Esempio n. 1
0
        public VM(Chunk p_chunk)
        {
            IP         = 0;
            parallelVM = false;

            main = p_chunk.MainFunctionUnit("main");

            instructions = new InstructionStack(callStackSize, main, out instructionsCache);

            stack = new Stack(callStackSize);

            variables          = new Memory <Unit>();
            upValues           = new Memory <UpValueUnit>();
            registeredUpValues = new UpValueEnv(variables);

            data       = p_chunk.GetData;
            Prelude    = p_chunk.Prelude;
            globals    = new Memory <Unit>();
            Intrinsics = p_chunk.Prelude.intrinsics;
            foreach (IntrinsicUnit v in Intrinsics)
            {
                // lock(globals) // not needed because this vm initialization does not run in parallel
                globals.Add(new Unit(v));
            }
            foreach (KeyValuePair <string, TableUnit> entry in p_chunk.Prelude.tables)
            {
                // lock(globals) // not needed because this vm initialization does not run in parallel
                globals.Add(new Unit(entry.Value));
            }
            LoadedModules = new Dictionary <string, int>();
            modules       = new List <ModuleUnit>();

            vmPool = new Stack <VM>();
        }
Esempio n. 2
0
        private VM(
            FunctionUnit p_main,
            List <Unit> p_data,
            Memory <Unit> p_globals,
            Library p_Prelude,
            Dictionary <string, int> p_LoadedModules,
            List <ModuleUnit> p_modules,
            Stack <VM> p_vmPool,
            bool p_parallelVM)
        {
            main          = p_main;
            data          = p_data;
            globals       = p_globals;
            Prelude       = p_Prelude;
            LoadedModules = p_LoadedModules;
            modules       = p_modules;
            vmPool        = p_vmPool;

            IP         = 0;
            parallelVM = p_parallelVM;

            instructions       = new InstructionStack(callStackSize, main, out instructionsCache);
            stack              = new Stack(callStackSize);
            variables          = new Memory <Unit>();
            upValues           = new Memory <UpValueUnit>();
            registeredUpValues = new UpValueEnv(variables);
        }