Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeBaseFactory.java @ 18807:4ce856e65728
Truffle-DSL: fix visiblity of create methods.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 09 Jan 2015 16:33:08 +0100 |
parents | c0fb70634640 |
children | d399c7ce78b3 |
comparison
equal
deleted
inserted
replaced
18806:b9cf6f3150ea | 18807:4ce856e65728 |
---|---|
136 | 136 |
137 return clazz; | 137 return clazz; |
138 } | 138 } |
139 | 139 |
140 public static List<ExecutableElement> findUserConstructors(TypeMirror nodeType) { | 140 public static List<ExecutableElement> findUserConstructors(TypeMirror nodeType) { |
141 TypeElement type = ElementUtils.fromTypeMirror(nodeType); | |
141 List<ExecutableElement> constructors = new ArrayList<>(); | 142 List<ExecutableElement> constructors = new ArrayList<>(); |
142 for (ExecutableElement constructor : ElementFilter.constructorsIn(ElementUtils.fromTypeMirror(nodeType).getEnclosedElements())) { | 143 for (ExecutableElement constructor : ElementFilter.constructorsIn(type.getEnclosedElements())) { |
143 if (constructor.getModifiers().contains(PRIVATE)) { | 144 if (constructor.getModifiers().contains(PRIVATE)) { |
144 continue; | 145 continue; |
145 } | 146 } |
146 if (isCopyConstructor(constructor)) { | 147 if (isCopyConstructor(constructor)) { |
147 continue; | 148 continue; |
148 } | 149 } |
149 constructors.add(constructor); | 150 constructors.add(constructor); |
150 } | 151 } |
151 | 152 |
152 if (constructors.isEmpty()) { | 153 if (constructors.isEmpty()) { |
153 constructors.add(new CodeExecutableElement(null, ElementUtils.getSimpleName(nodeType))); | 154 CodeExecutableElement executable = new CodeExecutableElement(null, ElementUtils.getSimpleName(nodeType)); |
155 ElementUtils.setVisibility(executable.getModifiers(), ElementUtils.getVisibility(type.getModifiers())); | |
156 constructors.add(executable); | |
154 } | 157 } |
155 | 158 |
156 return constructors; | 159 return constructors; |
157 } | 160 } |
158 | 161 |
437 } | 440 } |
438 } | 441 } |
439 | 442 |
440 private CodeExecutableElement createUserConstructor(CodeTypeElement type, ExecutableElement superConstructor) { | 443 private CodeExecutableElement createUserConstructor(CodeTypeElement type, ExecutableElement superConstructor) { |
441 CodeExecutableElement method = new CodeExecutableElement(null, type.getSimpleName().toString()); | 444 CodeExecutableElement method = new CodeExecutableElement(null, type.getSimpleName().toString()); |
445 ElementUtils.setVisibility(method.getModifiers(), ElementUtils.getVisibility(superConstructor.getModifiers())); | |
442 CodeTreeBuilder builder = method.createBuilder(); | 446 CodeTreeBuilder builder = method.createBuilder(); |
443 | 447 |
444 if (superConstructor != null) { | 448 if (superConstructor != null) { |
445 for (VariableElement param : superConstructor.getParameters()) { | 449 for (VariableElement param : superConstructor.getParameters()) { |
446 method.getParameters().add(CodeVariableElement.clone(param)); | 450 method.getParameters().add(CodeVariableElement.clone(param)); |
1836 } | 1840 } |
1837 | 1841 |
1838 /** | 1842 /** |
1839 * <pre> | 1843 * <pre> |
1840 * variant1 $condition != null | 1844 * variant1 $condition != null |
1841 * | 1845 * |
1842 * $type $name = defaultValue($type); | 1846 * $type $name = defaultValue($type); |
1843 * if ($condition) { | 1847 * if ($condition) { |
1844 * $name = $value; | 1848 * $name = $value; |
1845 * } | 1849 * } |
1846 * | 1850 * |
1847 * variant2 $condition != null | 1851 * variant2 $condition != null |
1848 * $type $name = $value; | 1852 * $type $name = $value; |
1849 * </pre> | 1853 * </pre> |
1850 * | 1854 * |
1851 * . | 1855 * . |