summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsefftinge2008-03-05 06:31:39 (EST)
committersefftinge2008-03-05 06:31:39 (EST)
commit7fcc1f51426ca3c974f164f0102571f12a4119de (patch)
tree2b436f9be9444d53c2b4ea67788ce3e916716486
parente01af59c42b0f8a812da1a73d98b68203e906324 (diff)
downloadorg.eclipse.xpand-7fcc1f51426ca3c974f164f0102571f12a4119de.zip
org.eclipse.xpand-7fcc1f51426ca3c974f164f0102571f12a4119de.tar.gz
org.eclipse.xpand-7fcc1f51426ca3c974f164f0102571f12a4119de.tar.bz2
static typesystem (434th draft)
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/AnalyzeContext.java64
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/TypeSystem.java58
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/TypeSystemUtil.java24
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/AbstractTypeSystemImpl.java53
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/CompositeTypeSystemImpl.java85
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclarationsContributor.java32
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclarationsContributorFactory.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/DeclarationsContributorFactory.java)3
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemFacade.java98
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemImpl.java97
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinFunctionsDeclarationsContributor.java80
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinTypesDeclarationsContributor.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java)100
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/java/Java2TypesystemConverter.java26
12 files changed, 515 insertions, 205 deletions
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/AnalyzeContext.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/AnalyzeContext.java
index ad701c3..e19feba 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/AnalyzeContext.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/AnalyzeContext.java
@@ -15,15 +15,7 @@
*/
package org.eclipse.xand3.analyzation;
-import java.util.Map;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.xpand3.Identifier;
-import org.eclipse.xpand3.declaration.AbstractDeclaration;
-import org.eclipse.xpand3.declaration.Extension;
-import org.eclipse.xpand3.expression.AbstractExpression;
import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
-import org.eclipse.xpand3.staticTypesystem.FunctionType;
/**
* @author Sven Efftinge
@@ -31,28 +23,40 @@ import org.eclipse.xpand3.staticTypesystem.FunctionType;
*/
public interface AnalyzeContext {
- String IMPLICIT_VARIABLE = null;
-
- Map<String, ? extends AbstractTypeReference> getLocalVars();
+ public final static String IMPLICIT_VARIABLE = "this";
boolean hasThis();
-
- Object getThis();
-
- AnalyzeContext cloneWithVariable(Identifier eleName,
- AbstractTypeReference object);
-
- AbstractTypeReference getVariable(String varName);
-
- AbstractExpression getExtensionForTypes(String functionName,
- AbstractTypeReference[] paramTypes);
-
- FunctionType getOperationFor(AbstractTypeReference target,
- String functionName, AbstractTypeReference[] withoutFirst);
-
- AbstractExpression getTypeForName(Identifier typeLiteral);
-
- Extension findExtension(String expression,
- EList<AbstractDeclaration> declarations);
-
+ Var getThis();
+ Var getVariable(String varName);
+
+ AnalyzeContext cloneWith(Var var);
+
+
+ public class Var {
+ public Var(AbstractTypeReference value) {
+ this(IMPLICIT_VARIABLE, value);
+ }
+
+ public Var(String name, AbstractTypeReference value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ private final String name;
+ private final AbstractTypeReference value;
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the value
+ */
+ public AbstractTypeReference getValue() {
+ return value;
+ }
+ }
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/TypeSystem.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/TypeSystem.java
new file mode 100644
index 0000000..d035690
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/TypeSystem.java
@@ -0,0 +1,58 @@
+/**
+ * <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;
+
+import java.util.List;
+
+import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
+import org.eclipse.xpand3.staticTypesystem.FunctionType;
+import org.eclipse.xpand3.staticTypesystem.Type;
+import org.eclipse.xpand3.staticTypesystem.WildcardType;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface TypeSystem {
+ String OBJECT = "Object";
+ String VOID = "Void";
+
+ // Collection types
+ String COLLECTION = "Collection";
+ String SET = "Set";
+ String LIST = "List";
+
+ // Datatypes
+ String BOOLEAN = "Boolean";
+ String INTEGER = "Integer";
+ String REAL = "Real";
+ String STRING = "String";
+
+ // reflection layer types
+ String FEATURE = "Feature";
+ String TYPE = "Type";
+ String OPERATION = "Operation";
+ String PROPERTY = "Property";
+ String STATIC_PROPERTY = "StaticProperty";
+
+ WildcardType wildCard(AbstractTypeReference...upperBounds);
+ WildcardType wildCardWithLower(AbstractTypeReference...lowerBounds);
+
+ Type typeForName(String name, AbstractTypeReference...typeArguments);
+
+ FunctionType functionForNameAndParameterTypes(String name, AbstractTypeReference...parameterTypes);
+ FunctionType functionForName(String name, List<AbstractTypeReference> parameterTypes, AbstractTypeReference...typeArguments);
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/TypeSystemUtil.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/TypeSystemUtil.java
new file mode 100644
index 0000000..3bbbcec
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/TypeSystemUtil.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;
+
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class TypeSystemUtil {
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/AbstractTypeSystemImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/AbstractTypeSystemImpl.java
new file mode 100644
index 0000000..c7c3348
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/AbstractTypeSystemImpl.java
@@ -0,0 +1,53 @@
+/**
+ * <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;
+
+import org.eclipse.xand3.analyzation.TypeSystem;
+import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
+import org.eclipse.xpand3.staticTypesystem.StaticTypesystemFactory;
+import org.eclipse.xpand3.staticTypesystem.WildcardType;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public abstract class AbstractTypeSystemImpl implements TypeSystem {
+
+ protected StaticTypesystemFactory FACTORY = StaticTypesystemFactory.eINSTANCE;
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.TypeSystem#wildCardWithLower(org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
+ */
+ public WildcardType wildCardWithLower(AbstractTypeReference... lowerBounds) {
+ WildcardType wildCard = wildCard();
+ for (AbstractTypeReference abstractTypeReference : lowerBounds) {
+ wildCard.getLowerBounds().add(abstractTypeReference);
+ }
+ return wildCard;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.TypeSystem#wildCard(org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
+ */
+ public WildcardType wildCard(AbstractTypeReference... upperBounds) {
+ WildcardType wildCard = FACTORY.createWildcardType();
+ for (AbstractTypeReference abstractTypeReference : upperBounds) {
+ wildCard.getLowerBounds().add(abstractTypeReference);
+ }
+ return wildCard;
+ }
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/CompositeTypeSystemImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/CompositeTypeSystemImpl.java
new file mode 100644
index 0000000..0e1b149
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/CompositeTypeSystemImpl.java
@@ -0,0 +1,85 @@
+/**
+ * <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;
+
+import java.util.List;
+
+import org.eclipse.xand3.analyzation.TypeSystem;
+import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
+import org.eclipse.xpand3.staticTypesystem.FunctionType;
+import org.eclipse.xpand3.staticTypesystem.Type;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class CompositeTypeSystemImpl extends AbstractTypeSystemImpl implements TypeSystem {
+ private List<? extends TypeSystem> delegates = null;
+
+ public CompositeTypeSystemImpl(List<? extends TypeSystem> delegates) {
+ this.delegates = delegates;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xand3.analyzation.TypeSystem#functionForName(java.lang.String,
+ * java.util.List,
+ * org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
+ */
+ public FunctionType functionForName(String name,
+ List<AbstractTypeReference> parameterTypes,
+ AbstractTypeReference... typeArguments) {
+ for (TypeSystem ts : delegates) {
+ FunctionType functionType = ts.functionForName(name, parameterTypes, typeArguments);
+ if (functionType!=null)
+ return functionType;
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xand3.analyzation.TypeSystem#functionForNameAndParameterTypes(java.lang.String,
+ * org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
+ */
+ public FunctionType functionForNameAndParameterTypes(String name,
+ AbstractTypeReference... parameterTypes) {
+ for (TypeSystem ts : delegates) {
+ FunctionType functionType = ts.functionForNameAndParameterTypes(name, parameterTypes);
+ if (functionType!=null)
+ return functionType;
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xand3.analyzation.TypeSystem#typeForName(java.lang.String,
+ * org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
+ */
+ public Type typeForName(String name, AbstractTypeReference... typeArguments) {
+ for (TypeSystem ts : delegates) {
+ Type type = ts.typeForName(name, typeArguments);
+ if (type!=null)
+ return type;
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclarationsContributor.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclarationsContributor.java
index 516c04b..abd4368 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclarationsContributor.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclarationsContributor.java
@@ -15,8 +15,8 @@
*/
package org.eclipse.xand3.analyzation.typesystem;
-import java.util.Set;
-
+import org.eclipse.xand3.analyzation.TypeSystem;
+import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
import org.eclipse.xpand3.staticTypesystem.DeclaredFunction;
import org.eclipse.xpand3.staticTypesystem.DeclaredType;
@@ -25,6 +25,32 @@ import org.eclipse.xpand3.staticTypesystem.DeclaredType;
*
*/
public interface DeclarationsContributor {
+ /**
+ * used to construct the type system scoped by the imports
+ * @return
+ */
+ String[] getReferencedContributors(); //TODO aliasing
+
+ /**
+ * this method is invoked during setup of this contributor.
+ * @param the type system to be used for resolving type and function references.
+ */
+ void setTypeSystem(TypeSystem ts);
+
+
+ /**
+ * if this contributor has a type with the declared name, the respective DeclareTpye should be returned.
+ * This method is only invoked once per name, so caching is done by the framework
+ * @param name
+ * @return the declared type with the given name or null if there is no such type declared in this Resource.
+ */
DeclaredType typeForName(String name);
- Set<DeclaredFunction> functionsForName(String name);
+
+ /**
+ * if this contributor has a type with the declared name, the respective DeclareTpye should be returned.
+ * This method is only invoked once per name.
+ * @param name
+ * @return
+ */
+ DeclaredFunction functionForName(String name, AbstractTypeReference...parameterTypes);
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/DeclarationsContributorFactory.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclarationsContributorFactory.java
index 2bebedc..d2320b1 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/DeclarationsContributorFactory.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclarationsContributorFactory.java
@@ -13,9 +13,8 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation;
+package org.eclipse.xand3.analyzation.typesystem;
-import org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor;
/**
* @author Sven Efftinge
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
deleted file mode 100644
index 45f9657..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemFacade.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * <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;
-
-import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
-import org.eclipse.xpand3.staticTypesystem.DeclaredFunction;
-import org.eclipse.xpand3.staticTypesystem.DeclaredType;
-import org.eclipse.xpand3.staticTypesystem.FunctionType;
-import org.eclipse.xpand3.staticTypesystem.StaticTypesystemFactory;
-import org.eclipse.xpand3.staticTypesystem.Type;
-import org.eclipse.xpand3.staticTypesystem.WildcardType;
-
-/**
- * @author Sven Efftinge
- *
- */
-public final class TypeSystemFacade {
- private TypeSystemFacade(){}
-
- public static TypeSystemFacade create() {
- return new TypeSystemFacade();
- }
-
- private StaticTypesystemFactory FACTORY = StaticTypesystemFactory.eINSTANCE;
- // factory methods for type arguments
- /**
- * creates and returns a simple wild card type argument
- */
- public WildcardType createWildcard() {
- WildcardType wildcardType = FACTORY.createWildcardType();
- return wildcardType;
- }
-
- /**
- * creates and returns a wild card type argument with the passed lower bound as well as upper bounds
- */
- public WildcardType createWildcardWithLower(AbstractTypeReference... lowerBounds) {
- WildcardType wildCard = createWildcard();
- for (AbstractTypeReference abstractTypeReference : lowerBounds) {
- wildCard.getLowerBounds().add(abstractTypeReference);
- }
- return wildCard;
- }
-
- /**
- * creates and returns a wild card type argument with the passed upper bounds
- */
- public WildcardType createWildcardWithUpper(Type... upperBounds){
- WildcardType wildCard = createWildcard();
- for (AbstractTypeReference abstractTypeReference : upperBounds) {
- wildCard.getLowerBounds().add(abstractTypeReference);
- }
- return wildCard;
- }
-
- /**
- * creates a type for a declared type and the needed arguments
- * @param type - the type to be instantiated
- * @param args
- * @return
- */
- public Type typeReference(DeclaredType dt, AbstractTypeReference... args) {
- Type type = FACTORY.createType();
- type.setDeclaredType(dt);
- for (AbstractTypeReference ref : args) {
- type.getActualTypeArguments().add(ref);
- }
- return type;
- }
-
- /**
- * @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
- */
- public FunctionType functionType(DeclaredFunction func, AbstractTypeReference... args){
- FunctionType funcType = FACTORY.createFunctionType();
- funcType.setDeclaredFunction(func);
- for (AbstractTypeReference ref : args) {
- funcType.getActualTypeArguments().add(ref);
- }
- return funcType;
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemImpl.java
new file mode 100644
index 0000000..f216ff0
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemImpl.java
@@ -0,0 +1,97 @@
+/**
+ * <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;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.xand3.analyzation.TypeSystem;
+import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
+import org.eclipse.xpand3.staticTypesystem.DeclaredFunction;
+import org.eclipse.xpand3.staticTypesystem.DeclaredType;
+import org.eclipse.xpand3.staticTypesystem.FunctionType;
+import org.eclipse.xpand3.staticTypesystem.Type;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class TypeSystemImpl extends AbstractTypeSystemImpl implements TypeSystem {
+
+
+ private DeclarationsContributor contr = null;
+
+ /**
+ *
+ */
+ public TypeSystemImpl(DeclarationsContributor contributor) {
+ if (contributor==null)
+ throw new NullPointerException("contributor was null");
+ this.contr = contributor;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xand3.analyzation.TypeSystem#typeForName(java.lang.String,
+ * org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
+ */
+ public Type typeForName(String name, AbstractTypeReference... typeArguments) {
+ DeclaredType dt = contr.typeForName(name);
+ if (dt == null) {
+ //TODO CACHING
+ Type t = FACTORY.createType();
+ t.setDeclaredType(dt);
+ t.getActualTypeArguments().addAll(Arrays.asList(typeArguments));
+ return t;
+ }
+ return null;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xand3.analyzation.TypeSystem#functionForName(java.lang.String,
+ * java.util.List,
+ * org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
+ */
+ public FunctionType functionForName(String name,
+ List<AbstractTypeReference> parameterTypes,
+ AbstractTypeReference... typeArguments) {
+ DeclaredFunction func = contr.functionForName(name, parameterTypes.toArray(new AbstractTypeReference[parameterTypes.size()]));
+ if (func == null) {
+ //TODO CACHING
+ FunctionType funcType = FACTORY.createFunctionType();
+ funcType.setDeclaredFunction(func);
+ funcType.getActualTypeArguments().addAll(Arrays.asList(typeArguments));
+ return funcType;
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xand3.analyzation.TypeSystem#functionForNameAndParameterTypes(java.lang.String,
+ * org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
+ */
+ public FunctionType functionForNameAndParameterTypes(String name,
+ AbstractTypeReference... parameterTypes) {
+ return functionForName(name, Arrays.asList(parameterTypes));
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinFunctionsDeclarationsContributor.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinFunctionsDeclarationsContributor.java
new file mode 100644
index 0000000..b34c26f
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinFunctionsDeclarationsContributor.java
@@ -0,0 +1,80 @@
+/**
+ * <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.builtin;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.xand3.analyzation.TypeSystem;
+import org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor;
+import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
+import org.eclipse.xpand3.staticTypesystem.DeclaredFunction;
+import org.eclipse.xpand3.staticTypesystem.DeclaredType;
+import org.eclipse.xpand3.staticTypesystem.StaticTypesystemFactory;
+import org.eclipse.xtend.backend.common.NamedFunction;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class BuiltinFunctionsDeclarationsContributor implements DeclarationsContributor {
+
+ private Map<String, DeclaredFunction> functions = new HashMap<String, DeclaredFunction>();
+ private TypeSystem typeSystem;
+
+ private DeclaredFunction createDeclaredFunction(NamedFunction backendFunction) {
+ if (functions.containsKey(backendFunction.getName())) {
+ return functions.get(backendFunction.getName());
+ }
+ DeclaredFunction df = StaticTypesystemFactory.eINSTANCE
+ .createDeclaredFunction();
+ functions.put(backendFunction.getName(), df);
+ df.setName(backendFunction.getName());
+// df.setReturnType(typeSystem.typeForName(OBJECT, typeArguments))
+ return df;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor#functionForName(java.lang.String, org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
+ */
+ public DeclaredFunction functionForName(String name,
+ AbstractTypeReference... parameterTypes) {
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor#typeForName(java.lang.String)
+ */
+ public DeclaredType typeForName(String name) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.Xpand3DeclarationsResource#getReferencedResources()
+ */
+ public String[] getReferencedContributors() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.Xpand3DeclarationsResource#setTypeSystem(org.eclipse.xand3.analyzation.TypeSystem)
+ */
+ public void setTypeSystem(TypeSystem ts) {
+ this.typeSystem = ts;
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinTypesDeclarationsContributor.java
index 0f025d7..2cc8f30 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinTypesDeclarationsContributor.java
@@ -17,22 +17,17 @@ package org.eclipse.xand3.analyzation.typesystem.builtin;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import java.util.Map.Entry;
+import org.eclipse.xand3.analyzation.TypeSystem;
import org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor;
-import org.eclipse.xand3.analyzation.typesystem.TypeSystemFacade;
-import org.eclipse.xpand3.declaration.DeclarationFactory;
import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
import org.eclipse.xpand3.staticTypesystem.DeclaredFunction;
import org.eclipse.xpand3.staticTypesystem.DeclaredProperty;
import org.eclipse.xpand3.staticTypesystem.DeclaredStaticProperty;
import org.eclipse.xpand3.staticTypesystem.DeclaredType;
import org.eclipse.xpand3.staticTypesystem.StaticTypesystemFactory;
-import org.eclipse.xtend.backend.BackendFacade;
import org.eclipse.xtend.backend.common.BackendType;
-import org.eclipse.xtend.backend.common.Function;
-import org.eclipse.xtend.backend.common.NamedFunction;
import org.eclipse.xtend.backend.common.Property;
import org.eclipse.xtend.backend.common.StaticProperty;
import org.eclipse.xtend.backend.types.builtin.BooleanType;
@@ -48,27 +43,31 @@ import org.eclipse.xtend.backend.types.builtin.StaticPropertyType;
import org.eclipse.xtend.backend.types.builtin.StringType;
import org.eclipse.xtend.backend.types.builtin.TypeType;
+import static org.eclipse.xand3.analyzation.TypeSystem.*;
+
/**
* @author Sven Efftinge
*
*/
-public class BuiltinDeclarationsContributor implements DeclarationsContributor {
+public class BuiltinTypesDeclarationsContributor implements DeclarationsContributor {
private Map<String, DeclaredType> types = new HashMap<String, DeclaredType>();
- private Map<String, DeclaredFunction> functions = new HashMap<String, DeclaredFunction>();
-
- private TypeSystemFacade facade = TypeSystemFacade.create();
+ private TypeSystem typeSystems = null;
- private DeclaredFunction createDeclaredFunction(NamedFunction backendFunction) {
- if (functions.containsKey(backendFunction.getName())) {
- return functions.get(backendFunction.getName());
- }
- DeclaredFunction df = StaticTypesystemFactory.eINSTANCE
- .createDeclaredFunction();
- functions.put(backendFunction.getName(), df);
- df.setName(backendFunction.getName());
- return df;
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.Xpand3DeclarationsResource#setTypeSystem(org.eclipse.xand3.analyzation.TypeSystem)
+ */
+ public void setTypeSystem(TypeSystem ts) {
+ this.typeSystems = ts;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.Xpand3DeclarationsResource#getReferencedResources()
+ */
+ public String[] getReferencedContributors() {
+ return null;
}
/**
* @param instance
@@ -87,9 +86,6 @@ public class BuiltinDeclarationsContributor implements DeclarationsContributor {
for (Entry<String, ? extends Property> entry : properties.entrySet()) {
dt.getProperties().add(createDeclaredProperty(entry.getValue()));
}
- // for (NamedFunction func: bt.getBuiltinOperations()) {
- // dt.getProperties().add(createDeclaredOperation(func));
- // }
for (StaticProperty sp : bt.getStaticProperties().values()) {
dt.getStaticProperties().add(createDeclaredStaticProperty(sp));
}
@@ -102,7 +98,10 @@ public class BuiltinDeclarationsContributor implements DeclarationsContributor {
*/
private DeclaredStaticProperty createDeclaredStaticProperty(
StaticProperty sp) {
- return null;
+ DeclaredStaticProperty dsp = StaticTypesystemFactory.eINSTANCE.createDeclaredStaticProperty();
+ dsp.setName(sp.getName());
+ dsp.setType(typeSystems.typeForName(sp.getType().getName()));
+ return dsp;
}
/**
@@ -113,25 +112,13 @@ public class BuiltinDeclarationsContributor implements DeclarationsContributor {
DeclaredProperty dp = StaticTypesystemFactory.eINSTANCE
.createDeclaredProperty();
dp.setName(value.getName());
- dp
- .setType(facade.typeReference(typeForName(value.getType()
- .getName())));
+ dp.setType(typeSystems.typeForName(value.getType().getName()));
return dp;
}
/*
* (non-Javadoc)
*
- * @see org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor#functionsForName(java.lang.String)
- */
- public Set<DeclaredFunction> functionsForName(String name) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
* @see org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor#typeForName(java.lang.String)
*/
public DeclaredType typeForName(String name) {
@@ -159,47 +146,16 @@ public class BuiltinDeclarationsContributor implements DeclarationsContributor {
createDeclaredType(FunctionType.INSTANCE);
} else if (name.equals(STATIC_PROPERTY)) {
createDeclaredType(StaticPropertyType.INSTANCE);
- } else if (name.equals(VOID)) {
- createVoidType();
}
return null;
}
- /**
- *
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor#functionForName(java.lang.String, org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
*/
- private void createVoidType() {
-
+ public DeclaredFunction functionForName(String name,
+ AbstractTypeReference... parameterTypes) {
+ return null;
}
- public static final String OBJECT = "Object";
-
- // Datatypes
- public final static String STRING = "String";
-
- public final static String BOOLEAN = "Boolean";
-
- public final static String INTEGER = "Integer";
-
- public final static String REAL = "Real";
-
- // Collection types
- public final static String COLLECTION = "Collection";
-
- public final static String SET = "Set";
-
- public final static String LIST = "List";
-
- // reflection layer types
- public static final String TYPE = "Type";
-
- public static final String FEATURE = "Feature";
-
- public static final String PROPERTY = "Property";
-
- public static final String OPERATION = "Operation";
-
- public static final String STATIC_PROPERTY = "StaticProperty";
-
- public static final String VOID = "Void";
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/java/Java2TypesystemConverter.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/java/Java2TypesystemConverter.java
new file mode 100644
index 0000000..03c858f
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/java/Java2TypesystemConverter.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.java;
+
+import org.eclipse.xpand3.staticTypesystem.DeclaredType;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class Java2TypesystemConverter {
+
+}