Exemple #1
0
        public IEnumerable <IInstruction> LoadReceiver(IMethod method, bool newobj)
        {
            EnsureMethod(method);

            if (!HasReceiver(method, newobj))
            {
                return(null);
            }

            var code = new AbcCode(_abc);

            CallStaticCtor(code, method);

            if (newobj)
            {
                LoadCtorReceiver(code, method);
                return(code);
            }

            if (LoadSpecReceiver(method, code))
            {
                return(code);
            }

            var inlineCall = method.Data as InlineCall;

            if (inlineCall != null && inlineCall.TargetType != null)
            {
                code.Getlex(inlineCall.TargetType);
                return(code);
            }

            if (method.IsStaticCall())
            {
                LoadStaticInstance(code, method.DeclaringType);
                return(code);
            }

            // TODO: check that code below is not needed now and remove it
            var mname = method.Data as AbcMultiname;

            if (mname != null)
            {
                code.FindPropertyStrict(mname);
                return(code);
            }

            //NOTE:
            //Primitive types should be boxed before calling of any instance method
            //But not here because object must be onto the stack.
            //And this operation must be controlled from the top level
            //if (TypeService.IsBoxablePrimitiveType(type))
            //{
            //    BoxPrimitive(code, type, false);
            //}

            return(code);
        }
Exemple #2
0
        private void LoadGlobalReceiver(AbcCode code, IMethod method)
        {
            var type = method.DeclaringType;

            if (type.Data is GlobalFunctionsContainer)
            {
                var mn = GetMethodName(method);
                code.FindPropertyStrict(mn);
                return;
            }

            if (type.IsInternalType())
            {
                string name = method.Name;
                var    mn   = _abc.DefineName(QName.Global(name));
                code.FindPropertyStrict(mn);
                return;
            }

            if (type.Is(SystemTypeCode.String))
            {
                code.Getlex(AvmTypeCode.String);
                return;
            }

            if (type.Is(AvmTypeCode.Class))
            {
                if (method.Name == "Find")
                {
                    var m = _generator.RuntimeImpl.FindClass();
                    code.Getlex(m);
                    return;
                }
            }

            throw new InvalidOperationException();
        }
Exemple #3
0
        private void RegisterRemoteClasses(AbcFile app, AbcCode code)
        {
            if (_remoteClasses.Count == 0)
            {
                return;
            }

            var registerClassAlias = app.DefineName(QName.Package("flash.net", "registerClassAlias"));

            foreach (var pair in _remoteClasses)
            {
                code.FindPropertyStrict(registerClassAlias);
                code.PushString(pair.Key);
                code.Getlex(pair.Value);
                code.CallVoid(registerClassAlias, 2);
            }
        }
Exemple #4
0
        public static void GetItem2(IMethod method, AbcCode code)
        {
            var p0 = method.Parameters[0].Type;

            if (p0.Name == "Namespace")
            {
                code.GetRuntimeProperty();
                code.CoerceXMLList();
            }
            else                               //namespace as Avm.String
            {
                code.Swap();                   //stack [name, nsname]
                var ns = code[AvmTypeCode.Namespace];
                code.FindPropertyStrict(ns);   //stack [name, nsname, global]
                code.Swap();                   //stack [name, global, nsname]
                code.ConstructProperty(ns, 1); //stack [name, ns]
                code.Coerce(ns);               //stack [name, ns]
                code.Swap();                   //stack [ns, name]
                code.GetRuntimeProperty();
                code.CoerceXMLList();
            }
        }
Exemple #5
0
 public static void Findpropstrict(AbcCode code)
 {
     code.FindPropertyStrict(code.Abc.RuntimeQName);
 }