summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsefftinge2008-03-11 03:11:17 (EDT)
committersefftinge2008-03-11 03:11:17 (EDT)
commit5b33b350710dd272953bb0839b99fc1437ae8734 (patch)
treedff1850ca5d36a687179509e3e9756afb631a88a
parente90f8a9dcd53e3449a220699792b569f96208182 (diff)
downloadorg.eclipse.xpand-5b33b350710dd272953bb0839b99fc1437ae8734.zip
org.eclipse.xpand-5b33b350710dd272953bb0839b99fc1437ae8734.tar.gz
org.eclipse.xpand-5b33b350710dd272953bb0839b99fc1437ae8734.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.xpand3/src/built-in-lib.xmi4
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/DeclarationsContributor.java8
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/TypeSystemFactory.java24
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/CompositeTypeSystemImpl.java9
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java161
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/builtin/BuiltinTypeSystem.java8
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaDeclarationsContributor.java110
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/ComparableDeclaration.java44
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/ComparableTypeReference.java39
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/FunctionSignature.java24
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/TypeList.java24
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/TypeUtil.java36
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/xpand3/Xpand3ResourceDeclarationsContributor.java47
-rw-r--r--plugins/org.eclipse.xpand3/src/static_typesystem.ecore2
-rw-r--r--plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/XtendBackendFacade.java11
-rw-r--r--tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java3
-rw-r--r--tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java3
-rw-r--r--tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java11
-rw-r--r--tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/Node2AstTest.java3
19 files changed, 254 insertions, 317 deletions
diff --git a/plugins/org.eclipse.xpand3/src/built-in-lib.xmi b/plugins/org.eclipse.xpand3/src/built-in-lib.xmi
new file mode 100644
index 0000000..4677aed
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/built-in-lib.xmi
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="ASCII"?>
+<staticTypesystem:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:staticTypesystem="http://www.eclipse.org/m2t/xpand3/staticTypesystem" xsi:schemaLocation="http://www.eclipse.org/m2t/xpand3/staticTypesystem static_typesystem.ecore">
+ <functionDeclarations/>
+</staticTypesystem:Model>
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/DeclarationsContributor.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/DeclarationsContributor.java
index 1622f46..cef4752 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/DeclarationsContributor.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/DeclarationsContributor.java
@@ -24,18 +24,12 @@ 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);
-
+ void setTypeSystemFactory(TypeSystemFactory tsf);
/**
* if this contributor has a type with the declared name, the respective DeclareTpye should be returned.
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/TypeSystemFactory.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/TypeSystemFactory.java
index ae6f97f..f9247bc 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/TypeSystemFactory.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/TypeSystemFactory.java
@@ -18,6 +18,10 @@ package org.eclipse.xpand3.analyzation;
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.xpand3.analyzation.typesystem.TypeSystemImpl;
+import org.eclipse.xpand3.analyzation.typesystem.builtin.BuiltinTypeSystem;
+import org.eclipse.xtend.backend.util.Cache;
+
/**
@@ -27,12 +31,28 @@ import java.util.Set;
public class TypeSystemFactory {
private final static Set<LanguageSpecificDeclarationContributorFactory> factories = new HashSet<LanguageSpecificDeclarationContributorFactory>();
-
public static void registerLanguageSpecificFactory(LanguageSpecificDeclarationContributorFactory factory) {
factories.add(factory);
}
- public static DeclarationsContributor createDeclarationContributor(String namespace) {
+ private final Cache<String, TypeSystem> cache = new Cache<String, TypeSystem>() {
+ @Override
+ protected TypeSystem create(String key) {
+ DeclarationsContributor decl = createDeclarationContributor(key);
+ decl.setTypeSystemFactory(TypeSystemFactory.this);
+ TypeSystem ts = new TypeSystemImpl(decl);
+ return ts;
+ }};
+
+ public TypeSystem getTypeSystem(String resourceName) {
+ return cache.get(resourceName);
+ }
+
+ public TypeSystem getBuiltInTypeSystem() {
+ return BuiltinTypeSystem.BUILTIN_TYPESYSTEM;
+ }
+
+ public DeclarationsContributor createDeclarationContributor(String namespace) {
for (LanguageSpecificDeclarationContributorFactory factory : factories) {
if (factory.canHandle(namespace)) {
return factory.createDeclarationContributor(namespace);
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/CompositeTypeSystemImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/CompositeTypeSystemImpl.java
index b12197c..6e7d017 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/CompositeTypeSystemImpl.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/CompositeTypeSystemImpl.java
@@ -29,10 +29,13 @@ import org.eclipse.xpand3.staticTypesystem.Type;
*
*/
public class CompositeTypeSystemImpl extends AbstractTypeSystemImpl implements TypeSystem {
- private List<? extends TypeSystem> delegates = null;
+ private List<TypeSystem> delegates = null;
- public CompositeTypeSystemImpl(List<? extends TypeSystem> delegates) {
- this.delegates = delegates;
+ public CompositeTypeSystemImpl() {
+ }
+
+ public void addTypeSystem(TypeSystem ts) {
+ this.delegates.add(ts);
}
/*
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java
deleted file mode 100644
index 572d659..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java
+++ /dev/null
@@ -1,161 +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.xpand3.analyzation.typesystem.builtin;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.xpand3.analyzation.DeclarationsContributor;
-import org.eclipse.xpand3.analyzation.TypeSystem;
-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.common.BackendType;
-import org.eclipse.xtend.backend.common.Property;
-import org.eclipse.xtend.backend.common.StaticProperty;
-import org.eclipse.xtend.backend.types.builtin.BooleanType;
-import org.eclipse.xtend.backend.types.builtin.CollectionType;
-import org.eclipse.xtend.backend.types.builtin.DoubleType;
-import org.eclipse.xtend.backend.types.builtin.FunctionType;
-import org.eclipse.xtend.backend.types.builtin.ListType;
-import org.eclipse.xtend.backend.types.builtin.LongType;
-import org.eclipse.xtend.backend.types.builtin.ObjectType;
-import org.eclipse.xtend.backend.types.builtin.PropertyType;
-import org.eclipse.xtend.backend.types.builtin.SetType;
-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.xpand3.analyzation.TypeSystem.*;
-
-/**
- * @author Sven Efftinge
- *
- */
-public class BuiltinDeclarationsContributor implements DeclarationsContributor {
-
- private Map<String, DeclaredType> types = new HashMap<String, DeclaredType>();
-
- private TypeSystem typeSystem = null;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.xand3.analyzation.typesystem.Xpand3DeclarationsResource#setTypeSystem(org.eclipse.xand3.analyzation.TypeSystem)
- */
- public void setTypeSystem(TypeSystem ts) {
- this.typeSystem = ts;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.xand3.analyzation.typesystem.Xpand3DeclarationsResource#getReferencedResources()
- */
- public String[] getReferencedContributors() {
- return null;
- }
- /**
- * @param instance
- * @return
- */
- private DeclaredType createDeclaredType(BackendType bt) {
- if (types.containsKey(bt.getName())) {
- return types.get(bt.getName());
- }
- DeclaredType dt = StaticTypesystemFactory.eINSTANCE
- .createDeclaredType();
- types.put(bt.getName(), dt);
- dt.setName(bt.getName());
- Map<String, ? extends Property> properties = bt.getProperties();
- for (Entry<String, ? extends Property> entry : properties.entrySet()) {
- dt.getProperties().add(createDeclaredProperty(entry.getValue()));
- }
- for (StaticProperty sp : bt.getStaticProperties().values()) {
- dt.getStaticProperties().add(createDeclaredStaticProperty(sp));
- }
- return dt;
- }
-
- /**
- * @param sp
- * @return
- */
- private DeclaredStaticProperty createDeclaredStaticProperty(
- StaticProperty sp) {
- DeclaredStaticProperty dsp = StaticTypesystemFactory.eINSTANCE.createDeclaredStaticProperty();
- dsp.setName(sp.getName());
- dsp.setType(typeSystem.typeForName(sp.getType().getName()));
- return dsp;
- }
-
- /**
- * @param value
- * @return
- */
- private DeclaredProperty createDeclaredProperty(Property value) {
- DeclaredProperty dp = StaticTypesystemFactory.eINSTANCE
- .createDeclaredProperty();
- dp.setName(value.getName());
- dp.setType(typeSystem.typeForName(value.getType().getName()));
- return dp;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor#typeForName(java.lang.String)
- */
- public DeclaredType typeForName(String name) {
- if (name.equals(OBJECT)) {
- createDeclaredType(ObjectType.INSTANCE);
- } else if (name.equals(STRING)) {
- createDeclaredType(StringType.INSTANCE);
- } else if (name.equals(BOOLEAN)) {
- createDeclaredType(BooleanType.INSTANCE);
- } else if (name.equals(INTEGER)) {
- createDeclaredType(LongType.INSTANCE);
- } else if (name.equals(REAL)) {
- createDeclaredType(DoubleType.INSTANCE);
- } else if (name.equals(COLLECTION)) {
- createDeclaredType(CollectionType.INSTANCE);
- } else if (name.equals(LIST)) {
- createDeclaredType(ListType.INSTANCE);
- } else if (name.equals(SET)) {
- createDeclaredType(SetType.INSTANCE);
- } else if (name.equals(TYPE)) {
- createDeclaredType(TypeType.INSTANCE);
- } else if (name.equals(PROPERTY)) {
- createDeclaredType(PropertyType.INSTANCE);
- } else if (name.equals(OPERATION)) {
- createDeclaredType(FunctionType.INSTANCE);
- } else if (name.equals(STATIC_PROPERTY)) {
- createDeclaredType(StaticPropertyType.INSTANCE);
- }
- return null;
- }
-
- /* (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) {
- //TODO
- return null;
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/builtin/BuiltinTypeSystem.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/builtin/BuiltinTypeSystem.java
index 87135d3..3d93977 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/builtin/BuiltinTypeSystem.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/builtin/BuiltinTypeSystem.java
@@ -27,6 +27,7 @@ import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.xpand3.analyzation.DeclarationsContributor;
import org.eclipse.xpand3.analyzation.TypeSystem;
+import org.eclipse.xpand3.analyzation.TypeSystemFactory;
import org.eclipse.xpand3.analyzation.typesystem.TypeSystemImpl;
import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
import org.eclipse.xpand3.staticTypesystem.DeclaredFunction;
@@ -43,6 +44,7 @@ public class BuiltinTypeSystem extends TypeSystemImpl implements TypeSystem {
private static Map<String, DeclaredType> types = new HashMap<String, DeclaredType>();
static {
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
+ @SuppressWarnings("unused")
EFactory factoryInstance = StaticTypesystemPackage.eINSTANCE.getEFactoryInstance();
// TODO use classpath: URI
InputStream resourceAsStream = LoaderFactory.getClassLoader(BuiltinTypeSystem.class).getResourceAsStream("built-in.xmi");
@@ -68,11 +70,7 @@ public class BuiltinTypeSystem extends TypeSystemImpl implements TypeSystem {
return null;
}
- public String[] getReferencedContributors() {
- return null;
- }
-
- public void setTypeSystem(TypeSystem ts) {
+ public void setTypeSystemFactory(TypeSystemFactory ts) {
}
public DeclaredType typeForName(String name) {
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaDeclarationsContributor.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaDeclarationsContributor.java
index 0090cf6..7dbbf91 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaDeclarationsContributor.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaDeclarationsContributor.java
@@ -15,47 +15,16 @@
*/
package org.eclipse.xpand3.analyzation.typesystem.java;
-import static org.eclipse.xpand3.analyzation.TypeSystem.BOOLEAN;
-import static org.eclipse.xpand3.analyzation.TypeSystem.COLLECTION;
-import static org.eclipse.xpand3.analyzation.TypeSystem.INTEGER;
-import static org.eclipse.xpand3.analyzation.TypeSystem.LIST;
-import static org.eclipse.xpand3.analyzation.TypeSystem.OBJECT;
-import static org.eclipse.xpand3.analyzation.TypeSystem.OPERATION;
-import static org.eclipse.xpand3.analyzation.TypeSystem.PROPERTY;
-import static org.eclipse.xpand3.analyzation.TypeSystem.REAL;
-import static org.eclipse.xpand3.analyzation.TypeSystem.SET;
-import static org.eclipse.xpand3.analyzation.TypeSystem.STATIC_PROPERTY;
-import static org.eclipse.xpand3.analyzation.TypeSystem.STRING;
-import static org.eclipse.xpand3.analyzation.TypeSystem.TYPE;
-
import java.util.HashMap;
import java.util.Map;
-import java.util.Map.Entry;
import org.eclipse.xpand3.analyzation.DeclarationsContributor;
import org.eclipse.xpand3.analyzation.TypeSystem;
+import org.eclipse.xpand3.analyzation.TypeSystemFactory;
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.xpand3.util.LoaderFactory;
-import org.eclipse.xtend.backend.common.BackendType;
-import org.eclipse.xtend.backend.common.Property;
-import org.eclipse.xtend.backend.common.StaticProperty;
-import org.eclipse.xtend.backend.types.builtin.BooleanType;
-import org.eclipse.xtend.backend.types.builtin.CollectionType;
-import org.eclipse.xtend.backend.types.builtin.DoubleType;
-import org.eclipse.xtend.backend.types.builtin.FunctionType;
-import org.eclipse.xtend.backend.types.builtin.ListType;
-import org.eclipse.xtend.backend.types.builtin.LongType;
-import org.eclipse.xtend.backend.types.builtin.ObjectType;
-import org.eclipse.xtend.backend.types.builtin.PropertyType;
-import org.eclipse.xtend.backend.types.builtin.SetType;
-import org.eclipse.xtend.backend.types.builtin.StaticPropertyType;
-import org.eclipse.xtend.backend.types.builtin.StringType;
-import org.eclipse.xtend.backend.types.builtin.TypeType;
/**
* @author Sven Efftinge
@@ -65,7 +34,7 @@ public class JavaDeclarationsContributor implements DeclarationsContributor {
private Map<String, DeclaredType> types = new HashMap<String, DeclaredType>();
- private TypeSystem typeSystem = null;
+ private TypeSystemFactory typeSystemFactory = null;
private Class<?> cls;
@@ -83,8 +52,8 @@ public class JavaDeclarationsContributor implements DeclarationsContributor {
* (non-Javadoc)
* @see org.eclipse.xand3.analyzation.typesystem.Xpand3DeclarationsResource#setTypeSystem(org.eclipse.xand3.analyzation.TypeSystem)
*/
- public void setTypeSystem(TypeSystem ts) {
- this.typeSystem = ts;
+ public void setTypeSystemFactory(TypeSystemFactory tsf) {
+ this.typeSystemFactory = tsf;
}
/* (non-Javadoc)
@@ -93,51 +62,6 @@ public class JavaDeclarationsContributor implements DeclarationsContributor {
public String[] getReferencedContributors() {
return null;
}
- /**
- * @param instance
- * @return
- */
- private DeclaredType createDeclaredType(BackendType bt) {
- if (types.containsKey(bt.getName())) {
- return types.get(bt.getName());
- }
- DeclaredType dt = StaticTypesystemFactory.eINSTANCE
- .createDeclaredType();
- types.put(bt.getName(), dt);
- dt.setName(bt.getName());
- Map<String, ? extends Property> properties = bt.getProperties();
- for (Entry<String, ? extends Property> entry : properties.entrySet()) {
- dt.getProperties().add(createDeclaredProperty(entry.getValue()));
- }
- for (StaticProperty sp : bt.getStaticProperties().values()) {
- dt.getStaticProperties().add(createDeclaredStaticProperty(sp));
- }
- return dt;
- }
-
- /**
- * @param sp
- * @return
- */
- private DeclaredStaticProperty createDeclaredStaticProperty(
- StaticProperty sp) {
- DeclaredStaticProperty dsp = StaticTypesystemFactory.eINSTANCE.createDeclaredStaticProperty();
- dsp.setName(sp.getName());
- dsp.setType(typeSystem.typeForName(sp.getType().getName()));
- return dsp;
- }
-
- /**
- * @param value
- * @return
- */
- private DeclaredProperty createDeclaredProperty(Property value) {
- DeclaredProperty dp = StaticTypesystemFactory.eINSTANCE
- .createDeclaredProperty();
- dp.setName(value.getName());
- dp.setType(typeSystem.typeForName(value.getType().getName()));
- return dp;
- }
/*
* (non-Javadoc)
@@ -145,31 +69,6 @@ public class JavaDeclarationsContributor implements DeclarationsContributor {
* @see org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor#typeForName(java.lang.String)
*/
public DeclaredType typeForName(String name) {
- if (name.equals(OBJECT)) {
- createDeclaredType(ObjectType.INSTANCE);
- } else if (name.equals(STRING)) {
- createDeclaredType(StringType.INSTANCE);
- } else if (name.equals(BOOLEAN)) {
- createDeclaredType(BooleanType.INSTANCE);
- } else if (name.equals(INTEGER)) {
- createDeclaredType(LongType.INSTANCE);
- } else if (name.equals(REAL)) {
- createDeclaredType(DoubleType.INSTANCE);
- } else if (name.equals(COLLECTION)) {
- createDeclaredType(CollectionType.INSTANCE);
- } else if (name.equals(LIST)) {
- createDeclaredType(ListType.INSTANCE);
- } else if (name.equals(SET)) {
- createDeclaredType(SetType.INSTANCE);
- } else if (name.equals(TYPE)) {
- createDeclaredType(TypeType.INSTANCE);
- } else if (name.equals(PROPERTY)) {
- createDeclaredType(PropertyType.INSTANCE);
- } else if (name.equals(OPERATION)) {
- createDeclaredType(FunctionType.INSTANCE);
- } else if (name.equals(STATIC_PROPERTY)) {
- createDeclaredType(StaticPropertyType.INSTANCE);
- }
return null;
}
@@ -178,7 +77,6 @@ public class JavaDeclarationsContributor implements DeclarationsContributor {
*/
public DeclaredFunction functionForName(String name,
AbstractTypeReference... parameterTypes) {
- //TODO
return null;
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/ComparableDeclaration.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/ComparableDeclaration.java
new file mode 100644
index 0000000..c8b0989
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/ComparableDeclaration.java
@@ -0,0 +1,44 @@
+/**
+ * <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.xpand3.analyzation.typesystem.util;
+
+import org.eclipse.xpand3.staticTypesystem.DeclaredType;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class ComparableDeclaration implements Comparable<ComparableDeclaration>{
+
+ private DeclaredType internal = null;
+
+ /**
+ * @param internal
+ */
+ public ComparableDeclaration(DeclaredType internal) {
+ super();
+ this.internal = internal;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(ComparableDeclaration o) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/ComparableTypeReference.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/ComparableTypeReference.java
new file mode 100644
index 0000000..f4c30e5
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/ComparableTypeReference.java
@@ -0,0 +1,39 @@
+/**
+ * <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.xpand3.analyzation.typesystem.util;
+
+import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class ComparableTypeReference implements Comparable<ComparableTypeReference> {
+
+ private AbstractTypeReference ref = null;
+
+ public ComparableTypeReference(AbstractTypeReference ref) {
+ this.ref = ref;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(ComparableTypeReference o) {
+ return 0;//new ComparableDeclaration(TypeUtil.getDeclaredType(o.ref));
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/FunctionSignature.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/FunctionSignature.java
new file mode 100644
index 0000000..c350378
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/FunctionSignature.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.xpand3.analyzation.typesystem.util;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class FunctionSignature {
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/TypeList.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/TypeList.java
new file mode 100644
index 0000000..2ed54b2
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/TypeList.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.xpand3.analyzation.typesystem.util;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class TypeList {
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/TypeUtil.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/TypeUtil.java
new file mode 100644
index 0000000..7b812d5
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/TypeUtil.java
@@ -0,0 +1,36 @@
+/**
+ * <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.xpand3.analyzation.typesystem.util;
+
+import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
+import org.eclipse.xpand3.staticTypesystem.DeclaredType;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class TypeUtil {
+
+ /**
+ * @param ref
+ * @return
+ */
+ public static DeclaredType getDeclaredType(AbstractTypeReference ref) {
+
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/xpand3/Xpand3ResourceDeclarationsContributor.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/xpand3/Xpand3ResourceDeclarationsContributor.java
index 34a59e8..3dc3c69 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/xpand3/Xpand3ResourceDeclarationsContributor.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/xpand3/Xpand3ResourceDeclarationsContributor.java
@@ -15,20 +15,21 @@
*/
package org.eclipse.xpand3.analyzation.typesystem.xpand3;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.xpand3.DeclaredParameter;
import org.eclipse.xpand3.File;
import org.eclipse.xpand3.Identifier;
import org.eclipse.xpand3.ImportStatement;
import org.eclipse.xpand3.analyzation.DeclarationsContributor;
import org.eclipse.xpand3.analyzation.TypeSystem;
+import org.eclipse.xpand3.analyzation.TypeSystemFactory;
+import org.eclipse.xpand3.analyzation.typesystem.CompositeTypeSystemImpl;
+import org.eclipse.xpand3.analyzation.typesystem.util.TypeList;
import org.eclipse.xpand3.ast.AstUtil;
import org.eclipse.xpand3.declaration.Definition;
import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
import org.eclipse.xpand3.staticTypesystem.DeclaredFunction;
import org.eclipse.xpand3.staticTypesystem.DeclaredType;
+import org.eclipse.xtend.backend.util.Cache;
/**
* @author Sven Efftinge
*
@@ -37,7 +38,7 @@ public class Xpand3ResourceDeclarationsContributor implements
DeclarationsContributor {
private File file = null;
- private TypeSystem typeSystem;
+ private TypeSystemFactory typeSystemFactory;
/**
* @param file
@@ -46,15 +47,21 @@ public class Xpand3ResourceDeclarationsContributor implements
super();
this.file = file;
}
+
/* (non-Javadoc)
* @see org.eclipse.xand3.analyzation.DeclarationsContributor#functionForName(java.lang.String, org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
*/
public DeclaredFunction functionForName(String name,
AbstractTypeReference... parameterTypes) {
+
return null;
}
+ class FunctionSign {
+ String name;
+ TypeList listOfTypes;
+ }
/**
* @param def
* @return
@@ -74,25 +81,37 @@ public class Xpand3ResourceDeclarationsContributor implements
*/
private AbstractTypeReference getTypeRef(Identifier type) {
//TODO type Args
- return typeSystem.typeForName(AstUtil.toString(type));
+ return getTypeSystem().typeForName(AstUtil.toString(type));
}
- /* (non-Javadoc)
- * @see org.eclipse.xand3.analyzation.DeclarationsContributor#getReferencedContributors()
+ private CompositeTypeSystemImpl ts = null;
+ /**
+ * @return
*/
- public String[] getReferencedContributors() {
- List<String> imports = new ArrayList<String>();
- for (ImportStatement is : file.getImports()) {
- imports.add(AstUtil.toString(is.getImportedId()));
+ private TypeSystem getTypeSystem() {
+ if (ts==null) {
+ ts = new CompositeTypeSystemImpl();
+ ts.addTypeSystem(typeSystemFactory.getTypeSystem(getResourceName()));
+ for (ImportStatement is : file.getImports()) {
+ ts.addTypeSystem(typeSystemFactory.getTypeSystem(is.getImportedId().getValue()));
+ }
+ ts.addTypeSystem(typeSystemFactory.getBuiltInTypeSystem());
}
- return imports.toArray(new String[imports.size()]);
+ return ts;
+ }
+
+ /**
+ * @return
+ */
+ private String getResourceName() {
+ return file.getFileName();
}
/* (non-Javadoc)
* @see org.eclipse.xand3.analyzation.DeclarationsContributor#setTypeSystem(org.eclipse.xand3.analyzation.TypeSystem)
*/
- public void setTypeSystem(TypeSystem ts) {
- this.typeSystem = ts;
+ public void setTypeSystemFactory(TypeSystemFactory ts) {
+ this.typeSystemFactory = ts;
}
/* (non-Javadoc)
diff --git a/plugins/org.eclipse.xpand3/src/static_typesystem.ecore b/plugins/org.eclipse.xpand3/src/static_typesystem.ecore
index db96c79..a1ba7d3 100644
--- a/plugins/org.eclipse.xpand3/src/static_typesystem.ecore
+++ b/plugins/org.eclipse.xpand3/src/static_typesystem.ecore
@@ -68,5 +68,7 @@
<eClassifiers xsi:type="ecore:EClass" name="Model">
<eStructuralFeatures xsi:type="ecore:EReference" name="declarations" upperBound="-1"
eType="#//DeclaredType" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="functionDeclarations" upperBound="-1"
+ eType="#//DeclaredFunction" containment="true"/>
</eClassifiers>
</ecore:EPackage>
diff --git a/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/XtendBackendFacade.java b/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/XtendBackendFacade.java
index c684704..37dfbde 100644
--- a/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/XtendBackendFacade.java
+++ b/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/XtendBackendFacade.java
@@ -16,16 +16,13 @@
package org.eclipse.xtend.middleend.internal.xpand3;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import org.eclipose.xtend.middleend.MiddleEnd;
-import org.eclipose.xtend.middleend.MiddleEndFactory;
import org.eclipse.xpand3.File;
import org.eclipse.xpand3.analyzation.AnalyzeContext;
-import org.eclipse.xpand3.declaration.Extension;
import org.eclipse.xtend.backend.common.BackendTypesystem;
-import org.eclipse.xtend.backend.common.ExpressionBase;
+import org.eclipse.xtend.middleend.MiddleEnd;
+import org.eclipse.xtend.middleend.MiddleEndFactory;
+import org.eclipse.xtend.middleend.plugins.LanguageSpecificMiddleEnd;
/**
* @author Bernd Kolb
@@ -40,7 +37,7 @@ public class XtendBackendFacade {
public XtendBackendFacade(String extensionFile) {
this.extensionFile = extensionFile;
- middleEnd = MiddleEndFactory.create(findBackendTypeSystem(), Collections.EMPTY_MAP);
+ middleEnd = MiddleEndFactory.create(findBackendTypeSystem(), Collections.<LanguageSpecificMiddleEnd>emptyList());
// TODO: To be impl
typeConverter = null;
diff --git a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java
index b5c753f..890c5d2 100644
--- a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java
+++ b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java
@@ -15,7 +15,6 @@ import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.eclipse.tmf.common.node.CompositeNode;
import org.eclipse.tmf.common.node.Node;
-import org.eclipse.tmf.common.node.NodeUtil;
/**
* @author Jan Kšhnlein
@@ -32,7 +31,7 @@ public class StatementParserTest extends AbstractXpand3NodeParserTest {
if (rootNode == null) {
System.out.println("Nothing parsed.");
} else {
- System.out.println(NodeUtil.toString(rootNode));
+ System.out.println(rootNode.toDebugString());
}
return (CompositeNode) rootNode;
}
diff --git a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java
index c22ccfe..b4d7bb7 100644
--- a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java
+++ b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java
@@ -4,7 +4,6 @@ import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.eclipse.tmf.common.node.CompositeNode;
import org.eclipse.tmf.common.node.Node;
-import org.eclipse.tmf.common.node.NodeUtil;
public class Xpand3MigratedNodeParserTest extends AbstractXpand3NodeParserTest {
@@ -193,7 +192,7 @@ public class Xpand3MigratedNodeParserTest extends AbstractXpand3NodeParserTest {
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
Xpand3NodeParser xpand3NodeParser = new Xpand3NodeParser(tokenStream);
Node rootNode = xpand3NodeParser.r_test_expression();
- System.out.println(NodeUtil.toString(rootNode));
+ System.out.println(rootNode.toDebugString());
return (CompositeNode) rootNode;
}
}
diff --git a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java
index 31298e4..f02e481 100644
--- a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java
+++ b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java
@@ -7,7 +7,6 @@ import junit.framework.TestCase;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.eclipse.tmf.common.node.Node;
-import org.eclipse.tmf.common.node.NodeUtil;
public class Xpand3NodeParserTest extends TestCase {
@@ -22,13 +21,13 @@ public class Xpand3NodeParserTest extends TestCase {
+ "import foo; myFunction(String this) : doStuff('holla');"
+ LG + "DEFINE foo FOR Entity" + RG + "bla" + LG + "ENDDEFINE"
+ RG);
- System.out.println(NodeUtil.toString(x));
+ System.out.println(x.toDebugString());
}
public void testFoo() throws Exception {
Node node = parse("import foo; myFunction(String this) : doStuff('holla');");
- System.out.println(NodeUtil.toString(node));
- System.out.println(NodeUtil.serialize(node));
+ System.out.println(node.toDebugString());
+ System.out.println(node.serialize());
}
public void testXpandXtendCheckMixedUp1() throws Exception {
@@ -36,8 +35,8 @@ public class Xpand3NodeParserTest extends TestCase {
+ "import foo; myFunction(String this) : doStuff('holla');"
+ LG + "DEFINE foo FOR Entity" + RG + "bla" + LG + "ENDDEFINE"
+ RG);
- System.out.println(NodeUtil.toString(node));
- System.out.println(NodeUtil.serialize(node));
+ System.out.println(node.toDebugString());
+ System.out.println(node.serialize());
}
//
diff --git a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/Node2AstTest.java b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/Node2AstTest.java
index a627387..3436f4d 100644
--- a/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/Node2AstTest.java
+++ b/tests/org.eclipse.xpand3.parser.tests/src/org/eclipse/xpand3/parser/node2ast/Node2AstTest.java
@@ -8,7 +8,6 @@ import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.tmf.common.node.Node;
-import org.eclipse.tmf.common.node.NodeUtil;
import org.eclipse.tmf.common.treetest.TreetestPackage;
import org.eclipse.xpand3.SyntaxElement;
import org.eclipse.xpand3.parser.Xpand3NodeLexer;
@@ -35,7 +34,7 @@ public class Node2AstTest extends TestCase {
if (rootNode == null) {
System.out.println("Nothing parsed.");
} else {
- System.out.println(NodeUtil.toString(rootNode));
+ System.out.println(rootNode.toDebugString());
}
Node2AstTransformer node2AstTransformer = new Node2AstTransformer();
return node2AstTransformer.doSwitch(rootNode);