Пример #1
0
        internal Process LaunchProcess(Method m)
        {
            Process p = new Process();
            p.Call(m);
            running.Enqueue(p);

            return p;
        }
Пример #2
0
 public Method Compile(IBlock b, bool mainProgram)
 {
     List<Instruction> instructions = CompileBlockToInstructions(b, mainProgram);
     Method ret = new Method();
     ret.Instructions = instructions.ToArray();
     ret.Arity = 0;
     ret.PrepareLabels();
     return ret;
 }
Пример #3
0
        public Method DefineMethod(ProcDefBlock b, BlockStack stack)
        {
            // 'stack' is a BlockStack whose first element (#0) is a ProcDefBlock, the same as 'b'

            Method ret = new Method();
            List<Instruction> instructions = new List<Instruction>();
            string[] argNames = b.GetArgNames();
            for (int i = 0; i < argNames.Length; ++i)
            {
                instructions.Add(new PopLocal(vm, argNames[i]));
            }
            for(int i=1; i<stack.Count; ++i)
                instructions.AddRange(CompileBlockToInstructions(stack[i], false));
            instructions.Add(new Push(vm, null));
            instructions.Add(new Ret(vm));
            ret.Instructions = instructions.ToArray();
            ret.Arity = argNames.Length;
            ret.PrepareLabels();
            return ret;
        }
Пример #4
0
 internal void DefineMethod(string name, Method m)
 {
     methods[name] = m;
 }
Пример #5
0
 public Frame(Method method)
 {
     this.Method = method;
     IP = 0;
 }
Пример #6
0
 public Call(VM vm, Method callee)
     : base(vm)
 {
     this.callee = callee;
 }