From a24fb5cd32797d39c26d49d50e221090a3516598 Mon Sep 17 00:00:00 2001 From: buraq Date: Tue, 2 Dec 2003 15:35:23 +0000 Subject: added debugprint code creation --- sources/scalac/ast/TreeGen.java | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'sources') diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java index 1df5678920..c1fc1ebeea 100644 --- a/sources/scalac/ast/TreeGen.java +++ b/sources/scalac/ast/TreeGen.java @@ -725,12 +725,16 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { return If(cond.pos, cond, thenpart, elsepart); } - /** Builds a Switch node with given components and type. */ + /** Builds a Switch node with given components and type. + * @param tags a sorted array of tags + */ public Switch Switch(int pos, Tree test, int[] tags, Tree[] bodies, Tree otherwise, Type type) { - for (int i = 0; i < bodies.length; i++) + for (int i = 0; i < bodies.length; i++) { assert assertTreeSubTypeOf(bodies[i], type); + assert (i==0) || ( tags[i-1] < tags[i] ) : "expecting sorted tags"; + } assert assertTreeSubTypeOf(otherwise, type); Switch tree = make.Switch(pos, test, tags, bodies, otherwise); tree.setType(type); @@ -1167,4 +1171,20 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { } + // for insert debug printing code + + public Tree Console_print(int pos, String str) { + return Console_print( pos, mkStringLit( pos, str )); + } + + public Tree Console_print(int pos, Tree arg) { + Symbol sym = global.definitions.getModule( Names.scala_Console ); + return Apply( Select( pos, + mkRef( pos, sym), + global.definitions.CONSOLE_PRINT()), + new Tree[] { + arg + }); + } + } -- cgit v1.2.3