예제 #1
0
        private void inputProgram()
        {
//			IStmt prgStatement = new CompStmt(new NewStmt("a", new ConstExp(10)), new CompStmt(new WriteHeapStmt("a", new ConstExp(4)),  new CompStmt(new AssignStmt("b", new ConstExp(1)), new PrintStmt(new ReadHeapExp("b")))));
            //new CompStmt (new AssignStmt ("a", new ArithExp (new ConstExp (2), "-", new ConstExp (3))), new CompStmt (new IfThenStmt (new VarExp ("a"), new AssignStmt ("v", new ConstExp (2))), new PrintStmt (new VarExp ("v"))));
            //inputStatement ();
            IStmt st1          = new AssignStmt("v", new ConstExp(10));
            IStmt st2          = new NewStmt("a", new ConstExp(22));
            IStmt st3          = new AssignStmt("v", new ConstExp(32));
            IStmt st4          = new PrintStmt(new VarExp("v"));
            IStmt st5          = new PrintStmt(new ReadHeapExp("a"));
            IStmt st8          = new ForkStmt(new CompStmt(new WriteHeapStmt("a", new ConstExp(30)), new CompStmt(st3, new CompStmt(st4, st5))));
            IStmt st6          = new PrintStmt(new VarExp("v"));
            IStmt st7          = new PrintStmt(new ReadHeapExp("a"));
            IStmt prgStatement = new CompStmt(st1, new CompStmt(st2, new CompStmt(st8, new CompStmt(st6, new CompStmt(st7, new CompStmt(new SkipStmt(), new CompStmt(new SkipStmt(), new SkipStmt())))))));

            List <PrgState> programs = new List <PrgState> ();

            programs.Add(new PrgState(new MyLibraryStack <IStmt> (), new MyLibraryDictionary <String, int> (), new MyLibraryHeap <int> (), new MyLibraryList <int> (), prgStatement));
            programs.ForEach(p => print(p.ToString()));
            ctrl = new Controller(new MyRepository(programs));
            ctrl.serializeProgramState();
        }
예제 #2
0
        private void inputProgram()
        {
            //			IStmt prgStatement = new CompStmt(new NewStmt("a", new ConstExp(10)), new CompStmt(new WriteHeapStmt("a", new ConstExp(4)),  new CompStmt(new AssignStmt("b", new ConstExp(1)), new PrintStmt(new ReadHeapExp("b")))));
                //new CompStmt (new AssignStmt ("a", new ArithExp (new ConstExp (2), "-", new ConstExp (3))), new CompStmt (new IfThenStmt (new VarExp ("a"), new AssignStmt ("v", new ConstExp (2))), new PrintStmt (new VarExp ("v"))));
            //inputStatement ();
            IStmt st1 = new AssignStmt("v", new ConstExp(10));
            IStmt st2 = new NewStmt("a", new ConstExp(22));
            IStmt st3 = new AssignStmt("v", new ConstExp(32));
            IStmt st4 = new PrintStmt(new VarExp("v"));
            IStmt st5 = new PrintStmt(new ReadHeapExp("a"));
            IStmt st8 = new ForkStmt(new CompStmt(new WriteHeapStmt("a", new ConstExp(30)), new CompStmt(st3, new CompStmt(st4, st5))));
            IStmt st6 = new PrintStmt(new VarExp("v"));
            IStmt st7 = new PrintStmt(new ReadHeapExp("a"));
            IStmt prgStatement = new CompStmt(st1, new CompStmt(st2, new CompStmt(st8, new CompStmt(st6,new CompStmt (st7, new CompStmt(new SkipStmt(), new CompStmt(new SkipStmt(), new SkipStmt() )))))));

            List<PrgState> programs = new List<PrgState> ();
            programs.Add (new PrgState (new MyLibraryStack<IStmt> (), new MyLibraryDictionary<String, int> (), new MyLibraryHeap<int> (), new MyLibraryList<int> (), prgStatement));
            programs.ForEach(p => print(p.ToString()));
            ctrl = new Controller (new MyRepository (programs));
            ctrl.serializeProgramState ();
        }