コード例 #1
0
        public StackSlot(CSWC classfinder,Player player)
        {
            this.player = player;
            store       = new RunTimeValueBase[(int)RunTimeDataType._OBJECT + 1];
            index       = (int)RunTimeDataType.unknown;

            _cache_arraySlot     = new operators.OpAccess_Dot.arraySlot(null,0,classfinder);
            _cache_vectorSlot    = new operators.OpVector.vectorSLot(null,0,classfinder);
            _cache_prototypeSlot = new operators.OpAccess_Dot.prototypeSlot(null,null,null);
            _cache_setthisslot   = new SetThisItemSlot();

            //存储器设置初始值
            for (int i = 0; i < RunTimeDataType._OBJECT + 1; i++)
            {
                RunTimeDataType t = (RunTimeDataType)i;
                if (t != RunTimeDataType.unknown)
                {
                    store[i] = TypeConverter.getDefaultValue(t).getValue(null,null);
                }
            }

            store[RunTimeDataType.rt_array]    = null;
            store[RunTimeDataType.rt_string]   = null;
            store[RunTimeDataType.rt_function] = null;


            _numberValue = (rtNumber)store[RunTimeDataType.rt_number];
            _intValue    = (rtInt)store[RunTimeDataType.rt_int];
            _uintValue   = (rtUInt)store[RunTimeDataType.rt_uint];
            _stringValue = new rtString(string.Empty);

            _functionValue  = new rtFunction(-1,false);
            _functon_result = new rtFunction(-1,false);
        }
 public static void regNativeFunctions(CSWC bin)
 {
     bin.regNativeFunction(LinkSystem_Buildin.getCreator("as3runtime_RefOutStore_creator", default(RefOutStore)));
     bin.regNativeFunction(new as3runtime_RefOutStore_ctor());
     bin.regNativeFunction(new as3runtime_RefOutStore_setValue());
     bin.regNativeFunction(new as3runtime_RefOutStore_getValue());
 }
コード例 #3
0
        public static void regNativeFunctions(CSWC bin)
        {
            bin.regNativeFunction(LinkSystem_Buildin.getCreator("_system_Delegate_creator_", default(Delegate)));
            bin.regNativeFunction(LinkSystem_Buildin.getCreator("_system_MulticastDelegate_creator_", default(MulticastDelegate)));


            bin.regNativeFunction(new system_MulticastDelegate_add());
            bin.regNativeFunction(new system_MulticastDelegate_remove());
        }
コード例 #4
0
 public InternalError(CSWC swc, ASBinCode.SourceToken token, ASBinCode.RunTimeValueBase errorValue) : this(swc)
 {
     this.token      = token;
     this.errorValue = errorValue;
     if (errorValue != null)
     {
         this.message = getErrorInfo();                 //errorValue.ToString();
     }
 }
コード例 #5
0
        public void registrationAllFunction(CSWC bin)
        {
            bin.SetNativeFunctionFactory(this);
            var it = regAutoCreateCodes(bin);

            while (it.MoveNext())
            {
            }
        }
コード例 #6
0
ファイル: Class.cs プロジェクト: ikvm/ASTool
        public Class(int id, int blockid, CSWC swc, string md5key)
        {
            _swc         = swc;
            this.md5key  = md5key;
            classid      = id;
            this.blockid = blockid;
            classMembers = new ClassMemberList();
            fields       = new List <ClassMember>();
            implements   = new Dictionary <Class, int[]>();

            implicit_to_type       = RunTimeDataType.unknown;
            implicit_to_functionid = -1;
        }
コード例 #7
0
 public static void regNativeFunctions(CSWC bin)
 {
     bin.regNativeFunction(
         LinkSystem_Buildin.getCreator("_system_ArrayList_creator_", default(ArrayList)));// new system_int64_creator());
     bin.regNativeFunction(new system_collections_arraylist_ctor());
     bin.regNativeFunction(new system_collections_arraylist_static_createinstance());
     bin.regNativeFunction(new system_collections_arraylist_static_createinstance_());
     bin.regNativeFunction(new system_collections_arraylist_capcaity());
     bin.regNativeFunction(new system_collections_arraylist_addrange());
     bin.regNativeFunction(new system_collections_arraylist_copyto());
     bin.regNativeFunction(new system_collections_arraylist_copyto_());
     bin.regNativeFunction(new system_collections_arraylist_reverse());
     bin.regNativeFunction(new system_collections_arraylist_sort());
 }
コード例 #8
0
 public static void regNativeFunctions(CSWC bin)
 {
     bin.regNativeFunction(
         LinkSystem_Buildin.getCreator("_system_collections_stack_creator_", default(Stack)));// new system_int64_creator());
     bin.regNativeFunction(new system_collections_stack_ctor());
     bin.regNativeFunction(new system_collections_stack_static_createinstance());
     bin.regNativeFunction(new system_collections_stack_static_createinstance_());
     bin.regNativeFunction(new system_collections_stack_clear());
     bin.regNativeFunction(new system_collections_stack_contains());
     bin.regNativeFunction(new system_collections_stack_peek());
     bin.regNativeFunction(new system_collections_stack_pop());
     bin.regNativeFunction(new system_collections_stack_push());
     bin.regNativeFunction(new system_collections_stack_toarray());
 }
コード例 #9
0
        public System.Collections.IEnumerator registrationFunction(CSWC bin)
        {
            bin.SetNativeFunctionFactory(this);

            var method = this.GetType().GetMethod("regAutoCreateCodes", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            if (method == null)
            {
                //The AS3 project-related code was not found.Please create the AS3 project first, or export the API in the AS3 project
                throw new InvalidOperationException("没有找到AS3项目相关代码。请先创建AS3项目,或在AS3项目中将API导出");
            }
            return((System.Collections.IEnumerator)method.Invoke(this, new object[] { bin }));

            //return regAutoCreateCodes(bin);
        }
コード例 #10
0
        public static void regNativeFunctions(CSWC bin)
        {
            bin.regNativeFunction(
                LinkSystem_Buildin.getCreator("_system_Hashtable_creator_", default(Hashtable)));// new system_int64_creator());
            bin.regNativeFunction(new system_collections_hashtable_ctor());

            bin.regNativeFunction(
                LinkSystem_Buildin.getCreator(
                    "_system_DictionaryEntry_creator__",
                    default(DictionaryEntry)));// new system_int64_creator());
            bin.regNativeFunction(new system_collections_dictionaryentry_ctor());
            bin.regNativeFunction(new system_collections_dictionaryentry_getkey());
            bin.regNativeFunction(new system_collections_dictionaryentry_setkey());
            bin.regNativeFunction(new system_collections_dictionaryentry_getvalue());
            bin.regNativeFunction(new system_collections_dictionaryentry_setvalue());
        }
コード例 #11
0
 public static void regNativeFunctions(CSWC bin)
 {
     bin.regNativeFunction(
         LinkSystem_Buildin.getCreator("_system_collections_queue_creator_",
                                       default(Queue)));// new system_int64_creator());
     bin.regNativeFunction(new system_collections_queue_ctor());
     bin.regNativeFunction(new system_collections_queue_static_createinstance());
     bin.regNativeFunction(new system_collections_queue_static_createinstance_());
     bin.regNativeFunction(new system_collections_queue_clear());
     bin.regNativeFunction(new system_collections_queue_contains());
     bin.regNativeFunction(new system_collections_queue_dequeue());
     bin.regNativeFunction(new system_collections_queue_enqueue());
     bin.regNativeFunction(new system_collections_queue_peek());
     bin.regNativeFunction(new system_collections_queue_toarray());
     bin.regNativeFunction(new system_collections_queue_trimtosize());
 }
コード例 #12
0
 public static void regNativeFunctions(CSWC bin)
 {
     //bin.regNativeFunction(
     //    LinkSystem_Buildin.getCreator("_system_Char_creator__", default(Char)));
     bin.regNativeFunction(new system_char_ctor());
     //bin.regNativeFunction(
     //    LinkSystem_Buildin.getStruct_static_field_getter<Char>("_system_Char_MaxValue_getter"
     //    ,
     //    () => { return char.MaxValue; }
     //    )
     //    );
     //bin.regNativeFunction(
     //    LinkSystem_Buildin.getStruct_static_field_getter<Char>("_system_Char_MinValue_getter"
     //    ,
     //    () => { return char.MinValue; }
     //    )
     //    );
     bin.regNativeFunction(new system_char_explicit_from());
     bin.regNativeFunction(new system_char_valueOf());
 }
コード例 #13
0
        public static void regNativeFunctions(CSWC bin)
        {
            bin.regNativeFunction(LinkSystem_Buildin.getCreator(
                                      "_system_Array_creator_", default(Array)));

            bin.regNativeFunction(new system_array_rank());
            bin.regNativeFunction(new system_array_getlength());
            bin.regNativeFunction(new system_array_getlowerbound());
            bin.regNativeFunction(new system_array_getupperbound());
            bin.regNativeFunction(new system_array_ctor <object>("_system_Array_ctor_"));
            bin.regNativeFunction(new system_array_static_createinstance());
            bin.regNativeFunction(new system_array_static_createinstance_());
            bin.regNativeFunction(new system_array_static_createinstance__());
            //bin.regNativeFunction(new system_array_getValue());
            //bin.regNativeFunction(new system_array_setValue());
            bin.regNativeFunction(new system_array_getValue_());
            bin.regNativeFunction(new system_array_setValue_());
            bin.regNativeFunction(new system_array_getValue__());
            bin.regNativeFunction(new system_array_setValue__());
        }
コード例 #14
0
        public StackLinkObjectCache(CSWC bin, Player player)
        {
            this.player = player;
            int maxstructidx = -1;

            foreach (var item in bin.class_Creator)
            {
                var cls = item.Key;

                {
                    if (cls.structIndex > maxstructidx)
                    {
                        maxstructidx = cls.structIndex;
                    }
                }
            }

            structuseswitchs = new bool[maxstructidx + 1];
            strunctuseindexs = new int[maxstructidx + 1];
            strunctusecount  = 0;

            if (maxstructidx >= 0)
            {
                cache = new StackCacheObject[maxstructidx + 1];
                //cache[0] = player.alloc_pureHostedOrLinkedObject(player.swc.LinkObjectClass);
                cache[0] = StackCacheObject.createFrom(this, player.alloc_pureHostedOrLinkedObject(player.swc.LinkObjectClass));


                foreach (var item in bin.class_Creator)
                {
                    var cls = item.Key;
                    if (cls.isStruct)
                    {
                        cache[cls.structIndex] = StackCacheObject.createFrom(this, player.alloc_pureHostedOrLinkedObject(cls));
                    }
                }
            }
        }
コード例 #15
0
 public static void regNativeFunctions(CSWC bin)
 {
     //bin.regNativeFunction(
     //   LinkSystem_Buildin.getCreator("_system_SByte_creator__", default(SByte)));
     bin.regNativeFunction(new system_sbyte_ctor());
     //bin.regNativeFunction(
     //    LinkSystem_Buildin.getStruct_static_field_getter<SByte>("_system_SByte_MaxValue_getter"
     //    ,
     //    () => { return SByte.MaxValue; }
     //    )
     //    );
     //bin.regNativeFunction(
     //    LinkSystem_Buildin.getStruct_static_field_getter<SByte>("_system_SByte_MinValue_getter"
     //    ,
     //    () => { return SByte.MinValue; }
     //    )
     //    );
     bin.regNativeFunction(new system_sbyte_explicit_from());
     bin.regNativeFunction(new system_sbyte_implicit_from());
     bin.regNativeFunction(new system_sbyte_static_Parse());
     bin.regNativeFunction(new system_sbyte_valueOf());
     //bin.regNativeFunction(new system_sbyte_toString_());
 }
コード例 #16
0
 public static void regNativeFunctions(CSWC bin)
 {
     //bin.regNativeFunction(
     //   LinkSystem_Buildin.getCreator("_system_UInt64_creator__", default(UInt64)));
     bin.regNativeFunction(new system_uint64_ctor());
     //bin.regNativeFunction(
     //    LinkSystem_Buildin.getStruct_static_field_getter<UInt64>("_system_UInt64_MaxValue_getter"
     //    ,
     //    () => { return UInt64.MaxValue; }
     //    )
     //    );
     //bin.regNativeFunction(
     //    LinkSystem_Buildin.getStruct_static_field_getter<UInt64>("_system_UInt64_MinValue_getter"
     //    ,
     //    () => { return UInt64.MinValue; }
     //    )
     //    );
     bin.regNativeFunction(new system_uint64_explicit_from());
     bin.regNativeFunction(new system_uint64_implicit_from());
     //bin.regNativeFunction(new system_uint64_static_Parse());
     bin.regNativeFunction(new system_uint64_valueOf());
     //bin.regNativeFunction(new system_uint64_toString_());
 }
コード例 #17
0
 public CodeGen(ASBinCode.rtti.Class as3class, CSWC swc, ASRuntime.Player player)
 {
     this.swc      = swc;
     this.as3class = as3class;
     this.player   = player;
 }
コード例 #18
0
        IEnumerator INativeFunctionRegister.registrationFunction(CSWC bin)
        {
            bin.SetNativeFunctionFactory(this);

            throw new NotImplementedException();
        }
コード例 #19
0
ファイル: extFunctions.cs プロジェクト: ikvm/ASTool
 public void registrationFunction(CSWC bin)
 {
     bin.SetNativeFunctionFactory(this);
     regAutoCreateCodes(bin);
 }
コード例 #20
0
        private static ASBinCode.rtti.Object createObject(CSWC swc,Class cls,InstanceCreator creator,
                                                          out ASBinCode.rtData.rtObjectBase rtObjectBase,
                                                          out ASBinCode.rtData.rtObjectBase linkrtobj,
                                                          out string errinfo
                                                          )
        {
            ASBinCode.rtti.Object obj = null;// = new ASBinCode.rtti.Object(cls);
            rtObjectBase = null; linkrtobj = null; errinfo = null;
            if (cls.isLink_System)
            {
                if (creator != null)
                {
                    StackSlot stackSlot = creator.objectStoreToSlot as StackSlot;
                    if (stackSlot != null)
                    {
                        rtObjectBase = stackSlot.getStackCacheObject(cls);
                        return(rtObjectBase.value);
                    }
                }


                var func = (NativeFunctionBase)swc.class_Creator[cls];

                string err; int no;
                ASBinCode.rtData.rtObjectBase rtObj =
                    func.execute(null,null,cls,out err,out no) as ASBinCode.rtData.rtObjectBase;
                linkrtobj = rtObj;
                if (rtObj == null)
                {
                    errinfo = cls.ToString() + " create linksystem object failed";
                    return(null);
                }
                else
                {
                    return(rtObj.value);
                }
            }
            else if (cls.isCrossExtend)
            {
                var scls = cls.super;
                while (!scls.isLink_System)
                {
                    scls = scls.super;
                }

                var cextend = scls.staticClass.linkObjCreator;
                var func    = swc.getNativeFunction(((ClassMethodGetter)cextend.bindField).functionId);

                if (func == null)
                {
                    errinfo = cls.ToString() + " create crossextend object failed, creator function not found";
                    return(null);
                }

                string err; int no;
                ASBinCode.rtData.rtObjectBase rtObj =
                    func.execute(null,null,cls,out err,out no) as ASBinCode.rtData.rtObjectBase;
                linkrtobj = rtObj;
                if (rtObj == null)
                {
                    errinfo = cls.ToString() + " create crossextend object failed";
                    return(null);
                }
                else
                {
                    LinkSystemObject lo = (LinkSystemObject)rtObj.value;
                    return(lo);
                }
            }
            else if (
                swc.DictionaryClass != null
                &&
                ClassMemberFinder.isInherits(cls,swc.DictionaryClass))
            {
                obj = new DictionaryObject(cls);
            }
            else if (cls.dynamic)
            {
                if (cls.isUnmanaged)
                {
                    obj = new HostedDynamicObject(cls);
                }
                else
                {
                    obj = new DynamicObject(cls);
                }
            }
            else if (cls.isUnmanaged)
            {
                obj = new HostedObject(cls);
            }
            else
            {
                obj = new ASBinCode.rtti.Object(cls);
            }

            return(obj);
        }
コード例 #21
0
 public InternalError(CSWC swc, ASBinCode.SourceToken token, string message, ASBinCode.RunTimeValueBase errorValue) : this(swc)
 {
     this.token      = token;
     this.message    = message;
     this.errorValue = errorValue;
 }
コード例 #22
0
 public InternalError(CSWC swc, ASBinCode.SourceToken token, string message) : this(swc)
 {
     this.token      = token;
     this.message    = message;
     this.errorValue = null;
 }
コード例 #23
0
 private InternalError(CSWC swc)
 {
     this.swc = swc;
 }
コード例 #24
0
        public static ASBinCode.RunTimeValueBase Eval(ASTool.AS3.AS3Expression expression,
                                                      Builder importBuilder = null
                                                      )
        {
            try
            {
                Builder builder = new Builder(new BuildOptions()
                {
                    isConsoleOut = false
                }, true);

                int bid = builder.getBlockId();

                if (importBuilder != null && importBuilder._currentImports.Count > 0)
                {
                    List <ASBinCode.rtti.Class> imps = new List <ASBinCode.rtti.Class>();
                    imps.AddRange(importBuilder._currentImports.Peek());

                    builder._currentImports.Push(imps);

                    bid = importBuilder.bin.blocks.Count;
                }

                CompileEnv tempEnv = new CompileEnv(new CodeBlock(bid, "temp", -65535, true), true);
                tempEnv.block.scope = new ASBinCode.scopes.StartUpBlockScope();
                builder.buildExpressNotEval(tempEnv, expression);

                tempEnv.completSteps(builder);
                tempEnv.block.totalStackSlots = tempEnv.combieNeedStackSlots();

                if (builder.buildErrors.Count == 0)
                {
                    RightValueBase value = builds.ExpressionBuilder.getRightValue(tempEnv, expression.Value, expression.token, builder);

                    if (player == null)
                    {
                        player = new ASRuntime.Player(null);
                    }
                    CSWC tempswc = new CSWC();
                    if (importBuilder != null)
                    {
                        tempswc.blocks.AddRange(importBuilder.bin.blocks);
                        tempswc.classes.AddRange(importBuilder.bin.classes);
                        tempswc.functions.AddRange(importBuilder.bin.functions);
                    }
                    tempswc.blocks.Add(tempEnv.block);

                    Variable variableResult = new Variable("@@", tempEnv.block.scope.members.Count, tempEnv.block.id);
                    tempEnv.block.scope.members.Add(variableResult);
                    OpStep step = new OpStep(OpCode.assigning, new SourceToken(0, 0, ""));
                    step.reg  = variableResult;
                    step.arg1 = value;
                    tempEnv.block.opSteps.Add(step);
                    tempEnv.block.instructions = tempEnv.block.opSteps.ToArray();
                    tempEnv.block.opSteps      = null;
                    player.loadCode(tempswc, tempEnv.block);

                    RunTimeValueBase result = player.run(variableResult);

                    return(result);
                    //IRunTimeScope scope = player.run();

                    //if (player.runtimeError ==null)
                    //{
                    //    return value.getValue(scope);
                    //}
                    //else
                    //{
                    //    return null;
                    //}
                }
                else
                {
                    return(null);
                }
            }
            catch (BuildException)
            {
                return(null);
            }
        }
 public static void regNativeFunctions(CSWC bin)
 {
     bin.regNativeFunction(LinkSystem_Buildin.getCreator("asruntime_nativefuncs_linksystem_Iterator_creator", default(ASRuntime.nativefuncs.linksystem.Iterator)));
     bin.regNativeFunction(new asruntime_nativefuncs_linksystem_Iterator_ctor());
     bin.regNativeFunction(new static_asruntime_nativefuncs_linksystem_Iterator_op_Explicit());
 }
コード例 #26
0
 public static void regNativeFunctions(CSWC bin)
 {
     bin.regNativeFunction(LinkSystem_Buildin.getCreator("system_ICloneable_creator", default(System.ICloneable)));
     bin.regNativeFunction(new system_ICloneable_clone());
 }
コード例 #27
0
        public void init(CSWC swc)
        {
            this.swc  = swc;
            arrayType = typeof(Array);

            link_type = new Dictionary <Type, RunTimeDataType>();



            link_type.Add(typeof(int), RunTimeDataType.rt_int);
            link_type.Add(typeof(string), RunTimeDataType.rt_string);
            link_type.Add(typeof(double), RunTimeDataType.rt_number);
            link_type.Add(typeof(bool), RunTimeDataType.rt_boolean);
            link_type.Add(typeof(uint), RunTimeDataType.rt_uint);
            link_type.Add(typeof(ASBinCode.rtData.rtArray), RunTimeDataType.rt_array);
            link_type.Add(typeof(ASBinCode.rtData.rtFunction), RunTimeDataType.rt_function);
            link_type.Add(typeof(DictionaryKey), _DICT_KEY);
            link_type.Add(typeof(RunTimeValueBase), _OBJECT_LINK);
            link_type.Add(typeof(float), _FLOAT);
            link_type.Add(typeof(short), _SHORT);
            link_type.Add(typeof(ushort), _USHORT);

            foreach (var item in swc.creator_Class)
            {
                link_type.Add(item.Key.getLinkSystemObjType(), item.Value.getRtType());
                link_type.Add(new AS3Class_Type(item.Value.staticClass.getRtType(), item.Key.getLinkSystemObjType()), item.Value.staticClass.getRtType());

                if (item.Key.getLinkSystemObjType().Equals(typeof(object)))
                {
                    _objectType_ = item.Value.getRtType();
                }
            }

            type_link = new Dictionary <RunTimeDataType, Type>();
            type_link.Add(RunTimeDataType.rt_int, typeof(int));
            type_link.Add(RunTimeDataType.rt_string, typeof(string));
            type_link.Add(RunTimeDataType.rt_number, typeof(double));
            type_link.Add(RunTimeDataType.rt_boolean, typeof(bool));
            type_link.Add(RunTimeDataType.rt_uint, typeof(uint));
            type_link.Add(RunTimeDataType.rt_array, typeof(ASBinCode.rtData.rtArray));
            type_link.Add(RunTimeDataType.rt_function, typeof(ASBinCode.rtData.rtFunction));
            type_link.Add(_DICT_KEY, typeof(DictionaryKey));
            type_link.Add(_OBJECT_LINK, typeof(RunTimeValueBase));
            type_link.Add(_FLOAT, typeof(float));
            type_link.Add(_SHORT, typeof(short));
            type_link.Add(_USHORT, typeof(ushort));

            foreach (var item in swc.creator_Class)
            {
                type_link.Add(item.Value.getRtType(), item.Key.getLinkSystemObjType());

                type_link.Add(item.Value.staticClass.getRtType(), new AS3Class_Type(item.Value.staticClass.getRtType(), item.Key.getLinkSystemObjType()));
            }

            if (swc.TypeClass == null)
            {
                return;
            }

            {
                var clsint = swc.getClassDefinitionByName("int").staticClass.getRtType();
                link_type.Add(new AS3Class_Type(clsint, typeof(int)), clsint);
                type_link.Add(clsint, new AS3Class_Type(clsint, typeof(int)));
            }
            {
                var clsuint = swc.getClassDefinitionByName("uint").staticClass.getRtType();
                link_type.Add(new AS3Class_Type(clsuint, typeof(uint)), clsuint);
                type_link.Add(clsuint, new AS3Class_Type(clsuint, typeof(uint)));
            }
            {
                var clsstring = swc.getClassDefinitionByName("String").staticClass.getRtType();
                link_type.Add(new AS3Class_Type(clsstring, typeof(string)), clsstring);
                type_link.Add(clsstring, new AS3Class_Type(clsstring, typeof(string)));
            }
            {
                var clsboolean = swc.getClassDefinitionByName("Boolean").staticClass.getRtType();
                link_type.Add(new AS3Class_Type(clsboolean, typeof(bool)), clsboolean);
                type_link.Add(clsboolean, new AS3Class_Type(clsboolean, typeof(bool)));
            }
            {
                var clsnumber = swc.getClassDefinitionByName("Number").staticClass.getRtType();
                link_type.Add(new AS3Class_Type(clsnumber, typeof(double)), clsnumber);
                type_link.Add(clsnumber, new AS3Class_Type(clsnumber, typeof(double)));
            }
        }