예제 #1
0
 /// <summary>
 /// if文を構築
 /// </summary>
 /// <param name="pos">ファイル位置</param>
 /// <param name="cond">条件式</param>
 /// <param name="then_stmt">条件式が真のときに実行する文</param>
 /// <param name="else_stmt">条件式が偽のときに実行する文</param>
 public MIfStmt(string pos, MExpr cond, MStmt then_stmt, MStmt else_stmt)
     : base(pos)
 {
     Cond = cond;
     ThenStmt = then_stmt;
     ElseStmt = else_stmt;
 }
예제 #2
0
파일: MTop.cs 프로젝트: lambdataro/Mokkosu2
 /// <summary>
 /// トップレベル関数定義を構築
 /// </summary>
 /// <param name="pos">ファイル位置</param>
 /// <param name="name">関数名</param>
 /// <param name="args">仮引数の列</param>
 /// <param name="body">本体の文</param>
 public MTopFun(string pos, string name, List<MArg> args, MStmt body)
     : base(pos)
 {
     Name = name;
     Args = args;
     RetType = new TypeVar();
     Body = body;
 }
예제 #3
0
 /// <summary>
 /// 文のコンパイル
 /// </summary>
 /// <param name="ilgen">IL Generator</param>
 /// <param name="stmt">文</param>
 static void CompileStmt(ILGenerator ilgen, MStmt stmt)
 {
     if (stmt is MNopStmt)
     {
         // do nothing
     }
     else if (stmt is MMultiStmt)
     {
         CompileMultiStmt(ilgen, (MMultiStmt)stmt);
     }
     else if (stmt is MRetStmt)
     {
         CompileRetStmt(ilgen, (MRetStmt)stmt);
     }
     else if (stmt is MDoStmt)
     {
         CompileExpr(ilgen, ((MDoStmt)stmt).Expr);
     }
     else if (stmt is MVarStmt)
     {
         CompileVarStmt(ilgen, (MVarStmt)stmt);
     }
     else if (stmt is MLetStmt)
     {
         CompileLetStmt(ilgen, (MLetStmt)stmt);
     }
     else if (stmt is MIfStmt)
     {
         CompileIfStmt(ilgen, (MIfStmt)stmt);
     }
     else if (stmt is MWhileStmt)
     {
         CompileWhileStmt(ilgen, (MWhileStmt)stmt);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
예제 #4
0
 /// <summary>
 /// 文の型推論
 /// </summary>
 /// <param name="stmt">文</param>
 static void TypeinfStmt(MStmt stmt)
 {
     if (stmt is MNopStmt)
     {
         // nop
     }
     else if (stmt is MMultiStmt)
     {
         TypeinfMultiStmt((MMultiStmt)stmt);
     }
     else if (stmt is MRetStmt)
     {
         TypeinfRetStmt((MRetStmt)stmt);
     }
     else if (stmt is MDoStmt)
     {
         TypeinfDoStmt((MDoStmt)stmt);
     }
     else if (stmt is MVarStmt)
     {
         TypeinfVarStmt((MVarStmt)stmt);
     }
     else if (stmt is MLetStmt)
     {
         TypeinfLetStmt((MLetStmt)stmt);
     }
     else if (stmt is MIfStmt)
     {
         TypeinfIfStmt((MIfStmt)stmt);
     }
     else if (stmt is MWhileStmt)
     {
         TypeinfWhileStmt((MWhileStmt)stmt);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
예제 #5
0
 /// <summary>
 /// while文を構築
 /// </summary>
 /// <param name="pos">ファイル位置</param>
 /// <param name="cond">条件式</param>
 /// <param name="body">本体の文</param>
 public MWhileStmt(string pos, MExpr cond, MStmt body)
     : base(pos)
 {
     Cond = cond;
     Body = body;
 }