changeset 16757:0cd0bdedd4ad

Truffle-DSL: removed old writable AST API.
author Christian Humer <christian.humer@gmail.com>
date Mon, 11 Aug 2014 15:53:05 +0200
parents 5148aab962af
children c5f8eeb3cbc8
files graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/ExtensionContext.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableAnnotationMirror.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableElement.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableElementFactory.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableExecutableElement.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/api/element/WritableVariableElement.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeAnnotationMirror.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeElement.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeExecutableElement.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeTree.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeTypeElement.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeVariableElement.java
diffstat 12 files changed, 9 insertions(+), 296 deletions(-) [+]
line wrap: on
line diff
--- 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);
-
-}
--- 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);
-
-}
--- 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);
-
-}
--- 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);
-
-}
--- 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();
-}
--- 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);
-
-}
--- 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<ExecutableElement, AnnotationValue> 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;
-    }
-
 }
--- 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<E extends Element> implements WritableElement, GeneratedElement {
+public abstract class CodeElement<E extends Element> implements Element, GeneratedElement {
 
     private final Set<Modifier> modifiers;
     private List<AnnotationMirror> annotations;
@@ -46,6 +45,10 @@
         this.modifiers = new LinkedHashSet<>();
     }
 
+    public CodeElement(Set<Modifier> modifiers) {
+        this.modifiers = new LinkedHashSet<>(modifiers);
+    }
+
     @Override
     public void setGeneratorAnnotationMirror(AnnotationMirror mirror) {
         this.generatorAnnotationMirror = mirror;
@@ -66,10 +69,6 @@
         return generatorElement;
     }
 
-    public CodeElement(Set<Modifier> 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);
     }
--- 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<Element> implements WritableExecutableElement {
+public class CodeExecutableElement extends CodeElement<Element> implements ExecutableElement {
 
     private final List<TypeMirror> throwables = new ArrayList<>();
     private final List<VariableElement> parameters = parentableList(this, new ArrayList<VariableElement>());
@@ -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;
     }
--- 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;
--- 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) {
--- 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<Element> implements WritableVariableElement {
+public final class CodeVariableElement extends CodeElement<Element> 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;
     }