public override void Compile(CEnv env, Generator gen)
        {
            String L1 = Label.Fresh();
            String L2 = Label.Fresh();

            e1.Compile(env, gen);
            gen.Emit(new IFZERO(L1));
            e2.Compile(env, gen);
            gen.Emit(new GOTO(L2));
            gen.Label(L1);
            e3.Compile(env, gen);
            gen.Label(L2);
        }
Exemple #2
0
        public override void Compile(CEnv env, Generator gen)
        {
            string l1 = Label.Fresh();
            string l2 = Label.Fresh();

            cond.Compile(env, gen);
            gen.Emit(new IFZERO(l1));
            e2.Compile(env, gen);
            gen.Emit(new GOTO(l2));
            gen.Label(l1);
            e3.Compile(env, gen);
            gen.Label(l2);
        }
Exemple #3
0
        public override void Compile(CompilationEnvironment env, Generator gen)
        {
            var l1 = Label.Fresh();
            var l2 = Label.Fresh();

            e1.Compile(env, gen);
            gen.Emit(new IfZero(l1));
            e2.Compile(env, gen);           // inside if
            gen.Emit(new Goto(l2));
            //generate flash labels: Label.Fresh()
            gen.Label(l1);        // add labels to the stack machine  L1 -else
            e3.Compile(env, gen); // inside else

            gen.Label(l2);        // L2
        }
 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));
 }
 public void Compile(Generator gen, CEnv env)
 {
     foreach (Pair <String, Type> formArg in this.formArgs)
     {
         env.DeclareLocal(formArg.Fst);
     }
     gen.Label(env.getFunctionLabel(fName));
     body.Compile(env, gen);
     gen.Emit(new RET(formArgs.Count));
 }
Exemple #6
0
        public void Compile(Generator gen, CEnv env)
        {
            int argCount = 0;

            foreach (var formArg in formArgs)
            {
                env.DeclareLocal(formArg.Fst);
                argCount++;
            }

            gen.Label(env.getFunctionLabel(fName));
            body.Compile(env, gen);
            gen.Emit(new RET(argCount));
            //throw new NotSupportedException("This functionality will be provided at a later moment.");
        }
        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));
             */
        }