Last change
on this file since 2687 was
2687,
checked in by ksherdy, 6 years ago
|
Added methods to generate @global label.
|
File size:
976 bytes
|
Line | |
---|
1 | package compiler.codeGenerator.visitors.helpers; |
---|
2 | |
---|
3 | import ast.*; |
---|
4 | |
---|
5 | import java.util.Iterator; |
---|
6 | import java.util.List; |
---|
7 | |
---|
8 | public abstract class UnparserUtil extends ASTVisitor.Default<CodeStore> { |
---|
9 | |
---|
10 | public static CodeStore concatenatedChildrenCode(List<CodeStore> childResults) { |
---|
11 | return concatenatedChildrenCode(new CodeStore(), childResults, false); |
---|
12 | } |
---|
13 | |
---|
14 | public static CodeStore concatenatedChildrenCode(CodeStore code, List<CodeStore> childResults, boolean blankBetween) { |
---|
15 | for(CodeStore childCode: childResults) { |
---|
16 | code.addAll(childCode, 0); |
---|
17 | if(blankBetween) { |
---|
18 | code.addLine(" "); |
---|
19 | } |
---|
20 | } |
---|
21 | return code; |
---|
22 | } |
---|
23 | |
---|
24 | public static String makeDelimitedList(Iterator<CodeStore> iter, String delimeter) { |
---|
25 | StringBuilder resultVar = new StringBuilder(); |
---|
26 | while (iter.hasNext()) { |
---|
27 | resultVar.append(iter.next().getResultVarName()); |
---|
28 | if (iter.hasNext()) { |
---|
29 | resultVar.append(delimeter); |
---|
30 | } |
---|
31 | } |
---|
32 | return resultVar.toString(); |
---|
33 | } |
---|
34 | |
---|
35 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.