Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsefftinge2008-03-03 13:52:21 +0000
committersefftinge2008-03-03 13:52:21 +0000
commitcf0aa0c7e66c02e8ba262ad0f0d14ee9e4f6c904 (patch)
tree2aa58bb6d4b66c2ab22c8b0b2ad0a82c70a0c931
parent6fb0219c6f92721ba5668cfdef9aabb92a5cf421 (diff)
downloadorg.eclipse.xpand-cf0aa0c7e66c02e8ba262ad0f0d14ee9e4f6c904.tar.gz
org.eclipse.xpand-cf0aa0c7e66c02e8ba262ad0f0d14ee9e4f6c904.tar.xz
org.eclipse.xpand-cf0aa0c7e66c02e8ba262ad0f0d14ee9e4f6c904.zip
static typesystem (second draft)
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/AbstractNamed.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/NamedElement.java)2
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFeature.java27
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFunction.java26
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredOperation.java25
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredProperty.java24
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredStaticProperty.java24
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredType.java14
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredTypeParameter.java8
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Feature.java7
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Function.java25
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Operation.java5
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Property.java4
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Type.java7
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeMirror.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeArgument.java)7
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemFacade.java79
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeVariable.java24
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/VoidType.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/ConcreteTypeArgument.java)3
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/WildcardType.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/WildcardTypeArgument.java)8
18 files changed, 298 insertions, 21 deletions
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/NamedElement.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/AbstractNamed.java
index 0c780077..66ffd869 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/NamedElement.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/AbstractNamed.java
@@ -19,6 +19,6 @@ package org.eclipse.xand3.analyzation.typesystem;
* @author Sven Efftinge
*
*/
-public interface NamedElement {
+public interface AbstractNamed {
String getName();
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFeature.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFeature.java
new file mode 100644
index 00000000..d7d35908
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFeature.java
@@ -0,0 +1,27 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2007 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.xand3.analyzation.typesystem;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface DeclaredFeature extends AbstractNamed {
+ /**
+ * @return the declaring type
+ */
+ DeclaredType getDeclaringType();
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFunction.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFunction.java
new file mode 100644
index 00000000..f03b8dbe
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFunction.java
@@ -0,0 +1,26 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2007 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.xand3.analyzation.typesystem;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface DeclaredFunction extends AbstractNamed {
+ DeclaredTypeParameter[] getTypeParameters();
+ TypeMirror getReturnType();
+ TypeMirror[] getParameterTypes();
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredOperation.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredOperation.java
new file mode 100644
index 00000000..953d26d7
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredOperation.java
@@ -0,0 +1,25 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2007 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.xand3.analyzation.typesystem;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface DeclaredOperation extends DeclaredFeature {
+ TypeMirror getReturnType();
+ TypeMirror[] getParameterTypes();
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredProperty.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredProperty.java
new file mode 100644
index 00000000..c4372b63
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredProperty.java
@@ -0,0 +1,24 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2007 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.xand3.analyzation.typesystem;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface DeclaredProperty extends DeclaredFeature {
+ TypeMirror getPropertyType();
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredStaticProperty.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredStaticProperty.java
new file mode 100644
index 00000000..e9a45cbc
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredStaticProperty.java
@@ -0,0 +1,24 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2007 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.xand3.analyzation.typesystem;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface DeclaredStaticProperty extends DeclaredFeature {
+ Type getPropertyType();
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredType.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredType.java
index 41d7ae1d..28d52afb 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredType.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredType.java
@@ -15,8 +15,16 @@
*/
package org.eclipse.xand3.analyzation.typesystem;
-public interface DeclaredType extends NamedElement {
- DeclaredType[] getSuperTypes();
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface DeclaredType {
+ Type[] getSuperTypes();
+
+ DeclaredFeature[] getDeclaredFeatures();
+ DeclaredProperty[] getDeclaredProperties();
+ DeclaredOperation[] getDeclaredOperations();
+
DeclaredTypeParameter[] getTypeParameters();
- Type createInstance(TypeArgument... args);
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredTypeParameter.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredTypeParameter.java
index eefa9508..e2d3af18 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredTypeParameter.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredTypeParameter.java
@@ -15,6 +15,10 @@
*/
package org.eclipse.xand3.analyzation.typesystem;
-public interface DeclaredTypeParameter extends NamedElement {
- DeclaredType[] getUpperBounds();
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface DeclaredTypeParameter extends AbstractNamed {
+ Type[] getUpperBounds();
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Feature.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Feature.java
index 25e5a0b2..558e7f09 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Feature.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Feature.java
@@ -19,6 +19,9 @@ package org.eclipse.xand3.analyzation.typesystem;
* @author Sven Efftinge
*
*/
-public interface Feature {
-
+public interface Feature extends AbstractNamed {
+ /**
+ * @return the declaring type
+ */
+ Type getDeclaringType();
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Function.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Function.java
new file mode 100644
index 00000000..43b09522
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Function.java
@@ -0,0 +1,25 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2007 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.xand3.analyzation.typesystem;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface Function extends AbstractNamed {
+ TypeMirror getReturnType();
+ TypeMirror[] getParameterTypes();
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Operation.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Operation.java
index 0db349cd..2b415009 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Operation.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Operation.java
@@ -19,6 +19,7 @@ package org.eclipse.xand3.analyzation.typesystem;
* @author Sven Efftinge
*
*/
-public interface Operation {
-
+public interface Operation extends Feature {
+ Type[] getParameterTypes();
+ Type getReturnType();
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Property.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Property.java
index 712e7168..788ff06d 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Property.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Property.java
@@ -19,6 +19,6 @@ package org.eclipse.xand3.analyzation.typesystem;
* @author Sven Efftinge
*
*/
-public interface Property {
-
+public interface Property extends Feature {
+ Type getPropertyType();
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Type.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Type.java
index b4265f30..be59cbc9 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Type.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Type.java
@@ -15,7 +15,7 @@
*/
package org.eclipse.xand3.analyzation.typesystem;
-public interface Type extends NamedElement {
+public interface Type extends AbstractNamed, TypeMirror {
Type[] getSuperTypes();
Feature[] getFeatures();
@@ -23,7 +23,10 @@ public interface Type extends NamedElement {
Operation[] getOperations();
/**
- * @return returns either the {@link DeclaredType} this type is a bound instance of or this, if the originally declared type wasn't unbound
+ * @return returns either the type this type is a bound instance of or just <code>this</code>, if the originally declared type wasn't generic
*/
DeclaredType getDeclaredType();
+
+ TypeMirror[] getActualTypeArguments();
+
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeArgument.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeMirror.java
index 6482eb60..03755e3b 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeArgument.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeMirror.java
@@ -15,5 +15,10 @@
*/
package org.eclipse.xand3.analyzation.typesystem;
-public interface TypeArgument {
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface TypeMirror {
+
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemFacade.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemFacade.java
new file mode 100644
index 00000000..4e4c2737
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemFacade.java
@@ -0,0 +1,79 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2007 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.xand3.analyzation.typesystem;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface TypeSystemFacade {
+ // factory methods for type arguments
+ /**
+ * creates and returns a simple wild card type argument
+ */
+ WildcardType createWildCard();
+
+ /**
+ * creates and returns a wild card type argument with the passed lower bound as well as upper bounds
+ */
+ WildcardType createWildCardWithLowerAndUpper(Type lower,
+ Type... upperBounds);
+
+ /**
+ * creates and returns a wild card type argument with the passed upper bounds
+ */
+ WildcardType createWildCardWithUpper(Type... upperBounds);
+
+ /**
+ * creates and returns a simple type argument, parameterized with a concrete type
+ */
+ WildcardType createSimpleArgument(Type type);
+
+ /**
+ * @param name - a simple name (not parameterized!)
+ * @return the type (maybe unbound) or null if there is no type with the given name
+ */
+ Type typeForName(String name);
+
+ /**
+ * this is like currying for generic types
+ * just pass an unbound type and the compatible type arguments and you'll get a new
+ * (partly) bound instance of that type.
+ * @param type - the type to be instantiated
+ * @param args
+ * @return
+ */
+ Type addArguments(DeclaredType dt, TypeMirror... args);
+
+ /**
+ * @param name - a simple name (not parameterized!)
+ * @param paramTypes - the types of the parameters to be passed
+ * @return the type (maybe unbound) or null if there is no type with the given name
+ */
+ Function functionForNameAndParameterTypes(String name, Type[]... paramTypes);
+
+ /**
+ * this is like currying for generic functions
+ * just pass an unbound functions and the compatible type arguments and you'll get a new
+ * (partly) bound instance of that function.
+ * @param f - the function to be instantiated
+ * @param args - the type arguments
+ * @return
+ */
+ Function addArguments(DeclaredFunction f, TypeMirror... args);
+
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeVariable.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeVariable.java
new file mode 100644
index 00000000..a9239514
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeVariable.java
@@ -0,0 +1,24 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2007 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.xand3.analyzation.typesystem;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface TypeVariable extends TypeMirror {
+ DeclaredTypeParameter getDeclaration();
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/ConcreteTypeArgument.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/VoidType.java
index 07f45aa5..5f0acab1 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/ConcreteTypeArgument.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/VoidType.java
@@ -19,6 +19,5 @@ package org.eclipse.xand3.analyzation.typesystem;
* @author Sven Efftinge
*
*/
-public interface ConcreteTypeArgument extends TypeArgument{
- Type[] getType();
+public interface VoidType extends TypeMirror {
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/WildcardTypeArgument.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/WildcardType.java
index 5afbe821..78abeb2e 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/WildcardTypeArgument.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/WildcardType.java
@@ -19,14 +19,14 @@ package org.eclipse.xand3.analyzation.typesystem;
* @author Sven Efftinge
*
*/
-public interface WildcardTypeArgument extends TypeArgument {
+public interface WildcardType extends TypeMirror {
/**
- * @return the lower bound type (specified using e.g. <* super MyType>)
+ * @return the lower bounds (specified using e.g. <* super MyType>)
*/
- Type getLowerBound();
+ TypeMirror[] getLowerBounds();
/**
* @return the upper bounds (specified using e.g. <* extends Comparable,Serializable>)
*/
- Type[] getUpperBounds();
+ TypeMirror[] getUpperBounds();
}

Back to the top