comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java @ 18761:a665483c3881

Truffle-DSL: new node layout implementation.
author Christian Humer <christian.humer@gmail.com>
date Mon, 29 Dec 2014 23:38:54 +0100
parents 3912400fc33a
children ae81dd154fb6
comparison
equal deleted inserted replaced
18760:6fa3999631d8 18761:a665483c3881
172 public CodeTreeBuilder startCall(String callSite) { 172 public CodeTreeBuilder startCall(String callSite) {
173 return startCall((CodeTree) null, callSite); 173 return startCall((CodeTree) null, callSite);
174 } 174 }
175 175
176 public CodeTreeBuilder startCall(String receiver, String callSite) { 176 public CodeTreeBuilder startCall(String receiver, String callSite) {
177 return startCall(singleString(receiver), callSite); 177 if (receiver != null) {
178 return startCall(singleString(receiver), callSite);
179 } else {
180 return startCall(callSite);
181 }
178 } 182 }
179 183
180 public CodeTreeBuilder startCall(CodeTree receiver, String callSite) { 184 public CodeTreeBuilder startCall(CodeTree receiver, String callSite) {
181 if (receiver == null) { 185 if (receiver == null) {
182 return startGroup().string(callSite).startParanthesesCommaGroup().endAfter(); 186 return startGroup().string(callSite).startParanthesesCommaGroup().endAfter();
612 public CodeTree getTree() { 616 public CodeTree getTree() {
613 assertRoot(); 617 assertRoot();
614 return root; 618 return root;
615 } 619 }
616 620
617 public CodeTree getRoot() { 621 public CodeTree build() {
618 return root; 622 return root;
619 } 623 }
620 624
621 public CodeTreeBuilder cast(String baseClassName) { 625 public CodeTreeBuilder cast(String baseClassName) {
622 string("(").string(baseClassName).string(") "); 626 string("(").string(baseClassName).string(") ");
627 return this;
628 }
629
630 public CodeTreeBuilder cast(TypeMirror type) {
631 string("(").type(type).string(") ");
623 return this; 632 return this;
624 } 633 }
625 634
626 public CodeTreeBuilder cast(TypeMirror type, CodeTree content) { 635 public CodeTreeBuilder cast(TypeMirror type, CodeTree content) {
627 if (ElementUtils.isVoid(type)) { 636 if (ElementUtils.isVoid(type)) {
733 } 742 }
734 743
735 public CodeTreeBuilder startCatchBlock(TypeMirror exceptionType, String localVarName) { 744 public CodeTreeBuilder startCatchBlock(TypeMirror exceptionType, String localVarName) {
736 clearLast(CodeTreeKind.NEW_LINE); 745 clearLast(CodeTreeKind.NEW_LINE);
737 string(" catch (").type(exceptionType).string(" ").string(localVarName).string(") "); 746 string(" catch (").type(exceptionType).string(" ").string(localVarName).string(") ");
747 return startBlock();
748 }
749
750 public CodeTreeBuilder startCatchBlock(TypeMirror[] exceptionTypes, String localVarName) {
751 clearLast(CodeTreeKind.NEW_LINE);
752 string(" catch (");
753
754 for (int i = 0; i < exceptionTypes.length; i++) {
755 if (i != 0) {
756 string(" | ");
757 }
758 type(exceptionTypes[i]);
759 }
760
761 string(" ").string(localVarName).string(") ");
738 return startBlock(); 762 return startBlock();
739 } 763 }
740 764
741 public CodeTreeBuilder startFinallyBlock() { 765 public CodeTreeBuilder startFinallyBlock() {
742 clearLast(CodeTreeKind.NEW_LINE); 766 clearLast(CodeTreeKind.NEW_LINE);