public void Compile(CompilationEnvironment compilationEnvironment, Generator generator)
 {
     compilationEnvironment.DeclareLocal(_argument.Item1); // Formal argument name points to top of stack
     generator.Label(compilationEnvironment.GetFunctionLabel(_name));
     _body.Compile(compilationEnvironment, generator);
     generator.Emit(new Return(1));
 }
Exemple #2
0
        public override void Compile(CompilationEnvironment env, Generator gen)
        {
            e1.Compile(env, gen);
            env.DeclareLocal(name);             // push the name variable to the stack<string> locals of CEnv

            //env.CompileVariable(gen, name); // get the array index of the variable name
            //gen.Emit(Instruction.LdI);      // load the variable name with the index which is on the top of the stack

            e2.Compile(env, gen);
            gen.Emit(Instruction.Swap);
            gen.Emit(new IncSp(-1));

            env.Pop();    // deallocate variable name
        }
        public void Compile(CompilationEnvironment env, Generator gen)
        {
            foreach (Tuple <String, Type> arg in args)
            {
                env.DeclareLocal(arg.Item1);
            }

            gen.Label(env.GetFunctionLabel(fName));
            body.Compile(env, gen);
            gen.Emit(new Return(args.Count));

            /*
             * env.DeclareLocal(formArg.Fst); // Formal argument name points to top of stack
             * gen.Label(env.getFunctionLabel(fName));
             * body.Compile(env, gen);
             * gen.Emit(new RET(1));
             */
        }