PROCEDURE CodeStatementNote (tokenno: CARDINAL) ;
BEGIN
+ IF Debugging
+ THEN
+ MetaErrorT0 (tokenno, '{%W} statement note')
+ END ;
CurrentQuadToken := tokenno ;
addStmtNote (TokenToLocation (tokenno))
END CodeStatementNote ;
False exit is backpatched with q+1
*)
-PROCEDURE BuildEndWhile ;
+PROCEDURE BuildEndWhile (reltokpos: INTEGER) ;
(*
False exit is backpatched with q+1
*)
-PROCEDURE BuildEndWhile ;
+PROCEDURE BuildEndWhile (reltokpos: INTEGER) ;
VAR
+ tok : CARDINAL ;
While,
t, f : CARDINAL ;
BEGIN
- PopBool(t, f) ;
- Assert(t=0) ;
- PopT(While) ;
- GenQuad(GotoOp, NulSym, NulSym, While) ;
- BackPatch(f, NextQuad)
+ tok := GetTokenNo () ;
+ tok := VAL (INTEGER, tok) + reltokpos ;
+ PopBool (t, f) ;
+ Assert (t=0) ;
+ PopT (While) ;
+ GenQuadO (tok, GotoOp, NulSym, NulSym, While, FALSE) ;
+ BackPatch (f, NextQuad)
END BuildEndWhile ;
% BuildStmtNote (0) %
"DO" % BuildDoWhile %
StatementSequence % BuildStmtNote (0) %
- "END" % DisplayStack ; BuildEndWhile %
+ "END" % DisplayStack ; BuildEndWhile (-1) %
=:
RepeatStatement := "REPEAT"
#include "m2options.h"
#include "m2tree.h"
#include "m2treelib.h"
+#include "m2pp.h"
/* For each binding contour we allocate a binding_level structure
which records the entities defined or declared in that contour.
return error_mark_node;
}
-/* GetGlobals - returns a list of global variables, functions,
- constants. */
+/* GetGlobals returns a list of global variables, functions and constants. */
tree
m2block_GetGlobals (void)
return global_binding_level->context;
}
-/* do_add_stmt - t is a statement. Add it to the statement-tree. */
+/* do_add_stmt t is a statement. Add it to the statement-tree. */
static tree
do_add_stmt (tree t)
return t;
}
-/* flush_pending_note - flushes a pending_statement note if
- necessary. */
+/* flush_pending_note flushes a pending_statement note if necessary. */
static void
flush_pending_note (void)
{
if (pending_statement && (M2Options_GetM2g ()))
{
-#if 0
- /* --fixme-- we need a machine independant way to generate a nop. */
- tree instr = m2decl_BuildStringConstant ("nop", 3);
- tree string
- = resolve_asm_operand_names (instr, NULL_TREE, NULL_TREE, NULL_TREE);
- tree note = build_stmt (pending_location, ASM_EXPR, string, NULL_TREE,
- NULL_TREE, NULL_TREE, NULL_TREE);
-
- ASM_BASIC_P (note) = false;
- ASM_VOLATILE_P (note) = false;
-#else
tree note = build_empty_stmt (pending_location);
-#endif
pending_statement = false;
do_add_stmt (note);
}
m2pp_print (state, ");\n");
}
+/* m2pp_nop_expr display the nop_expr node. */
+
+static void
+m2pp_nop_expr (pretty *state, tree t)
+{
+ enum tree_code code = TREE_CODE (t);
+ m2pp_begin (state);
+ m2pp_print (state, "(* NOP for debug location *)");
+ m2pp_needspace (state);
+ m2pp_loc (state, t);
+}
+
/* m2pp_statement attempts to reconstruct a statement. */
static void
case IF_STMT:
m2pp_if_stmt (s, t);
break;
+ case NOP_EXPR:
+ m2pp_nop_expr (s, t);
+ break;
case ERROR_MARK:
m2pp_print (s, "<ERROR CODE>\n");
break;
--- /dev/null
+MODULE whilestep ;
+
+FROM libc IMPORT printf ;
+
+PROCEDURE init ;
+VAR
+ c: CARDINAL ;
+BEGIN
+ c := 0 ;
+ WHILE c < 20 DO
+ printf ("iteration %d\n", c) ;
+ INC (c)
+ END
+END init ;
+
+BEGIN
+ init
+END whilestep.