+ type_class->ref++;
+}
+
+void type_class_unref(struct type_class *type_class)
+{
+ if (!--type_class->ref)
+ free_type_class(type_class);
+}
+
+void type_ref(struct type *type)
+{
+ type->ref++;
+}
+
+void type_unref(struct type *type)
+{
+ if (!--type->ref)
+ free_type(type);
+}
+
+struct declaration_scope *
+new_declaration_scope(struct declaration_scope *parent_scope)
+{
+ struct declaration_scope *scope = g_new(struct declaration_scope, 1);
+
+ scope->type_classes = g_hash_table_new_full(g_direct_hash,
+ g_direct_equal, NULL,
+ (GDestroyNotify) type_class_unref);
+ scope->parent_scope = parent_scope;
+ return scope;