Esempio n. 1
0
        public void If(Expression id, Action <AbsynCodeEmitter> then)
        {
            var thenStmts   = new List <AbsynStatement>();
            var thenEmitter = new AbsynCodeEmitter(thenStmts);

            then(thenEmitter);
            stmts.Add(new AbsynIf(id, thenStmts));
        }
Esempio n. 2
0
        public void While(Expression cond, Action <AbsynCodeEmitter> bodyGen)
        {
            var bodyStmts = new List <AbsynStatement>();
            var m         = new AbsynCodeEmitter(bodyStmts);

            bodyGen(m);
            stmts.Add(new AbsynWhile(cond, bodyStmts));
        }
Esempio n. 3
0
        public void DoWhile(Action <AbsynCodeEmitter> bodyGen, BinaryExpression cond)
        {
            var bodyStmts = new List <AbsynStatement>();
            var m         = new AbsynCodeEmitter(bodyStmts);

            bodyGen(m);
            stmts.Add(new AbsynDoWhile(bodyStmts, cond));
        }
Esempio n. 4
0
        public void For(
            Func <AbsynCodeEmitter, AbsynAssignment> init,
            Func <AbsynCodeEmitter, Expression> cond,
            Func <AbsynCodeEmitter, AbsynAssignment> update,
            Action <AbsynCodeEmitter> body)
        {
            var initStms    = new List <AbsynStatement>();
            var initEmitter = new AbsynCodeEmitter(initStms);
            var initStm     = init(initEmitter);
            var condExp     = cond(initEmitter);
            var updateStm   = update(initEmitter);
            var bodyStms    = new List <AbsynStatement>();
            var bodyEmitter = new AbsynCodeEmitter(bodyStms);

            body(bodyEmitter);
            this.stmts.Add(new AbsynFor(initStm, condExp, updateStm, bodyStms));
        }
Esempio n. 5
0
        private void RunHllTest(string testName, string sExp, Action <Procedure, AbsynCodeEmitter> builder)
        {
            var arch  = new FakeArchitecture(new ServiceContainer());
            var frame = arch.CreateFrame();
            var proc  = Procedure.Create(arch, Address.Ptr32(0x00123400), frame);

            proc.Body = new List <Core.Absyn.AbsynStatement>();
            var m = new AbsynCodeEmitter(proc.Body);

            builder(proc, m);
            var program = CreateProgram(proc);
            var sActual = ProcedureRenderer.RenderProcedureHll(program, proc.EntryAddress.ToString());

            if (sExp != sActual)
            {
                Console.WriteLine(sActual);
                Assert.AreEqual(sExp, sActual);
            }
        }