Mercurial > hg > truffle
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeTreeBuilder.java @ 11186:4a9936bb03a4
Truffle-DSL: Fixed executeAndSpecialize layout to always call specialization methods on the correct node. (GRAAL-379 #resolve)
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 30 Jul 2013 16:12:26 +0200 |
parents | 79041ab43660 |
children | 0460c44aef60 |
comparison
equal
deleted
inserted
replaced
11185:5daaa0821406 | 11186:4a9936bb03a4 |
---|---|
297 | 297 |
298 public CodeTreeBuilder startWhile() { | 298 public CodeTreeBuilder startWhile() { |
299 return startGroup().string("while ").startParanthesesCommaGroup().endAndWhitespaceAfter().startGroup().endAfter(); | 299 return startGroup().string("while ").startParanthesesCommaGroup().endAndWhitespaceAfter().startGroup().endAfter(); |
300 } | 300 } |
301 | 301 |
302 public CodeTreeBuilder startDoBlock() { | |
303 return startGroup().string("do ").startBlock(); | |
304 } | |
305 | |
306 public CodeTreeBuilder startDoWhile() { | |
307 clearLast(CodeTreeKind.NEW_LINE); | |
308 return startStatement().string(" while ").startParanthesesCommaGroup().endAfter().startGroup().endAfter(); | |
309 } | |
310 | |
302 public CodeTreeBuilder startIf() { | 311 public CodeTreeBuilder startIf() { |
303 return startGroup().string("if ").startParanthesesCommaGroup().endAndWhitespaceAfter().startGroup().endAfter(); | 312 return startGroup().string("if ").startParanthesesCommaGroup().endAndWhitespaceAfter().startGroup().endAfter(); |
304 } | 313 } |
305 | 314 |
306 public boolean startIf(boolean elseIf) { | 315 public boolean startIf(boolean elseIf) { |
475 } | 484 } |
476 return this; | 485 return this; |
477 } | 486 } |
478 | 487 |
479 public CodeTreeBuilder declaration(TypeMirror type, String name, String init) { | 488 public CodeTreeBuilder declaration(TypeMirror type, String name, String init) { |
489 return declaration(type, name, singleString(init)); | |
490 } | |
491 | |
492 public CodeTreeBuilder declaration(String type, String name, CodeTree init) { | |
493 startStatement(); | |
494 string(type); | |
495 string(" "); | |
496 string(name); | |
497 if (init != null) { | |
498 string(" = "); | |
499 tree(init); | |
500 } | |
501 end(); // statement | |
502 return this; | |
503 } | |
504 | |
505 public CodeTreeBuilder declaration(String type, String name, String init) { | |
480 return declaration(type, name, singleString(init)); | 506 return declaration(type, name, singleString(init)); |
481 } | 507 } |
482 | 508 |
483 public CodeTreeBuilder declaration(TypeMirror type, String name, CodeTree init) { | 509 public CodeTreeBuilder declaration(TypeMirror type, String name, CodeTree init) { |
484 if (Utils.isVoid(type)) { | 510 if (Utils.isVoid(type)) { |
498 } | 524 } |
499 return this; | 525 return this; |
500 } | 526 } |
501 | 527 |
502 public CodeTreeBuilder declaration(TypeMirror type, String name, CodeTreeBuilder init) { | 528 public CodeTreeBuilder declaration(TypeMirror type, String name, CodeTreeBuilder init) { |
529 if (init == this) { | |
530 throw new IllegalArgumentException("Recursive builder usage."); | |
531 } | |
532 return declaration(type, name, init.getTree()); | |
533 } | |
534 | |
535 public CodeTreeBuilder declaration(String type, String name, CodeTreeBuilder init) { | |
503 if (init == this) { | 536 if (init == this) { |
504 throw new IllegalArgumentException("Recursive builder usage."); | 537 throw new IllegalArgumentException("Recursive builder usage."); |
505 } | 538 } |
506 return declaration(type, name, init.getTree()); | 539 return declaration(type, name, init.getTree()); |
507 } | 540 } |