示例#1
0
        public VCPU(byte[] exe, IScriptContext ctx)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException(nameof(ctx));
            }
            Context = ctx;

            maki  = new Maki(exe);
            types = maki.Guids.Select(
                g => ctx.ResolveType(g)).ToList();
            imports = maki.Imports.Select(
                i => new ScriptImport(ctx, i)).ToList();
            var events = maki.Listeners.Select(
                l => new ScriptEvent(ctx, l, CreateEventHandler)).ToList();
            var memory = new ScriptMemory(
                maki.Objects.Select(InstantiateIfGuid), events);

            stack = new ScriptStack(memory);
            code  = maki.Code.ToArray();

            // We have init section
            ExecuteAndStop(0, maki.Listeners.Min(l => l.Offset));

            shutdown = memory.Unsubscribe;
        }
示例#2
0
 public ScriptStack(ScriptMemory objectStore)
 {
     objects = objectStore;
 }