diff options
Diffstat (limited to 'src/codegen/Label.java')
-rw-r--r-- | src/codegen/Label.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/codegen/Label.java b/src/codegen/Label.java new file mode 100644 index 0000000..52977c7 --- /dev/null +++ b/src/codegen/Label.java @@ -0,0 +1,32 @@ +package codegen; + +public class Label { + + private static String funDef = ""; + private static int labelCounter = 0; + private static int functionLabelCounter = 0; + + public static void addFunDef(String s) { + funDef += s; + } + + public static String getFunDef() { + return funDef; + } + + /** + * Create a new basic label. Use this method to define labels for if, while and + * for statemests. + */ + public static String newBasic(String base) { + return base + (labelCounter++); + } + + /** + * Create a new label for a function definition. + */ + public static String newFun(String base) { + return base + (functionLabelCounter++); + } + +} |