Beispiel #1
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;
 }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #4
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);
        }