@Override public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) { List<String> childNames = ElementUtils.getAnnotationValueList(String.class, mirror, "value"); NodeChildData foundChild = null; for (String childName : childNames) { foundChild = getNode().findChild(childName); if (foundChild != null) { break; } } TypeMirror baseType = getContext().getTruffleTypes().getNode(); if (foundChild != null) { baseType = foundChild.getOriginalType(); } MethodSpec spec = new MethodSpec(new ParameterSpec("child", baseType)); addDefaultFieldMethodSpec(spec); ParameterSpec childSpec = new ParameterSpec("castedChild", baseType); childSpec.setSignature(true); spec.addRequired(childSpec); return spec; }
node.getCasts().addAll(new CreateCastParser(context, node).parse(members)); node.getShortCircuits().addAll(new ShortCircuitParser(context, node).parse(members));
@Override public CreateCastData create(TemplateMethod method, boolean invalid) { AnnotationMirror mirror = method.getMarkerAnnotation(); List<String> childNames = ElementUtils.getAnnotationValueList(String.class, mirror, "value"); CreateCastData cast = new CreateCastData(method, childNames); AnnotationValue value = ElementUtils.getAnnotationValue(mirror, "value"); TypeMirror type = null; if (childNames == null || childNames.isEmpty()) { cast.addError(value, "No value specified but required."); return cast; } for (String childName : childNames) { NodeChildData child = getNode().findChild(childName); if (child == null) { // error cast.addError(value, "Specified child '%s' not found.", childName); continue; } if (type == null) { type = child.getNodeType(); } else if (!ElementUtils.typeEquals(type, child.getNodeType())) { cast.addError(value, "All child nodes for a cast must have the same node type."); continue; } } return cast; }
node.getCasts().addAll(new CreateCastParser(context, node).parse(members));
@Override public CreateCastData create(TemplateMethod method, boolean invalid) { AnnotationMirror mirror = method.getMarkerAnnotation(); List<String> childNames = ElementUtils.getAnnotationValueList(String.class, mirror, "value"); CreateCastData cast = new CreateCastData(method, childNames); AnnotationValue value = ElementUtils.getAnnotationValue(mirror, "value"); TypeMirror type = null; if (childNames == null || childNames.isEmpty()) { cast.addError(value, "No value specified but required."); return cast; } for (String childName : childNames) { NodeChildData child = getNode().findChild(childName); if (child == null) { // error cast.addError(value, "Specified child '%s' not found.", childName); continue; } if (type == null) { type = child.getNodeType(); } else if (!ElementUtils.typeEquals(type, child.getNodeType())) { cast.addError(value, "All child nodes for a cast must have the same node type."); continue; } } return cast; }
@Override public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) { List<String> childNames = ElementUtils.getAnnotationValueList(String.class, mirror, "value"); NodeChildData foundChild = null; for (String childName : childNames) { foundChild = getNode().findChild(childName); if (foundChild != null) { break; } } TypeMirror baseType = getContext().getTruffleTypes().getNode(); if (foundChild != null) { baseType = foundChild.getOriginalType(); } MethodSpec spec = new MethodSpec(new ParameterSpec("child", baseType)); addDefaultFieldMethodSpec(spec); ParameterSpec childSpec = new ParameterSpec("castedChild", baseType); childSpec.setSignature(true); spec.addRequired(childSpec); return spec; }