# HG changeset patch # User Christian Humer # Date 1407765185 -7200 # Node ID 0cd0bdedd4ad752b8884d9540c44e974ef7f611c # Parent 5148aab962af0d001c1d68a61ed8b7d42fef7e34 Truffle-DSL: removed old writable AST API. diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/ExtensionContext.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/ExtensionContext.java Mon Aug 11 15:53:05 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.dsl.processor.api; - -import javax.annotation.processing.*; - -import com.oracle.truffle.dsl.processor.api.element.*; - -public interface ExtensionContext { - - ProcessingEnvironment getProcessingEnvironment(); - - RoundEnvironment getRoundEnvironment(); - - WritableElementFactory getElementFactory(); - - void addGeneratedElement(WritableElement element); - - void removeGeneratedElement(WritableElement element); - -} diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableAnnotationMirror.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableAnnotationMirror.java Mon Aug 11 15:53:05 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.dsl.processor.api.element; - -import javax.lang.model.element.*; - -public interface WritableAnnotationMirror extends AnnotationMirror { - - void setElementValue(ExecutableElement valueName, AnnotationValue value); - - AnnotationValue getElementValue(ExecutableElement valueName); - -} diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableElement.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableElement.java Mon Aug 11 15:53:05 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.dsl.processor.api.element; - -import javax.lang.model.element.*; - -public interface WritableElement extends Element { - - void addAnnotationMirror(AnnotationMirror annotationMirror); - - void removeAnnotationMirror(AnnotationMirror annotationMirror); - -} diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableElementFactory.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableElementFactory.java Mon Aug 11 15:53:05 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.dsl.processor.api.element; - -import javax.lang.model.element.*; -import javax.lang.model.type.*; - -public interface WritableElementFactory { - - WritableExecutableElement cloneExecutableElement(ExecutableElement method); - - WritableVariableElement cloneVariableElement(VariableElement parameter); - - WritableAnnotationMirror cloneAnnotationMirror(AnnotationMirror mirror); - - WritableVariableElement createParameter(TypeMirror type, String simpleName); - - WritableExecutableElement createExecutableElement(TypeMirror returnType, String methodName); - - WritableAnnotationMirror createAnnotationMirror(DeclaredType annotationClass); - - Name createName(String name); - - AnnotationValue createAnnotationValue(Object value); - - TypeMirror createTypeMirror(Class javaClass); - -} diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableExecutableElement.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableExecutableElement.java Mon Aug 11 15:53:05 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.dsl.processor.api.element; - -import javax.lang.model.element.*; -import javax.lang.model.type.*; - -public interface WritableExecutableElement extends ExecutableElement, WritableElement { - - void setReturnType(TypeMirror type); - - void setDefaultValue(AnnotationValue defaultValue); - - void addParameter(VariableElement parameter); - - void removeParameter(VariableElement parameter); - - void addThrownType(TypeMirror thrownType); - - void removeThrownType(TypeMirror thrownType); - - void setSimpleName(Name name); - - void setVarArgs(boolean varargs); - - void setBody(String body); - - String getBody(); -} diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableVariableElement.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableVariableElement.java Mon Aug 11 15:53:05 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.dsl.processor.api.element; - -import javax.lang.model.element.*; -import javax.lang.model.type.*; - -public interface WritableVariableElement extends VariableElement, WritableElement { - - void setSimpleName(Name name); - - void setType(TypeMirror type); - -} diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeAnnotationMirror.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeAnnotationMirror.java Mon Aug 11 15:53:05 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeAnnotationMirror.java Mon Aug 11 15:53:05 2014 +0200 @@ -28,9 +28,8 @@ import javax.lang.model.type.*; import com.oracle.truffle.dsl.processor.*; -import com.oracle.truffle.dsl.processor.api.element.*; -public class CodeAnnotationMirror implements WritableAnnotationMirror { +public class CodeAnnotationMirror implements AnnotationMirror { private final DeclaredType annotationType; private final Map values = new LinkedHashMap<>(); @@ -49,12 +48,10 @@ return values; } - @Override public AnnotationValue getElementValue(ExecutableElement method) { return values.get(method); } - @Override public void setElementValue(ExecutableElement method, AnnotationValue value) { values.put(method, value); } @@ -63,12 +60,4 @@ return Utils.findExecutableElement(annotationType, name); } - public static CodeAnnotationMirror clone(AnnotationMirror mirror) { - CodeAnnotationMirror copy = new CodeAnnotationMirror(mirror.getAnnotationType()); - for (ExecutableElement key : mirror.getElementValues().keySet()) { - copy.setElementValue(key, mirror.getElementValues().get(key)); - } - return copy; - } - } diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeElement.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeElement.java Mon Aug 11 15:53:05 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeElement.java Mon Aug 11 15:53:05 2014 +0200 @@ -28,10 +28,9 @@ import javax.lang.model.element.*; -import com.oracle.truffle.dsl.processor.api.element.*; import com.oracle.truffle.dsl.processor.codewriter.*; -public abstract class CodeElement implements WritableElement, GeneratedElement { +public abstract class CodeElement implements Element, GeneratedElement { private final Set modifiers; private List annotations; @@ -46,6 +45,10 @@ this.modifiers = new LinkedHashSet<>(); } + public CodeElement(Set modifiers) { + this.modifiers = new LinkedHashSet<>(modifiers); + } + @Override public void setGeneratorAnnotationMirror(AnnotationMirror mirror) { this.generatorAnnotationMirror = mirror; @@ -66,10 +69,6 @@ return generatorElement; } - public CodeElement(Set modifiers) { - this.modifiers = new LinkedHashSet<>(modifiers); - } - public E add(E element) { if (element == null) { throw new NullPointerException(); @@ -137,7 +136,6 @@ throw new UnsupportedOperationException(); } - @Override public void addAnnotationMirror(AnnotationMirror annotationMirror) { getAnnotationMirrors().add(annotationMirror); } diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeExecutableElement.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeExecutableElement.java Mon Aug 11 15:53:05 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeExecutableElement.java Mon Aug 11 15:53:05 2014 +0200 @@ -29,9 +29,8 @@ import javax.lang.model.type.*; import com.oracle.truffle.dsl.processor.*; -import com.oracle.truffle.dsl.processor.api.element.*; -public class CodeExecutableElement extends CodeElement implements WritableExecutableElement { +public class CodeExecutableElement extends CodeElement implements ExecutableElement { private final List throwables = new ArrayList<>(); private final List parameters = parentableList(this, new ArrayList()); @@ -88,7 +87,6 @@ return Collections.emptyList(); } - @Override public void setVarArgs(boolean varargs) { this.varArgs = varargs; } @@ -98,7 +96,6 @@ return varArgs; } - @Override public void setDefaultValue(AnnotationValue defaultValue) { this.defaultValue = defaultValue; } @@ -151,55 +148,34 @@ return types; } - @Override public void setReturnType(TypeMirror type) { returnType = type; } - @Override public void addParameter(VariableElement parameter) { parameters.add(parameter); } - @Override public void removeParameter(VariableElement parameter) { parameters.remove(parameter); } - public void removeParameter(String varName) { - VariableElement remove = null; - for (VariableElement var : getParameters()) { - if (var.getSimpleName().toString().equals(varName)) { - remove = var; - break; - } - } - if (remove != null) { - parameters.remove(remove); - } - } - - @Override public void addThrownType(TypeMirror thrownType) { throwables.add(thrownType); } - @Override public void removeThrownType(TypeMirror thrownType) { throwables.remove(thrownType); } - @Override public void setSimpleName(Name name) { this.name = name; } - @Override public void setBody(String body) { this.body = body; } - @Override public String getBody() { return body; } diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeTree.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeTree.java Mon Aug 11 15:53:05 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeTree.java Mon Aug 11 15:53:05 2014 +0200 @@ -32,7 +32,7 @@ private TypeMirror type; private final String string; - public CodeTree(CodeTreeKind kind, TypeMirror type, String string) { + CodeTree(CodeTreeKind kind, TypeMirror type, String string) { this.kind = kind; this.type = type; this.string = string; diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeTypeElement.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeTypeElement.java Mon Aug 11 15:53:05 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeTypeElement.java Mon Aug 11 15:53:05 2014 +0200 @@ -111,15 +111,6 @@ return super.getEnclosingElement() instanceof CodeCompilationUnit; } - public CodeVariableElement getField(String name) { - for (VariableElement field : ElementFilter.fieldsIn(getEnclosedElements())) { - if (field.getSimpleName().toString().equals(name)) { - return (CodeVariableElement) field; - } - } - return null; - } - private Name createQualifiedName() { TypeElement enclosingType = getEnclosingClass(); if (enclosingType == null) { diff -r 5148aab962af -r 0cd0bdedd4ad graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeVariableElement.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeVariableElement.java Mon Aug 11 15:53:05 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeVariableElement.java Mon Aug 11 15:53:05 2014 +0200 @@ -28,9 +28,8 @@ import javax.lang.model.type.*; import com.oracle.truffle.dsl.processor.*; -import com.oracle.truffle.dsl.processor.api.element.*; -public final class CodeVariableElement extends CodeElement implements WritableVariableElement { +public final class CodeVariableElement extends CodeElement implements VariableElement { private Name name; private TypeMirror type; @@ -109,7 +108,6 @@ return getSimpleName().toString(); } - @Override public void setSimpleName(Name name) { this.name = name; } @@ -118,7 +116,6 @@ this.name = CodeNames.of(name); } - @Override public void setType(TypeMirror type) { this.type = type; }