コード例 #1
0
ファイル: AST.cs プロジェクト: shunchuan/cnpl
            public override void Compile(CompilerBase state)
            {
                var cid = Guid.NewGuid();
                var end = $"{cid}-function-end";

                state.InsertJMP(end);
                state.FunctionDefine(Name, Parameters.Length, 0);
                state.EnterFunction(Name);
                state.InsertLabel($"<{Name}>");
                var iadstk = state.InsertALLOCDSTK();

                foreach (var p in Parameters)
                {
                    state.VariableDefine(p);
                }
                foreach (var p in Parameters)
                {
                    state.InsertSD(p);
                }

                mBlockStatement.Compile(state);
                state.InsertLC(new BooleanValue(false));
                state.InsertRET();
                iadstk.Size = state.CurrentScopeVariableCount;
                state.ExitFunction();
                state.InsertLabel(end);
            }
コード例 #2
0
ファイル: AST.cs プロジェクト: shunchuan/cnpl
 public override void Compile(CompilerBase state)
 {
     if (mExpression != null)
     {
         mExpression.Compile(state);
     }
     else
     {
         state.InsertLC(new BooleanValue(false));
     }
     state.InsertRET();
 }
コード例 #3
0
ファイル: AST.cs プロジェクト: shunchuan/cnpl
            public void Compile(CompilerBase state)
            {
                state.EnterFunction("<Program>");
                var iadstk = state.InsertALLOCDSTK();

                foreach (var s in mStatements)
                {
                    s.Compile(state);
                }
                state.InsertLC(new BooleanValue(false));
                state.InsertRET();
                iadstk.Size = state.CurrentScopeVariableCount;
                state.ExitFunction();
            }