Example #1
0
/* This loads the symtab's classes into the vm's class table. That class table
   is used to give classes out to instances and enums that are built. The class
   information is later used to differentiate different instances. */
void lily_register_classes(lily_symtab *symtab, lily_vm_state *vm)
{
    lily_vm_ensure_class_table(vm, symtab->next_class_id + 1);

    lily_package *package_iter = symtab->first_package;
    while (package_iter) {
        lily_module_entry *module_iter = package_iter->first_module;
        while (module_iter) {
            lily_class *class_iter = module_iter->class_chain;
            while (class_iter) {
                if ((class_iter->flags & CLS_IS_VARIANT) == 0)
                    lily_vm_add_class_unchecked(vm, class_iter);

                class_iter = class_iter->next;
            }
            module_iter = module_iter->root_next;
        }
        package_iter = package_iter->root_next;
    }

    /* Variants have an id of 0 since they don't need to go into the class
       table. However, this causes them to take over Integer's slot. This makes
       sure that Integer has Integer's slot. */
    lily_vm_add_class_unchecked(vm, symtab->integer_class);
}
Example #2
0
/* This loads the symtab's classes into the vm's class table. That class table
   is used to give classes out to instances and enums that are built. The class
   information is later used to differentiate different instances. */
void lily_register_classes(lily_symtab *symtab, lily_vm_state *vm)
{
    lily_vm_ensure_class_table(vm, symtab->next_class_id + 1);

    lily_package *package_iter = symtab->first_package;
    while (package_iter) {
        lily_module_entry *module_iter = package_iter->first_module;
        while (module_iter) {
            lily_class *class_iter = module_iter->class_chain;
            while (class_iter) {
                lily_vm_add_class_unchecked(vm, class_iter);

                if (class_iter->flags & CLS_ENUM_IS_SCOPED) {
                    int i;
                    for (i = 0;i < class_iter->variant_size;i++) {
                        lily_class *v = (lily_class *)class_iter->variant_members[i];
                        lily_vm_add_class_unchecked(vm, v);
                    }
                }
                class_iter = class_iter->next;
            }
            module_iter = module_iter->root_next;
        }
        package_iter = package_iter->root_next;
    }

    /* Variants have an id of 0 since they don't need to go into the class
       table. However, this causes them to take over Integer's slot. This makes
       sure that Integer has Integer's slot. */
    lily_vm_add_class_unchecked(vm, symtab->integer_class);
}