Ejemplo n.º 1
0
        // a "toplevel" class is treated as an instance, while TypeClass fields are treated as references
        void visitClass(TypeClass* t)
        {
            d_uns64 classoff = offset;

            // skip vtable-ptr and monitor
            if (t->sym->baseClass)
                visitClass((TypeClass*)t->sym->baseClass->type);

            for (size_t i = 0; i < t->sym->fields.dim; i++)
            {
                VarDeclaration *v = t->sym->fields[i];
                offset = classoff + v->offset;
                v->type->accept(this);
            }
            offset = classoff;
        }
Ejemplo n.º 2
0
	// Dynamically dispatch the appropriate visiting method at runtime from a GCObject*.
	void visitObj(GCObject* o, bool isModifyPhase, WBCallback callback)
	{
		// Green objects have no references to other objects.
		if(GCOBJ_COLOR(o) == GCFlags_Green)
			return;

		switch(o->type)
		{
			case CrocType_Table:     visitTable    (cast(Table*)o,     callback, isModifyPhase); return;
			case CrocType_Namespace: visitNamespace(cast(Namespace*)o, callback, isModifyPhase); return;
			case CrocType_Array:     visitArray    (cast(Array*)o,     callback, isModifyPhase); return;
			case CrocType_Function:  visitFunction (cast(Function*)o,  callback);                return;
			case CrocType_Funcdef:   visitFuncdef  (cast(Funcdef*)o,   callback);                return;
			case CrocType_Class:     visitClass    (cast(Class*)o,     callback, isModifyPhase); return;
			case CrocType_Instance:  visitInstance (cast(Instance*)o,  callback, isModifyPhase); return;
			case CrocType_Thread:    visitThread   (cast(Thread*)o,    callback, false);         return;
			case CrocType_Upval:     visitUpval    (cast(Upval*)o,     callback);                return;
			default:
				DBGPRINT("%p %u %03x %u\n", cast(void*)o, o->type, GCOBJ_COLOR(o), o->refCount);
				assert(false);
		}
	}