Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeCodeGenerator.java @ 7859:3c68170fc9b0
Fixed a visibility bug in NodeFactory generation.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 25 Feb 2013 17:00:52 +0100 |
parents | 4958cbdbf360 |
children | 6b74ffe38183 |
comparison
equal
deleted
inserted
replaced
7858:4958cbdbf360 | 7859:3c68170fc9b0 |
---|---|
509 add(new SpecializedNodeFactory(context), specialization); | 509 add(new SpecializedNodeFactory(context), specialization); |
510 } | 510 } |
511 | 511 |
512 TypeMirror nodeFactory = getContext().getEnvironment().getTypeUtils().getDeclaredType(Utils.fromTypeMirror(getContext().getType(NodeFactory.class)), node.getNodeType()); | 512 TypeMirror nodeFactory = getContext().getEnvironment().getTypeUtils().getDeclaredType(Utils.fromTypeMirror(getContext().getType(NodeFactory.class)), node.getNodeType()); |
513 clazz.getImplements().add(nodeFactory); | 513 clazz.getImplements().add(nodeFactory); |
514 clazz.add(createCreateNodeMethod(node, createVisibility)); | 514 clazz.add(createCreateNodeMethod(node)); |
515 clazz.add(createCreateNodeSpecializedMethod(node, createVisibility)); | 515 clazz.add(createCreateNodeSpecializedMethod(node)); |
516 clazz.add(createGetNodeClassMethod(node)); | 516 clazz.add(createGetNodeClassMethod(node)); |
517 clazz.add(createGetNodeSignaturesMethod(node)); | 517 clazz.add(createGetNodeSignaturesMethod(node)); |
518 clazz.add(createGetInstanceMethod(node, createVisibility)); | 518 clazz.add(createGetInstanceMethod(node, createVisibility)); |
519 clazz.add(createInstanceConstant(node, clazz.asType())); | 519 clazz.add(createInstanceConstant(node, clazz.asType())); |
520 } | 520 } |
578 builder.end(); | 578 builder.end(); |
579 builder.end(); | 579 builder.end(); |
580 return method; | 580 return method; |
581 } | 581 } |
582 | 582 |
583 private CodeExecutableElement createCreateNodeMethod(NodeData node, Modifier visibility) { | 583 private CodeExecutableElement createCreateNodeMethod(NodeData node) { |
584 CodeExecutableElement method = new CodeExecutableElement(modifiers(), node.getNodeType(), "createNode"); | 584 CodeExecutableElement method = new CodeExecutableElement(modifiers(PUBLIC), node.getNodeType(), "createNode"); |
585 CodeVariableElement arguments = new CodeVariableElement(getContext().getType(Object.class), "arguments"); | 585 CodeVariableElement arguments = new CodeVariableElement(getContext().getType(Object.class), "arguments"); |
586 method.setVarArgs(true); | 586 method.setVarArgs(true); |
587 method.addParameter(arguments); | 587 method.addParameter(arguments); |
588 | |
589 if (visibility != null) { | |
590 method.getModifiers().add(visibility); | |
591 } | |
592 | 588 |
593 CodeTreeBuilder builder = method.createBuilder(); | 589 CodeTreeBuilder builder = method.createBuilder(); |
594 List<ExecutableElement> signatures = findUserConstructors(node); | 590 List<ExecutableElement> signatures = findUserConstructors(node); |
595 boolean ifStarted = false; | 591 boolean ifStarted = false; |
596 | 592 |
634 builder.end().end(); | 630 builder.end().end(); |
635 builder.end(); // else block | 631 builder.end(); // else block |
636 return method; | 632 return method; |
637 } | 633 } |
638 | 634 |
639 private CodeExecutableElement createCreateNodeSpecializedMethod(NodeData node, Modifier visibility) { | 635 private CodeExecutableElement createCreateNodeSpecializedMethod(NodeData node) { |
640 CodeExecutableElement method = new CodeExecutableElement(modifiers(), node.getNodeType(), "createNodeSpecialized"); | 636 CodeExecutableElement method = new CodeExecutableElement(modifiers(PUBLIC), node.getNodeType(), "createNodeSpecialized"); |
641 CodeVariableElement nodeParam = new CodeVariableElement(node.getNodeType(), "thisNode"); | 637 CodeVariableElement nodeParam = new CodeVariableElement(node.getNodeType(), "thisNode"); |
642 CodeVariableElement arguments = new CodeVariableElement(getContext().getType(Class.class), "types"); | 638 CodeVariableElement arguments = new CodeVariableElement(getContext().getType(Class.class), "types"); |
643 method.addParameter(nodeParam); | 639 method.addParameter(nodeParam); |
644 method.addParameter(arguments); | 640 method.addParameter(arguments); |
645 method.setVarArgs(true); | 641 method.setVarArgs(true); |
646 if (visibility != null) { | |
647 method.getModifiers().add(visibility); | |
648 } | |
649 | 642 |
650 CodeTreeBuilder builder = method.createBuilder(); | 643 CodeTreeBuilder builder = method.createBuilder(); |
651 if (!node.needsRewrites(getContext())) { | 644 if (!node.needsRewrites(getContext())) { |
652 builder.startThrow().startNew(getContext().getType(UnsupportedOperationException.class)).end().end(); | 645 builder.startThrow().startNew(getContext().getType(UnsupportedOperationException.class)).end().end(); |
653 } else { | 646 } else { |