コード例 #1
0
 private static IVMTranslator CreateTranslator(
     ICounter eqCommandCounter,
     ICounter gtCommandCounter,
     ICounter ltCommandCounter,
     IFunctionCallCounter functionCallCounter,
     string filenameWithoutExt)
 {
     return(new VMTranslator.Lib.VMTranslator(
                new TextCleaner(),
                new CommandTranslator(
                    new ArithmeticCommandTranslator(
                        eqCommandCounter,
                        gtCommandCounter,
                        ltCommandCounter
                        ),
                    new StackOperationTranslator(
                        new CommandParser(),
                        new StackOperationTranslatorProvider(
                            new MemorySegmentPushCommandTranslator(),
                            new MemorySegmentPopCommandTranslator(),
                            new ConstantPushCommandTranslator(),
                            new StaticPushCommandTranslator(filenameWithoutExt),
                            new StaticPopCommandTranslator(filenameWithoutExt),
                            new PointerPushCommandTranslator(),
                            new PointerPopCommandTranslator(),
                            new TempPushCommandTranslator(),
                            new TempPopCommandTranslator()
                            )
                        ),
                    new LabelTranslator(filenameWithoutExt, new FunctionState()),
                    new GotoTranslator(filenameWithoutExt),
                    new IfGotoTranslator(filenameWithoutExt),
                    new FunctionTranslator(),
                    new ReturnTranslator(),
                    new CallFunctionTranslator(functionCallCounter)
                    )));
 }
コード例 #2
0
 private CallFunctionTranslator CreateSutWithCallCounter(IFunctionCallCounter callCounter)
 {
     return(new CallFunctionTranslator(callCounter));
 }
コード例 #3
0
 public CallFunctionTranslator(IFunctionCallCounter callCounter)
 {
     this.callCounter = callCounter;
 }