/// <summary> /// while文のコンパイル /// </summary> /// <param name="ilgen">IL Generator</param> /// <param name="stmt">while文</param> static void CompileWhileStmt(ILGenerator ilgen, MWhileStmt stmt) { var l1 = ilgen.DefineLabel(); var l2 = ilgen.DefineLabel(); ilgen.MarkLabel(l1); CompileExpr(ilgen, stmt.Cond); ilgen.Emit(OpCodes.Brfalse, l2); CompileStmt(ilgen, stmt.Body); ilgen.Emit(OpCodes.Br, l1); ilgen.MarkLabel(l2); }
/// <summary> /// while文の型推論 /// </summary> /// <param name="stmt">while文</param> static void TypeinfWhileStmt(MWhileStmt stmt) { TypeinfExpr(stmt.Cond); Unification(stmt.Pos, stmt.Cond.Type, new DotNetType(typeof(bool))); TypeinfStmt(stmt.Body); }