Exemplo n.º 1
0
 private static void CreateInstance(AbcCode code, AbcInstance instance, int argLocal)
 {
     code.CreateInstance(instance,
                         () =>
     {
         code.GetLocal(argLocal);
         return(1);
     });
 }
Exemplo n.º 2
0
        private void NewFieldInfo(AbcCode code, AbcInstance instance, IField field, int varField)
        {
            var trait = field.Data as AbcTrait;

            if (trait == null)
            {
                code.PushNull();
                return;
            }

            var name = trait.Name;

            var fieldInfo = _generator.Corlib.GetInstance(CorlibTypeId.FieldInfo);

            code.CreateInstance(fieldInfo);
            code.SetLocal(varField);

            var ns = name.Namespace;

            code.GetLocal(varField);
            code.PushNamespace(ns);
            code.SetField(FieldId.FieldInfo_Namespace);

            code.GetLocal(varField);
            code.PushString(field.Name);
            code.SetField(FieldId.FieldInfo_Name);

            int typeIndex = GetTypeId(field.Type);

            code.GetLocal(varField);
            code.PushInt(typeIndex);
            code.SetField(FieldId.FieldInfo_Type);

            typeIndex = GetTypeId(field.DeclaringType);
            code.GetLocal(varField);
            code.PushInt(typeIndex);
            code.SetField(FieldId.FieldInfo_DeclType);

            code.GetLocal(varField);
            code.PushBool(field.IsStatic);
            code.SetField(FieldId.FieldInfo_IsStatic);

            if (GlobalSettings.ReflectionSupport)
            {
                InitCustomAttributes(code, instance, field, varField);
            }

            code.GetLocal(varField);
        }
Exemplo n.º 3
0
        private void RunTest(AbcCode code, IMethod test)
        {
            var testFixture = test.DeclaringType;

            var       testType     = GetType(NUnitTypeId.Test);
            var       testInstance = GetInstance(NUnitTypeId.Test);
            const int varTest      = 1;

            code.CreateInstance(testInstance);
            code.SetLocal(varTest);

            code.GetLocal(varTest);
            code.PushString(test.FullName);
            code.SetProperty(testType, "Name");

            code.GetLocal(varTest);
            code.PushString(testFixture.FullName);
            code.SetProperty(testType, "SuiteName");

            string desc = test.GetTestDescription();

            if (!string.IsNullOrEmpty(desc))
            {
                code.GetLocal(varTest);
                code.PushString(desc);
                code.SetProperty(testType, "Description");
            }

            desc = testFixture.GetTestDescription();
            if (!string.IsNullOrEmpty(desc))
            {
                code.GetLocal(varTest);
                code.PushString(desc);
                code.SetProperty(testType, "SuiteDescription");
            }

            var func = DefineTestRunner(test);

            code.GetLocal(varTest);
            code.GetStaticFunction(func);
            //code.CallSetter(testType, "Func");
            code.SetField(testType, "Func");

            //register test in FlashTestRunner
            code.CallStatic(GetMethod(NUnitMethodId.TestRunner_Register), () => code.GetLocal(varTest));
        }
Exemplo n.º 4
0
        private void InitPointers(AbcCode code)
        {
            if (!HasActivationVar)
            {
                return;
            }

            if (AbcGenConfig.UseActivationTraits)
            {
                code.NewActivation();
                if (AbcGenConfig.UseFuncPointers)
                {
                    code.Dup();
                    code.PushThisScope();
                    code.PushScope();
                }
            }
            else
            {
                code.CreateInstance(_activation);
            }
            code.SetLocal(_activationVar);

            if (IsThisAddressed)
            {
                var ptr = DefineThisPtr();
                GetActivation(code);
                code.LoadThis();
                code.SetSlot(ptr.Slot);
                InitSlotPtr(code, ptr);
            }

            //store arguments in slots
            int n = _method.Parameters.Count;

            for (int i = 0; i < n; ++i)
            {
                var p   = _method.Parameters[i];
                var ptr = p.Data as VarPtr;
                if (ptr == null)
                {
                    continue;
                }

                GetActivation(code);
                code.GetLocal(GetArgIndex(i));
                code.SetSlot(ptr.Slot);

                InitSlotPtr(code, ptr);
            }

            if (HasLocalVariables)
            {
                n = VarCount;
                for (int i = 0; i < n; ++i)
                {
                    var v   = GetVar(i);
                    var ptr = v.Data as VarPtr;
                    if (ptr == null)
                    {
                        continue;
                    }
                    InitSlotPtr(code, ptr);
                }
            }

            //NOTE: Because of VerifyError #1068
            if (AbcGenConfig.UseActivationTraits && AbcGenConfig.UseFuncPointers)
            {
                code.PopScope(); //activation
                code.PopScope(); //this
            }
        }