summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsefftinge2008-03-13 07:41:50 (EDT)
committer sefftinge2008-03-13 07:41:50 (EDT)
commit9111ff462b07b2407fc521b9679e8dd881114fde (patch)
treefbb8bc6e842695c4cf58fed3609a8262c2344a6c
parent50a10c3586af9143f7d7ef4cd4ec66e35fb14614 (diff)
downloadorg.eclipse.xpand-9111ff462b07b2407fc521b9679e8dd881114fde.zip
org.eclipse.xpand-9111ff462b07b2407fc521b9679e8dd881114fde.tar.gz
org.eclipse.xpand-9111ff462b07b2407fc521b9679e8dd881114fde.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.xpand3/META-INF/MANIFEST.MF15
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/ExpressionFactory.java11
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/ExpressionPackage.java134
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/UnaryOperation.java81
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/ExpressionFactoryImpl.java13
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/ExpressionPackageImpl.java46
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/UnaryOperationImpl.java241
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/util/ExpressionAdapterFactory.java20
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/util/ExpressionSwitch.java25
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/validation/UnaryOperationValidator.java24
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/FileStatement.java29
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/ForEachStatement.java24
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/IfStatement.java29
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/StatementPackage.java80
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/FileStatementImpl.java70
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/ForEachStatementImpl.java58
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/IfStatementImpl.java62
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/StatementPackageImpl.java32
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/validation/FileStatementValidator.java4
-rw-r--r--plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/validation/ForEachStatementValidator.java4
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/DeclarationsContributor.java49
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/GenericsUtil.java73
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/LanguageSpecificTypeSystemFactory.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/LanguageSpecificDeclarationContributorFactory.java)4
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/TypeSystem.java36
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/TypeSystemFactory.java32
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/AbstractTypeSystemImpl.java53
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/CompositeTypeSystemImpl.java89
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/TypeSystemImpl.java98
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/builtin/BuiltinTypeSystem.java80
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaDeclarationsContributor.java83
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystem.java391
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystemFactory.java59
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/PolymorphicResolver.java48
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/xpand3/Xpand3ResourceDeclarationsContributor.java30
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/middlend/XtendFrontendASTConverter.java384
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/util/CreateCache.java53
-rw-r--r--plugins/org.eclipse.xtend.middleend.xpand3/META-INF/MANIFEST.MF12
-rw-r--r--plugins/org.eclipse.xtend.middleend.xpand3/TOBEDELETED.TXT1
-rw-r--r--plugins/org.eclipse.xtend.middleend.xpand3/build.properties4
-rw-r--r--plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/Activator.java43
-rw-r--r--plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/BackendTypeConverter.java44
-rw-r--r--plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/SyntaxConstants.java26
-rw-r--r--plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/XtendBackendFacade.java59
-rw-r--r--plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/XtendFrontendASTConverter.java444
44 files changed, 1500 insertions, 1697 deletions
diff --git a/plugins/org.eclipse.xpand3/META-INF/MANIFEST.MF b/plugins/org.eclipse.xpand3/META-INF/MANIFEST.MF
index 9359613..1055976 100644
--- a/plugins/org.eclipse.xpand3/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.xpand3/META-INF/MANIFEST.MF
@@ -13,21 +13,28 @@ Require-Bundle: org.antlr.patched;bundle-version="3.0.0",
org.eclipse.xtend.backend;bundle-version="0.7.0",
org.junit,
org.eclipse.emf.ecore.xmi;bundle-version="2.3.0"
-Export-Package: org.eclipse.xpand3.analyzation,
- org.eclipse.xpand3,
- org.eclipse.xpand3.analyzation.typesystem,
+Export-Package: org.eclipse.xpand3,
+ org.eclipse.xpand3.analyzation,
org.eclipse.xpand3.analyzation.typesystem.builtin,
+ org.eclipse.xpand3.analyzation.typesystem.java,
+ org.eclipse.xpand3.analyzation.typesystem.util,
+ org.eclipse.xpand3.analyzation.typesystem.xpand3,
+ org.eclipse.xpand3.ast,
org.eclipse.xpand3.declaration,
org.eclipse.xpand3.declaration.impl,
org.eclipse.xpand3.declaration.util,
+ org.eclipse.xpand3.declaration.validation,
org.eclipse.xpand3.expression,
org.eclipse.xpand3.expression.impl,
org.eclipse.xpand3.expression.util,
+ org.eclipse.xpand3.expression.validation,
org.eclipse.xpand3.impl,
org.eclipse.xpand3.statement,
org.eclipse.xpand3.statement.impl,
org.eclipse.xpand3.statement.util,
+ org.eclipse.xpand3.statement.validation,
org.eclipse.xpand3.staticTypesystem,
org.eclipse.xpand3.staticTypesystem.impl,
org.eclipse.xpand3.staticTypesystem.util,
- org.eclipse.xpand3.util
+ org.eclipse.xpand3.util,
+ org.eclipse.xpand3.validation
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/ExpressionFactory.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/ExpressionFactory.java
index 1eccf39..99b9294 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/ExpressionFactory.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/ExpressionFactory.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: ExpressionFactory.java,v 1.5 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: ExpressionFactory.java,v 1.6 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.expression;
@@ -206,6 +206,15 @@ public interface ExpressionFactory extends EFactory {
BinaryOperation createBinaryOperation();
/**
+ * Returns a new object of class '<em>Unary Operation</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Unary Operation</em>'.
+ * @generated
+ */
+ UnaryOperation createUnaryOperation();
+
+ /**
* Returns the package supported by this factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/ExpressionPackage.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/ExpressionPackage.java
index df2b276..0d6d3fe 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/ExpressionPackage.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/ExpressionPackage.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: ExpressionPackage.java,v 1.5 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: ExpressionPackage.java,v 1.6 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.expression;
@@ -1650,6 +1650,80 @@ public interface ExpressionPackage extends EPackage {
/**
+ * The meta object id for the '{@link org.eclipse.xpand3.expression.impl.UnaryOperationImpl <em>Unary Operation</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xpand3.expression.impl.UnaryOperationImpl
+ * @see org.eclipse.xpand3.expression.impl.ExpressionPackageImpl#getUnaryOperation()
+ * @generated
+ */
+ int UNARY_OPERATION = 22;
+
+ /**
+ * The feature id for the '<em><b>Line</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int UNARY_OPERATION__LINE = ABSTRACT_EXPRESSION__LINE;
+
+ /**
+ * The feature id for the '<em><b>Start</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int UNARY_OPERATION__START = ABSTRACT_EXPRESSION__START;
+
+ /**
+ * The feature id for the '<em><b>End</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int UNARY_OPERATION__END = ABSTRACT_EXPRESSION__END;
+
+ /**
+ * The feature id for the '<em><b>File Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int UNARY_OPERATION__FILE_NAME = ABSTRACT_EXPRESSION__FILE_NAME;
+
+ /**
+ * The feature id for the '<em><b>Operator</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int UNARY_OPERATION__OPERATOR = ABSTRACT_EXPRESSION_FEATURE_COUNT + 0;
+
+ /**
+ * The feature id for the '<em><b>Operand</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int UNARY_OPERATION__OPERAND = ABSTRACT_EXPRESSION_FEATURE_COUNT + 1;
+
+ /**
+ * The number of structural features of the '<em>Unary Operation</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int UNARY_OPERATION_FEATURE_COUNT = ABSTRACT_EXPRESSION_FEATURE_COUNT + 2;
+
+
+ /**
* Returns the meta object for class '{@link org.eclipse.xpand3.expression.AbstractExpression <em>Abstract Expression</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -2178,6 +2252,38 @@ public interface ExpressionPackage extends EPackage {
EReference getBinaryOperation_Operator();
/**
+ * Returns the meta object for class '{@link org.eclipse.xpand3.expression.UnaryOperation <em>Unary Operation</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Unary Operation</em>'.
+ * @see org.eclipse.xpand3.expression.UnaryOperation
+ * @generated
+ */
+ EClass getUnaryOperation();
+
+ /**
+ * Returns the meta object for the containment reference '{@link org.eclipse.xpand3.expression.UnaryOperation#getOperator <em>Operator</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference '<em>Operator</em>'.
+ * @see org.eclipse.xpand3.expression.UnaryOperation#getOperator()
+ * @see #getUnaryOperation()
+ * @generated
+ */
+ EReference getUnaryOperation_Operator();
+
+ /**
+ * Returns the meta object for the reference '{@link org.eclipse.xpand3.expression.UnaryOperation#getOperand <em>Operand</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the reference '<em>Operand</em>'.
+ * @see org.eclipse.xpand3.expression.UnaryOperation#getOperand()
+ * @see #getUnaryOperation()
+ * @generated
+ */
+ EReference getUnaryOperation_Operand();
+
+ /**
* Returns the factory that creates the instances of the model.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -2643,6 +2749,32 @@ public interface ExpressionPackage extends EPackage {
*/
EReference BINARY_OPERATION__OPERATOR = eINSTANCE.getBinaryOperation_Operator();
+ /**
+ * The meta object literal for the '{@link org.eclipse.xpand3.expression.impl.UnaryOperationImpl <em>Unary Operation</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xpand3.expression.impl.UnaryOperationImpl
+ * @see org.eclipse.xpand3.expression.impl.ExpressionPackageImpl#getUnaryOperation()
+ * @generated
+ */
+ EClass UNARY_OPERATION = eINSTANCE.getUnaryOperation();
+
+ /**
+ * The meta object literal for the '<em><b>Operator</b></em>' containment reference feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference UNARY_OPERATION__OPERATOR = eINSTANCE.getUnaryOperation_Operator();
+
+ /**
+ * The meta object literal for the '<em><b>Operand</b></em>' reference feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference UNARY_OPERATION__OPERAND = eINSTANCE.getUnaryOperation_Operand();
+
}
} //ExpressionPackage
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/UnaryOperation.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/UnaryOperation.java
new file mode 100644
index 0000000..522a3ee
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/UnaryOperation.java
@@ -0,0 +1,81 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: UnaryOperation.java,v 1.3 2008/03/13 11:42:32 sefftinge Exp $
+ */
+package org.eclipse.xpand3.expression;
+
+import org.eclipse.xpand3.Identifier;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Unary Operation</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.xpand3.expression.UnaryOperation#getOperator <em>Operator</em>}</li>
+ * <li>{@link org.eclipse.xpand3.expression.UnaryOperation#getOperand <em>Operand</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.xpand3.expression.ExpressionPackage#getUnaryOperation()
+ * @model
+ * @generated
+ */
+public interface UnaryOperation extends AbstractExpression {
+ /**
+ * Returns the value of the '<em><b>Operator</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Operator</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Operator</em>' containment reference.
+ * @see #setOperator(Identifier)
+ * @see org.eclipse.xpand3.expression.ExpressionPackage#getUnaryOperation_Operator()
+ * @model containment="true"
+ * @generated
+ */
+ Identifier getOperator();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.xpand3.expression.UnaryOperation#getOperator <em>Operator</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Operator</em>' containment reference.
+ * @see #getOperator()
+ * @generated
+ */
+ void setOperator(Identifier value);
+
+ /**
+ * Returns the value of the '<em><b>Operand</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Operand</em>' reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Operand</em>' reference.
+ * @see #setOperand(AbstractExpression)
+ * @see org.eclipse.xpand3.expression.ExpressionPackage#getUnaryOperation_Operand()
+ * @model
+ * @generated
+ */
+ AbstractExpression getOperand();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.xpand3.expression.UnaryOperation#getOperand <em>Operand</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Operand</em>' reference.
+ * @see #getOperand()
+ * @generated
+ */
+ void setOperand(AbstractExpression value);
+
+} // UnaryOperation
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/ExpressionFactoryImpl.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/ExpressionFactoryImpl.java
index dfe3320..7473369 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/ExpressionFactoryImpl.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/ExpressionFactoryImpl.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: ExpressionFactoryImpl.java,v 1.5 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: ExpressionFactoryImpl.java,v 1.6 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.expression.impl;
@@ -80,6 +80,7 @@ public class ExpressionFactoryImpl extends EFactoryImpl implements ExpressionFac
case ExpressionPackage.SWITCH_EXPRESSION: return createSwitchExpression();
case ExpressionPackage.CASE: return createCase();
case ExpressionPackage.BINARY_OPERATION: return createBinaryOperation();
+ case ExpressionPackage.UNARY_OPERATION: return createUnaryOperation();
default:
throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
}
@@ -290,6 +291,16 @@ public class ExpressionFactoryImpl extends EFactoryImpl implements ExpressionFac
* <!-- end-user-doc -->
* @generated
*/
+ public UnaryOperation createUnaryOperation() {
+ UnaryOperationImpl unaryOperation = new UnaryOperationImpl();
+ return unaryOperation;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public ExpressionPackage getExpressionPackage() {
return (ExpressionPackage)getEPackage();
}
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/ExpressionPackageImpl.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/ExpressionPackageImpl.java
index cffcdc8..a5e0bf2 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/ExpressionPackageImpl.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/ExpressionPackageImpl.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: ExpressionPackageImpl.java,v 1.5 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: ExpressionPackageImpl.java,v 1.6 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.expression.impl;
@@ -43,6 +43,7 @@ import org.eclipse.xpand3.expression.StringLiteral;
import org.eclipse.xpand3.expression.SwitchExpression;
import org.eclipse.xpand3.expression.TypeSelectExpression;
+import org.eclipse.xpand3.expression.UnaryOperation;
import org.eclipse.xpand3.impl.Xpand3PackageImpl;
import org.eclipse.xpand3.statement.StatementPackage;
@@ -211,6 +212,13 @@ public class ExpressionPackageImpl extends EPackageImpl implements ExpressionPac
private EClass binaryOperationEClass = null;
/**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass unaryOperationEClass = null;
+
+ /**
* Creates an instance of the model <b>Package</b>, registered with
* {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
* package URI value.
@@ -744,6 +752,33 @@ public class ExpressionPackageImpl extends EPackageImpl implements ExpressionPac
* <!-- end-user-doc -->
* @generated
*/
+ public EClass getUnaryOperation() {
+ return unaryOperationEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getUnaryOperation_Operator() {
+ return (EReference)unaryOperationEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getUnaryOperation_Operand() {
+ return (EReference)unaryOperationEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public ExpressionFactory getExpressionFactory() {
return (ExpressionFactory)getEFactoryInstance();
}
@@ -838,6 +873,10 @@ public class ExpressionPackageImpl extends EPackageImpl implements ExpressionPac
createEReference(binaryOperationEClass, BINARY_OPERATION__LEFT);
createEReference(binaryOperationEClass, BINARY_OPERATION__RIGHT);
createEReference(binaryOperationEClass, BINARY_OPERATION__OPERATOR);
+
+ unaryOperationEClass = createEClass(UNARY_OPERATION);
+ createEReference(unaryOperationEClass, UNARY_OPERATION__OPERATOR);
+ createEReference(unaryOperationEClass, UNARY_OPERATION__OPERAND);
}
/**
@@ -893,6 +932,7 @@ public class ExpressionPackageImpl extends EPackageImpl implements ExpressionPac
switchExpressionEClass.getESuperTypes().add(this.getAbstractExpression());
caseEClass.getESuperTypes().add(theXpand3Package.getSyntaxElement());
binaryOperationEClass.getESuperTypes().add(this.getAbstractExpression());
+ unaryOperationEClass.getESuperTypes().add(this.getAbstractExpression());
// Initialize classes and features; add operations and parameters
initEClass(abstractExpressionEClass, AbstractExpression.class, "AbstractExpression", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
@@ -966,6 +1006,10 @@ public class ExpressionPackageImpl extends EPackageImpl implements ExpressionPac
initEReference(getBinaryOperation_Left(), this.getAbstractExpression(), null, "left", null, 0, 1, BinaryOperation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getBinaryOperation_Right(), this.getAbstractExpression(), null, "right", null, 0, 1, BinaryOperation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getBinaryOperation_Operator(), theXpand3Package.getIdentifier(), null, "operator", null, 0, 1, BinaryOperation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(unaryOperationEClass, UnaryOperation.class, "UnaryOperation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getUnaryOperation_Operator(), theXpand3Package.getIdentifier(), null, "operator", null, 0, 1, UnaryOperation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getUnaryOperation_Operand(), this.getAbstractExpression(), null, "operand", null, 0, 1, UnaryOperation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
}
} //ExpressionPackageImpl
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/UnaryOperationImpl.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/UnaryOperationImpl.java
new file mode 100644
index 0000000..ae9fd92
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/impl/UnaryOperationImpl.java
@@ -0,0 +1,241 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: UnaryOperationImpl.java,v 1.3 2008/03/13 11:42:32 sefftinge Exp $
+ */
+package org.eclipse.xpand3.expression.impl;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+
+import org.eclipse.xpand3.Identifier;
+
+import org.eclipse.xpand3.expression.AbstractExpression;
+import org.eclipse.xpand3.expression.ExpressionPackage;
+import org.eclipse.xpand3.expression.UnaryOperation;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Unary Operation</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.xpand3.expression.impl.UnaryOperationImpl#getOperator <em>Operator</em>}</li>
+ * <li>{@link org.eclipse.xpand3.expression.impl.UnaryOperationImpl#getOperand <em>Operand</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class UnaryOperationImpl extends AbstractExpressionImpl implements UnaryOperation {
+ /**
+ * The cached value of the '{@link #getOperator() <em>Operator</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getOperator()
+ * @generated
+ * @ordered
+ */
+ protected Identifier operator;
+
+ /**
+ * The cached value of the '{@link #getOperand() <em>Operand</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getOperand()
+ * @generated
+ * @ordered
+ */
+ protected AbstractExpression operand;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected UnaryOperationImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return ExpressionPackage.Literals.UNARY_OPERATION;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Identifier getOperator() {
+ return operator;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain basicSetOperator(Identifier newOperator, NotificationChain msgs) {
+ Identifier oldOperator = operator;
+ operator = newOperator;
+ if (eNotificationRequired()) {
+ ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExpressionPackage.UNARY_OPERATION__OPERATOR, oldOperator, newOperator);
+ if (msgs == null) msgs = notification; else msgs.add(notification);
+ }
+ return msgs;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setOperator(Identifier newOperator) {
+ if (newOperator != operator) {
+ NotificationChain msgs = null;
+ if (operator != null)
+ msgs = ((InternalEObject)operator).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ExpressionPackage.UNARY_OPERATION__OPERATOR, null, msgs);
+ if (newOperator != null)
+ msgs = ((InternalEObject)newOperator).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ExpressionPackage.UNARY_OPERATION__OPERATOR, null, msgs);
+ msgs = basicSetOperator(newOperator, msgs);
+ if (msgs != null) msgs.dispatch();
+ }
+ else if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, ExpressionPackage.UNARY_OPERATION__OPERATOR, newOperator, newOperator));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public AbstractExpression getOperand() {
+ if (operand != null && operand.eIsProxy()) {
+ InternalEObject oldOperand = (InternalEObject)operand;
+ operand = (AbstractExpression)eResolveProxy(oldOperand);
+ if (operand != oldOperand) {
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.RESOLVE, ExpressionPackage.UNARY_OPERATION__OPERAND, oldOperand, operand));
+ }
+ }
+ return operand;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public AbstractExpression basicGetOperand() {
+ return operand;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setOperand(AbstractExpression newOperand) {
+ AbstractExpression oldOperand = operand;
+ operand = newOperand;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, ExpressionPackage.UNARY_OPERATION__OPERAND, oldOperand, operand));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case ExpressionPackage.UNARY_OPERATION__OPERATOR:
+ return basicSetOperator(null, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case ExpressionPackage.UNARY_OPERATION__OPERATOR:
+ return getOperator();
+ case ExpressionPackage.UNARY_OPERATION__OPERAND:
+ if (resolve) return getOperand();
+ return basicGetOperand();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case ExpressionPackage.UNARY_OPERATION__OPERATOR:
+ setOperator((Identifier)newValue);
+ return;
+ case ExpressionPackage.UNARY_OPERATION__OPERAND:
+ setOperand((AbstractExpression)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case ExpressionPackage.UNARY_OPERATION__OPERATOR:
+ setOperator((Identifier)null);
+ return;
+ case ExpressionPackage.UNARY_OPERATION__OPERAND:
+ setOperand((AbstractExpression)null);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case ExpressionPackage.UNARY_OPERATION__OPERATOR:
+ return operator != null;
+ case ExpressionPackage.UNARY_OPERATION__OPERAND:
+ return operand != null;
+ }
+ return super.eIsSet(featureID);
+ }
+
+} //UnaryOperationImpl
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/util/ExpressionAdapterFactory.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/util/ExpressionAdapterFactory.java
index 2a104af..2638e2b 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/util/ExpressionAdapterFactory.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/util/ExpressionAdapterFactory.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: ExpressionAdapterFactory.java,v 1.5 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: ExpressionAdapterFactory.java,v 1.6 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.expression.util;
@@ -162,6 +162,10 @@ public class ExpressionAdapterFactory extends AdapterFactoryImpl {
return createBinaryOperationAdapter();
}
@Override
+ public Adapter caseUnaryOperation(UnaryOperation object) {
+ return createUnaryOperationAdapter();
+ }
+ @Override
public Adapter caseSyntaxElement(SyntaxElement object) {
return createSyntaxElementAdapter();
}
@@ -494,6 +498,20 @@ public class ExpressionAdapterFactory extends AdapterFactoryImpl {
}
/**
+ * Creates a new adapter for an object of class '{@link org.eclipse.xpand3.expression.UnaryOperation <em>Unary Operation</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.xpand3.expression.UnaryOperation
+ * @generated
+ */
+ public Adapter createUnaryOperationAdapter() {
+ return null;
+ }
+
+ /**
* Creates a new adapter for an object of class '{@link org.eclipse.xpand3.SyntaxElement <em>Syntax Element</em>}'.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/util/ExpressionSwitch.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/util/ExpressionSwitch.java
index 970253a..422446f 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/util/ExpressionSwitch.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/util/ExpressionSwitch.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: ExpressionSwitch.java,v 1.5 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: ExpressionSwitch.java,v 1.6 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.expression.util;
@@ -272,6 +272,14 @@ public class ExpressionSwitch<T> {
if (result == null) result = defaultCase(theEObject);
return result;
}
+ case ExpressionPackage.UNARY_OPERATION: {
+ UnaryOperation unaryOperation = (UnaryOperation)theEObject;
+ T result = caseUnaryOperation(unaryOperation);
+ if (result == null) result = caseAbstractExpression(unaryOperation);
+ if (result == null) result = caseSyntaxElement(unaryOperation);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
default: return defaultCase(theEObject);
}
}
@@ -607,6 +615,21 @@ public class ExpressionSwitch<T> {
}
/**
+ * Returns the result of interpreting the object as an instance of '<em>Unary Operation</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Unary Operation</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseUnaryOperation(UnaryOperation object) {
+ return null;
+ }
+
+ /**
* Returns the result of interpreting the object as an instance of '<em>Syntax Element</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/validation/UnaryOperationValidator.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/validation/UnaryOperationValidator.java
deleted file mode 100644
index 20fb10d..0000000
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/expression/validation/UnaryOperationValidator.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * <copyright>
- * </copyright>
- *
- * $Id: UnaryOperationValidator.java,v 1.1 2008/03/12 09:54:30 jkohnlein Exp $
- */
-package org.eclipse.xpand3.expression.validation;
-
-import org.eclipse.xpand3.Identifier;
-
-import org.eclipse.xpand3.expression.AbstractExpression;
-
-/**
- * A sample validator interface for {@link org.eclipse.xpand3.expression.UnaryOperation}.
- * This doesn't really do anything, and it's not a real EMF artifact.
- * It was generated by the org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's code generator can be extended.
- * This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false.
- */
-public interface UnaryOperationValidator {
- boolean validate();
-
- boolean validateOperator(Identifier value);
- boolean validateOperand(AbstractExpression value);
-}
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/FileStatement.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/FileStatement.java
index cc3ad6d..48f7b40 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/FileStatement.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/FileStatement.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: FileStatement.java,v 1.4 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: FileStatement.java,v 1.5 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.statement;
@@ -20,6 +20,7 @@ import org.eclipse.xpand3.expression.AbstractExpression;
* <ul>
* <li>{@link org.eclipse.xpand3.statement.FileStatement#getFileNameExpression <em>File Name Expression</em>}</li>
* <li>{@link org.eclipse.xpand3.statement.FileStatement#getOutletNameIdentifier <em>Outlet Name Identifier</em>}</li>
+ * <li>{@link org.eclipse.xpand3.statement.FileStatement#isOnce <em>Once</em>}</li>
* </ul>
* </p>
*
@@ -80,4 +81,30 @@ public interface FileStatement extends AbstractStatementWithBody {
*/
void setOutletNameIdentifier(Identifier value);
+ /**
+ * Returns the value of the '<em><b>Once</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Once</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Once</em>' attribute.
+ * @see #setOnce(boolean)
+ * @see org.eclipse.xpand3.statement.StatementPackage#getFileStatement_Once()
+ * @model
+ * @generated
+ */
+ boolean isOnce();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.xpand3.statement.FileStatement#isOnce <em>Once</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Once</em>' attribute.
+ * @see #isOnce()
+ * @generated
+ */
+ void setOnce(boolean value);
+
} // FileStatement
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/ForEachStatement.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/ForEachStatement.java
index 492ed66..af6ef8d 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/ForEachStatement.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/ForEachStatement.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: ForEachStatement.java,v 1.4 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: ForEachStatement.java,v 1.5 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.statement;
@@ -19,7 +19,7 @@ import org.eclipse.xpand3.expression.AbstractExpression;
* The following features are supported:
* <ul>
* <li>{@link org.eclipse.xpand3.statement.ForEachStatement#getTarget <em>Target</em>}</li>
- * <li>{@link org.eclipse.xpand3.statement.ForEachStatement#getSeperator <em>Seperator</em>}</li>
+ * <li>{@link org.eclipse.xpand3.statement.ForEachStatement#getSeparator <em>Separator</em>}</li>
* <li>{@link org.eclipse.xpand3.statement.ForEachStatement#getVariable <em>Variable</em>}</li>
* <li>{@link org.eclipse.xpand3.statement.ForEachStatement#getIteratorName <em>Iterator Name</em>}</li>
* </ul>
@@ -57,30 +57,30 @@ public interface ForEachStatement extends AbstractStatementWithBody {
void setTarget(AbstractExpression value);
/**
- * Returns the value of the '<em><b>Seperator</b></em>' containment reference.
+ * Returns the value of the '<em><b>Separator</b></em>' containment reference.
* <!-- begin-user-doc -->
* <p>
- * If the meaning of the '<em>Seperator</em>' containment reference isn't clear,
+ * If the meaning of the '<em>Separator</em>' containment reference isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
- * @return the value of the '<em>Seperator</em>' containment reference.
- * @see #setSeperator(AbstractExpression)
- * @see org.eclipse.xpand3.statement.StatementPackage#getForEachStatement_Seperator()
+ * @return the value of the '<em>Separator</em>' containment reference.
+ * @see #setSeparator(AbstractExpression)
+ * @see org.eclipse.xpand3.statement.StatementPackage#getForEachStatement_Separator()
* @model containment="true"
* @generated
*/
- AbstractExpression getSeperator();
+ AbstractExpression getSeparator();
/**
- * Sets the value of the '{@link org.eclipse.xpand3.statement.ForEachStatement#getSeperator <em>Seperator</em>}' containment reference.
+ * Sets the value of the '{@link org.eclipse.xpand3.statement.ForEachStatement#getSeparator <em>Separator</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @param value the new value of the '<em>Seperator</em>' containment reference.
- * @see #getSeperator()
+ * @param value the new value of the '<em>Separator</em>' containment reference.
+ * @see #getSeparator()
* @generated
*/
- void setSeperator(AbstractExpression value);
+ void setSeparator(AbstractExpression value);
/**
* Returns the value of the '<em><b>Variable</b></em>' containment reference.
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/IfStatement.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/IfStatement.java
index 69c3dee..30b3631 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/IfStatement.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/IfStatement.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: IfStatement.java,v 1.4 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: IfStatement.java,v 1.5 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.statement;
@@ -17,7 +17,6 @@ import org.eclipse.xpand3.expression.AbstractExpression;
* The following features are supported:
* <ul>
* <li>{@link org.eclipse.xpand3.statement.IfStatement#getCondition <em>Condition</em>}</li>
- * <li>{@link org.eclipse.xpand3.statement.IfStatement#getUpperIf <em>Upper If</em>}</li>
* <li>{@link org.eclipse.xpand3.statement.IfStatement#getElseIf <em>Else If</em>}</li>
* </ul>
* </p>
@@ -54,32 +53,6 @@ public interface IfStatement extends AbstractStatementWithBody {
void setCondition(AbstractExpression value);
/**
- * Returns the value of the '<em><b>Upper If</b></em>' reference.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Upper If</em>' reference isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Upper If</em>' reference.
- * @see #setUpperIf(IfStatement)
- * @see org.eclipse.xpand3.statement.StatementPackage#getIfStatement_UpperIf()
- * @model
- * @generated
- */
- IfStatement getUpperIf();
-
- /**
- * Sets the value of the '{@link org.eclipse.xpand3.statement.IfStatement#getUpperIf <em>Upper If</em>}' reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Upper If</em>' reference.
- * @see #getUpperIf()
- * @generated
- */
- void setUpperIf(IfStatement value);
-
- /**
* Returns the value of the '<em><b>Else If</b></em>' containment reference.
* <!-- begin-user-doc -->
* <p>
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/StatementPackage.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/StatementPackage.java
index 59a9c00..0a53b14 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/StatementPackage.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/StatementPackage.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: StatementPackage.java,v 1.4 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: StatementPackage.java,v 1.5 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.statement;
@@ -482,13 +482,22 @@ public interface StatementPackage extends EPackage {
int FILE_STATEMENT__OUTLET_NAME_IDENTIFIER = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 1;
/**
+ * The feature id for the '<em><b>Once</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int FILE_STATEMENT__ONCE = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 2;
+
+ /**
* The number of structural features of the '<em>File Statement</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- int FILE_STATEMENT_FEATURE_COUNT = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 2;
+ int FILE_STATEMENT_FEATURE_COUNT = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 3;
/**
* The meta object id for the '{@link org.eclipse.xpand3.statement.impl.ForEachStatementImpl <em>For Each Statement</em>}' class.
@@ -555,13 +564,13 @@ public interface StatementPackage extends EPackage {
int FOR_EACH_STATEMENT__TARGET = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 0;
/**
- * The feature id for the '<em><b>Seperator</b></em>' containment reference.
+ * The feature id for the '<em><b>Separator</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- int FOR_EACH_STATEMENT__SEPERATOR = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 1;
+ int FOR_EACH_STATEMENT__SEPARATOR = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 1;
/**
* The feature id for the '<em><b>Variable</b></em>' containment reference.
@@ -655,22 +664,13 @@ public interface StatementPackage extends EPackage {
int IF_STATEMENT__CONDITION = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 0;
/**
- * The feature id for the '<em><b>Upper If</b></em>' reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- int IF_STATEMENT__UPPER_IF = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 1;
-
- /**
* The feature id for the '<em><b>Else If</b></em>' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- int IF_STATEMENT__ELSE_IF = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 2;
+ int IF_STATEMENT__ELSE_IF = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 1;
/**
* The number of structural features of the '<em>If Statement</em>' class.
@@ -679,7 +679,7 @@ public interface StatementPackage extends EPackage {
* @generated
* @ordered
*/
- int IF_STATEMENT_FEATURE_COUNT = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 3;
+ int IF_STATEMENT_FEATURE_COUNT = ABSTRACT_STATEMENT_WITH_BODY_FEATURE_COUNT + 2;
/**
* The meta object id for the '{@link org.eclipse.xpand3.statement.impl.LetStatementImpl <em>Let Statement</em>}' class.
@@ -1108,6 +1108,17 @@ public interface StatementPackage extends EPackage {
EReference getFileStatement_OutletNameIdentifier();
/**
+ * Returns the meta object for the attribute '{@link org.eclipse.xpand3.statement.FileStatement#isOnce <em>Once</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Once</em>'.
+ * @see org.eclipse.xpand3.statement.FileStatement#isOnce()
+ * @see #getFileStatement()
+ * @generated
+ */
+ EAttribute getFileStatement_Once();
+
+ /**
* Returns the meta object for class '{@link org.eclipse.xpand3.statement.ForEachStatement <em>For Each Statement</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -1129,15 +1140,15 @@ public interface StatementPackage extends EPackage {
EReference getForEachStatement_Target();
/**
- * Returns the meta object for the containment reference '{@link org.eclipse.xpand3.statement.ForEachStatement#getSeperator <em>Seperator</em>}'.
+ * Returns the meta object for the containment reference '{@link org.eclipse.xpand3.statement.ForEachStatement#getSeparator <em>Separator</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @return the meta object for the containment reference '<em>Seperator</em>'.
- * @see org.eclipse.xpand3.statement.ForEachStatement#getSeperator()
+ * @return the meta object for the containment reference '<em>Separator</em>'.
+ * @see org.eclipse.xpand3.statement.ForEachStatement#getSeparator()
* @see #getForEachStatement()
* @generated
*/
- EReference getForEachStatement_Seperator();
+ EReference getForEachStatement_Separator();
/**
* Returns the meta object for the containment reference '{@link org.eclipse.xpand3.statement.ForEachStatement#getVariable <em>Variable</em>}'.
@@ -1183,17 +1194,6 @@ public interface StatementPackage extends EPackage {
EReference getIfStatement_Condition();
/**
- * Returns the meta object for the reference '{@link org.eclipse.xpand3.statement.IfStatement#getUpperIf <em>Upper If</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the reference '<em>Upper If</em>'.
- * @see org.eclipse.xpand3.statement.IfStatement#getUpperIf()
- * @see #getIfStatement()
- * @generated
- */
- EReference getIfStatement_UpperIf();
-
- /**
* Returns the meta object for the containment reference '{@link org.eclipse.xpand3.statement.IfStatement#getElseIf <em>Else If</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -1485,6 +1485,14 @@ public interface StatementPackage extends EPackage {
EReference FILE_STATEMENT__OUTLET_NAME_IDENTIFIER = eINSTANCE.getFileStatement_OutletNameIdentifier();
/**
+ * The meta object literal for the '<em><b>Once</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute FILE_STATEMENT__ONCE = eINSTANCE.getFileStatement_Once();
+
+ /**
* The meta object literal for the '{@link org.eclipse.xpand3.statement.impl.ForEachStatementImpl <em>For Each Statement</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -1503,12 +1511,12 @@ public interface StatementPackage extends EPackage {
EReference FOR_EACH_STATEMENT__TARGET = eINSTANCE.getForEachStatement_Target();
/**
- * The meta object literal for the '<em><b>Seperator</b></em>' containment reference feature.
+ * The meta object literal for the '<em><b>Separator</b></em>' containment reference feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
- EReference FOR_EACH_STATEMENT__SEPERATOR = eINSTANCE.getForEachStatement_Seperator();
+ EReference FOR_EACH_STATEMENT__SEPARATOR = eINSTANCE.getForEachStatement_Separator();
/**
* The meta object literal for the '<em><b>Variable</b></em>' containment reference feature.
@@ -1545,14 +1553,6 @@ public interface StatementPackage extends EPackage {
EReference IF_STATEMENT__CONDITION = eINSTANCE.getIfStatement_Condition();
/**
- * The meta object literal for the '<em><b>Upper If</b></em>' reference feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- EReference IF_STATEMENT__UPPER_IF = eINSTANCE.getIfStatement_UpperIf();
-
- /**
* The meta object literal for the '<em><b>Else If</b></em>' containment reference feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/FileStatementImpl.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/FileStatementImpl.java
index 2575458..d1a9dac 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/FileStatementImpl.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/FileStatementImpl.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: FileStatementImpl.java,v 1.4 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: FileStatementImpl.java,v 1.5 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.statement.impl;
@@ -30,6 +30,7 @@ import org.eclipse.xpand3.statement.StatementPackage;
* <ul>
* <li>{@link org.eclipse.xpand3.statement.impl.FileStatementImpl#getFileNameExpression <em>File Name Expression</em>}</li>
* <li>{@link org.eclipse.xpand3.statement.impl.FileStatementImpl#getOutletNameIdentifier <em>Outlet Name Identifier</em>}</li>
+ * <li>{@link org.eclipse.xpand3.statement.impl.FileStatementImpl#isOnce <em>Once</em>}</li>
* </ul>
* </p>
*
@@ -57,6 +58,26 @@ public class FileStatementImpl extends AbstractStatementWithBodyImpl implements
protected Identifier outletNameIdentifier;
/**
+ * The default value of the '{@link #isOnce() <em>Once</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isOnce()
+ * @generated
+ * @ordered
+ */
+ protected static final boolean ONCE_EDEFAULT = false;
+
+ /**
+ * The cached value of the '{@link #isOnce() <em>Once</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isOnce()
+ * @generated
+ * @ordered
+ */
+ protected boolean once = ONCE_EDEFAULT;
+
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -166,6 +187,27 @@ public class FileStatementImpl extends AbstractStatementWithBodyImpl implements
* <!-- end-user-doc -->
* @generated
*/
+ public boolean isOnce() {
+ return once;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setOnce(boolean newOnce) {
+ boolean oldOnce = once;
+ once = newOnce;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, StatementPackage.FILE_STATEMENT__ONCE, oldOnce, once));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
@@ -189,6 +231,8 @@ public class FileStatementImpl extends AbstractStatementWithBodyImpl implements
return getFileNameExpression();
case StatementPackage.FILE_STATEMENT__OUTLET_NAME_IDENTIFIER:
return getOutletNameIdentifier();
+ case StatementPackage.FILE_STATEMENT__ONCE:
+ return isOnce() ? Boolean.TRUE : Boolean.FALSE;
}
return super.eGet(featureID, resolve, coreType);
}
@@ -207,6 +251,9 @@ public class FileStatementImpl extends AbstractStatementWithBodyImpl implements
case StatementPackage.FILE_STATEMENT__OUTLET_NAME_IDENTIFIER:
setOutletNameIdentifier((Identifier)newValue);
return;
+ case StatementPackage.FILE_STATEMENT__ONCE:
+ setOnce(((Boolean)newValue).booleanValue());
+ return;
}
super.eSet(featureID, newValue);
}
@@ -225,6 +272,9 @@ public class FileStatementImpl extends AbstractStatementWithBodyImpl implements
case StatementPackage.FILE_STATEMENT__OUTLET_NAME_IDENTIFIER:
setOutletNameIdentifier((Identifier)null);
return;
+ case StatementPackage.FILE_STATEMENT__ONCE:
+ setOnce(ONCE_EDEFAULT);
+ return;
}
super.eUnset(featureID);
}
@@ -241,8 +291,26 @@ public class FileStatementImpl extends AbstractStatementWithBodyImpl implements
return fileNameExpression != null;
case StatementPackage.FILE_STATEMENT__OUTLET_NAME_IDENTIFIER:
return outletNameIdentifier != null;
+ case StatementPackage.FILE_STATEMENT__ONCE:
+ return once != ONCE_EDEFAULT;
}
return super.eIsSet(featureID);
}
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (once: ");
+ result.append(once);
+ result.append(')');
+ return result.toString();
+ }
+
} //FileStatementImpl
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/ForEachStatementImpl.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/ForEachStatementImpl.java
index ce15321..ec46673 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/ForEachStatementImpl.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/ForEachStatementImpl.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: ForEachStatementImpl.java,v 1.4 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: ForEachStatementImpl.java,v 1.5 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.statement.impl;
@@ -29,7 +29,7 @@ import org.eclipse.xpand3.statement.StatementPackage;
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.xpand3.statement.impl.ForEachStatementImpl#getTarget <em>Target</em>}</li>
- * <li>{@link org.eclipse.xpand3.statement.impl.ForEachStatementImpl#getSeperator <em>Seperator</em>}</li>
+ * <li>{@link org.eclipse.xpand3.statement.impl.ForEachStatementImpl#getSeparator <em>Separator</em>}</li>
* <li>{@link org.eclipse.xpand3.statement.impl.ForEachStatementImpl#getVariable <em>Variable</em>}</li>
* <li>{@link org.eclipse.xpand3.statement.impl.ForEachStatementImpl#getIteratorName <em>Iterator Name</em>}</li>
* </ul>
@@ -49,14 +49,14 @@ public class ForEachStatementImpl extends AbstractStatementWithBodyImpl implemen
protected AbstractExpression target;
/**
- * The cached value of the '{@link #getSeperator() <em>Seperator</em>}' containment reference.
+ * The cached value of the '{@link #getSeparator() <em>Separator</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @see #getSeperator()
+ * @see #getSeparator()
* @generated
* @ordered
*/
- protected AbstractExpression seperator;
+ protected AbstractExpression separator;
/**
* The cached value of the '{@link #getVariable() <em>Variable</em>}' containment reference.
@@ -145,8 +145,8 @@ public class ForEachStatementImpl extends AbstractStatementWithBodyImpl implemen
* <!-- end-user-doc -->
* @generated
*/
- public AbstractExpression getSeperator() {
- return seperator;
+ public AbstractExpression getSeparator() {
+ return separator;
}
/**
@@ -154,11 +154,11 @@ public class ForEachStatementImpl extends AbstractStatementWithBodyImpl implemen
* <!-- end-user-doc -->
* @generated
*/
- public NotificationChain basicSetSeperator(AbstractExpression newSeperator, NotificationChain msgs) {
- AbstractExpression oldSeperator = seperator;
- seperator = newSeperator;
+ public NotificationChain basicSetSeparator(AbstractExpression newSeparator, NotificationChain msgs) {
+ AbstractExpression oldSeparator = separator;
+ separator = newSeparator;
if (eNotificationRequired()) {
- ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StatementPackage.FOR_EACH_STATEMENT__SEPERATOR, oldSeperator, newSeperator);
+ ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StatementPackage.FOR_EACH_STATEMENT__SEPARATOR, oldSeparator, newSeparator);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
@@ -169,18 +169,18 @@ public class ForEachStatementImpl extends AbstractStatementWithBodyImpl implemen
* <!-- end-user-doc -->
* @generated
*/
- public void setSeperator(AbstractExpression newSeperator) {
- if (newSeperator != seperator) {
+ public void setSeparator(AbstractExpression newSeparator) {
+ if (newSeparator != separator) {
NotificationChain msgs = null;
- if (seperator != null)
- msgs = ((InternalEObject)seperator).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StatementPackage.FOR_EACH_STATEMENT__SEPERATOR, null, msgs);
- if (newSeperator != null)
- msgs = ((InternalEObject)newSeperator).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StatementPackage.FOR_EACH_STATEMENT__SEPERATOR, null, msgs);
- msgs = basicSetSeperator(newSeperator, msgs);
+ if (separator != null)
+ msgs = ((InternalEObject)separator).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StatementPackage.FOR_EACH_STATEMENT__SEPARATOR, null, msgs);
+ if (newSeparator != null)
+ msgs = ((InternalEObject)newSeparator).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StatementPackage.FOR_EACH_STATEMENT__SEPARATOR, null, msgs);
+ msgs = basicSetSeparator(newSeparator, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, StatementPackage.FOR_EACH_STATEMENT__SEPERATOR, newSeperator, newSeperator));
+ eNotify(new ENotificationImpl(this, Notification.SET, StatementPackage.FOR_EACH_STATEMENT__SEPARATOR, newSeparator, newSeparator));
}
/**
@@ -279,8 +279,8 @@ public class ForEachStatementImpl extends AbstractStatementWithBodyImpl implemen
switch (featureID) {
case StatementPackage.FOR_EACH_STATEMENT__TARGET:
return basicSetTarget(null, msgs);
- case StatementPackage.FOR_EACH_STATEMENT__SEPERATOR:
- return basicSetSeperator(null, msgs);
+ case StatementPackage.FOR_EACH_STATEMENT__SEPARATOR:
+ return basicSetSeparator(null, msgs);
case StatementPackage.FOR_EACH_STATEMENT__VARIABLE:
return basicSetVariable(null, msgs);
case StatementPackage.FOR_EACH_STATEMENT__ITERATOR_NAME:
@@ -299,8 +299,8 @@ public class ForEachStatementImpl extends AbstractStatementWithBodyImpl implemen
switch (featureID) {
case StatementPackage.FOR_EACH_STATEMENT__TARGET:
return getTarget();
- case StatementPackage.FOR_EACH_STATEMENT__SEPERATOR:
- return getSeperator();
+ case StatementPackage.FOR_EACH_STATEMENT__SEPARATOR:
+ return getSeparator();
case StatementPackage.FOR_EACH_STATEMENT__VARIABLE:
return getVariable();
case StatementPackage.FOR_EACH_STATEMENT__ITERATOR_NAME:
@@ -320,8 +320,8 @@ public class ForEachStatementImpl extends AbstractStatementWithBodyImpl implemen
case StatementPackage.FOR_EACH_STATEMENT__TARGET:
setTarget((AbstractExpression)newValue);
return;
- case StatementPackage.FOR_EACH_STATEMENT__SEPERATOR:
- setSeperator((AbstractExpression)newValue);
+ case StatementPackage.FOR_EACH_STATEMENT__SEPARATOR:
+ setSeparator((AbstractExpression)newValue);
return;
case StatementPackage.FOR_EACH_STATEMENT__VARIABLE:
setVariable((Identifier)newValue);
@@ -344,8 +344,8 @@ public class ForEachStatementImpl extends AbstractStatementWithBodyImpl implemen
case StatementPackage.FOR_EACH_STATEMENT__TARGET:
setTarget((AbstractExpression)null);
return;
- case StatementPackage.FOR_EACH_STATEMENT__SEPERATOR:
- setSeperator((AbstractExpression)null);
+ case StatementPackage.FOR_EACH_STATEMENT__SEPARATOR:
+ setSeparator((AbstractExpression)null);
return;
case StatementPackage.FOR_EACH_STATEMENT__VARIABLE:
setVariable((Identifier)null);
@@ -367,8 +367,8 @@ public class ForEachStatementImpl extends AbstractStatementWithBodyImpl implemen
switch (featureID) {
case StatementPackage.FOR_EACH_STATEMENT__TARGET:
return target != null;
- case StatementPackage.FOR_EACH_STATEMENT__SEPERATOR:
- return seperator != null;
+ case StatementPackage.FOR_EACH_STATEMENT__SEPARATOR:
+ return separator != null;
case StatementPackage.FOR_EACH_STATEMENT__VARIABLE:
return variable != null;
case StatementPackage.FOR_EACH_STATEMENT__ITERATOR_NAME:
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/IfStatementImpl.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/IfStatementImpl.java
index f1c914e..0b6e1c1 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/IfStatementImpl.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/IfStatementImpl.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: IfStatementImpl.java,v 1.4 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: IfStatementImpl.java,v 1.5 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.statement.impl;
@@ -27,7 +27,6 @@ import org.eclipse.xpand3.statement.StatementPackage;
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.xpand3.statement.impl.IfStatementImpl#getCondition <em>Condition</em>}</li>
- * <li>{@link org.eclipse.xpand3.statement.impl.IfStatementImpl#getUpperIf <em>Upper If</em>}</li>
* <li>{@link org.eclipse.xpand3.statement.impl.IfStatementImpl#getElseIf <em>Else If</em>}</li>
* </ul>
* </p>
@@ -46,16 +45,6 @@ public class IfStatementImpl extends AbstractStatementWithBodyImpl implements If
protected AbstractExpression condition;
/**
- * The cached value of the '{@link #getUpperIf() <em>Upper If</em>}' reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getUpperIf()
- * @generated
- * @ordered
- */
- protected IfStatement upperIf;
-
- /**
* The cached value of the '{@link #getElseIf() <em>Else If</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -132,44 +121,6 @@ public class IfStatementImpl extends AbstractStatementWithBodyImpl implements If
* <!-- end-user-doc -->
* @generated
*/
- public IfStatement getUpperIf() {
- if (upperIf != null && upperIf.eIsProxy()) {
- InternalEObject oldUpperIf = (InternalEObject)upperIf;
- upperIf = (IfStatement)eResolveProxy(oldUpperIf);
- if (upperIf != oldUpperIf) {
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.RESOLVE, StatementPackage.IF_STATEMENT__UPPER_IF, oldUpperIf, upperIf));
- }
- }
- return upperIf;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public IfStatement basicGetUpperIf() {
- return upperIf;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void setUpperIf(IfStatement newUpperIf) {
- IfStatement oldUpperIf = upperIf;
- upperIf = newUpperIf;
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, StatementPackage.IF_STATEMENT__UPPER_IF, oldUpperIf, upperIf));
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
public IfStatement getElseIf() {
return elseIf;
}
@@ -234,9 +185,6 @@ public class IfStatementImpl extends AbstractStatementWithBodyImpl implements If
switch (featureID) {
case StatementPackage.IF_STATEMENT__CONDITION:
return getCondition();
- case StatementPackage.IF_STATEMENT__UPPER_IF:
- if (resolve) return getUpperIf();
- return basicGetUpperIf();
case StatementPackage.IF_STATEMENT__ELSE_IF:
return getElseIf();
}
@@ -254,9 +202,6 @@ public class IfStatementImpl extends AbstractStatementWithBodyImpl implements If
case StatementPackage.IF_STATEMENT__CONDITION:
setCondition((AbstractExpression)newValue);
return;
- case StatementPackage.IF_STATEMENT__UPPER_IF:
- setUpperIf((IfStatement)newValue);
- return;
case StatementPackage.IF_STATEMENT__ELSE_IF:
setElseIf((IfStatement)newValue);
return;
@@ -275,9 +220,6 @@ public class IfStatementImpl extends AbstractStatementWithBodyImpl implements If
case StatementPackage.IF_STATEMENT__CONDITION:
setCondition((AbstractExpression)null);
return;
- case StatementPackage.IF_STATEMENT__UPPER_IF:
- setUpperIf((IfStatement)null);
- return;
case StatementPackage.IF_STATEMENT__ELSE_IF:
setElseIf((IfStatement)null);
return;
@@ -295,8 +237,6 @@ public class IfStatementImpl extends AbstractStatementWithBodyImpl implements If
switch (featureID) {
case StatementPackage.IF_STATEMENT__CONDITION:
return condition != null;
- case StatementPackage.IF_STATEMENT__UPPER_IF:
- return upperIf != null;
case StatementPackage.IF_STATEMENT__ELSE_IF:
return elseIf != null;
}
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/StatementPackageImpl.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/StatementPackageImpl.java
index 870d59e..d556e0e 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/StatementPackageImpl.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/impl/StatementPackageImpl.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: StatementPackageImpl.java,v 1.4 2008/03/13 11:41:50 sefftinge Exp $
+ * $Id: StatementPackageImpl.java,v 1.5 2008/03/13 11:42:32 sefftinge Exp $
*/
package org.eclipse.xpand3.statement.impl;
@@ -351,6 +351,15 @@ public class StatementPackageImpl extends EPackageImpl implements StatementPacka
* <!-- end-user-doc -->
* @generated
*/
+ public EAttribute getFileStatement_Once() {
+ return (EAttribute)fileStatementEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public EClass getForEachStatement() {
return forEachStatementEClass;
}
@@ -369,7 +378,7 @@ public class StatementPackageImpl extends EPackageImpl implements StatementPacka
* <!-- end-user-doc -->
* @generated
*/
- public EReference getForEachStatement_Seperator() {
+ public EReference getForEachStatement_Separator() {
return (EReference)forEachStatementEClass.getEStructuralFeatures().get(1);
}
@@ -414,17 +423,8 @@ public class StatementPackageImpl extends EPackageImpl implements StatementPacka
* <!-- end-user-doc -->
* @generated
*/
- public EReference getIfStatement_UpperIf() {
- return (EReference)ifStatementEClass.getEStructuralFeatures().get(1);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
public EReference getIfStatement_ElseIf() {
- return (EReference)ifStatementEClass.getEStructuralFeatures().get(2);
+ return (EReference)ifStatementEClass.getEStructuralFeatures().get(1);
}
/**
@@ -575,16 +575,16 @@ public class StatementPackageImpl extends EPackageImpl implements StatementPacka
fileStatementEClass = createEClass(FILE_STATEMENT);
createEReference(fileStatementEClass, FILE_STATEMENT__FILE_NAME_EXPRESSION);
createEReference(fileStatementEClass, FILE_STATEMENT__OUTLET_NAME_IDENTIFIER);
+ createEAttribute(fileStatementEClass, FILE_STATEMENT__ONCE);
forEachStatementEClass = createEClass(FOR_EACH_STATEMENT);
createEReference(forEachStatementEClass, FOR_EACH_STATEMENT__TARGET);
- createEReference(forEachStatementEClass, FOR_EACH_STATEMENT__SEPERATOR);
+ createEReference(forEachStatementEClass, FOR_EACH_STATEMENT__SEPARATOR);
createEReference(forEachStatementEClass, FOR_EACH_STATEMENT__VARIABLE);
createEReference(forEachStatementEClass, FOR_EACH_STATEMENT__ITERATOR_NAME);
ifStatementEClass = createEClass(IF_STATEMENT);
createEReference(ifStatementEClass, IF_STATEMENT__CONDITION);
- createEReference(ifStatementEClass, IF_STATEMENT__UPPER_IF);
createEReference(ifStatementEClass, IF_STATEMENT__ELSE_IF);
letStatementEClass = createEClass(LET_STATEMENT);
@@ -668,16 +668,16 @@ public class StatementPackageImpl extends EPackageImpl implements StatementPacka
initEClass(fileStatementEClass, FileStatement.class, "FileStatement", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getFileStatement_FileNameExpression(), theExpressionPackage.getAbstractExpression(), null, "fileNameExpression", null, 0, 1, FileStatement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getFileStatement_OutletNameIdentifier(), theXpand3Package.getIdentifier(), null, "outletNameIdentifier", null, 0, 1, FileStatement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getFileStatement_Once(), ecorePackage.getEBoolean(), "once", null, 0, 1, FileStatement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(forEachStatementEClass, ForEachStatement.class, "ForEachStatement", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getForEachStatement_Target(), theExpressionPackage.getAbstractExpression(), null, "target", null, 0, 1, ForEachStatement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getForEachStatement_Seperator(), theExpressionPackage.getAbstractExpression(), null, "seperator", null, 0, 1, ForEachStatement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getForEachStatement_Separator(), theExpressionPackage.getAbstractExpression(), null, "separator", null, 0, 1, ForEachStatement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getForEachStatement_Variable(), theXpand3Package.getIdentifier(), null, "variable", null, 0, 1, ForEachStatement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getForEachStatement_IteratorName(), theXpand3Package.getIdentifier(), null, "iteratorName", null, 0, 1, ForEachStatement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(ifStatementEClass, IfStatement.class, "IfStatement", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getIfStatement_Condition(), theExpressionPackage.getAbstractExpression(), null, "condition", null, 0, 1, IfStatement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getIfStatement_UpperIf(), this.getIfStatement(), null, "upperIf", null, 0, 1, IfStatement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getIfStatement_ElseIf(), this.getIfStatement(), null, "elseIf", null, 0, 1, IfStatement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(letStatementEClass, LetStatement.class, "LetStatement", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/validation/FileStatementValidator.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/validation/FileStatementValidator.java
index 835d810..c4ac245 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/validation/FileStatementValidator.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/validation/FileStatementValidator.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: FileStatementValidator.java,v 1.4 2008/03/12 09:54:30 jkohnlein Exp $
+ * $Id: FileStatementValidator.java,v 1.5 2008/03/13 11:41:50 sefftinge Exp $
*/
package org.eclipse.xpand3.statement.validation;
@@ -21,6 +21,4 @@ public interface FileStatementValidator {
boolean validateFileNameExpression(AbstractExpression value);
boolean validateOutletNameIdentifier(Identifier value);
-
- boolean validateOnce(boolean value);
}
diff --git a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/validation/ForEachStatementValidator.java b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/validation/ForEachStatementValidator.java
index e188255..caefab0 100644
--- a/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/validation/ForEachStatementValidator.java
+++ b/plugins/org.eclipse.xpand3/emf-gen/org/eclipse/xpand3/statement/validation/ForEachStatementValidator.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: ForEachStatementValidator.java,v 1.4 2008/03/12 09:54:30 jkohnlein Exp $
+ * $Id: ForEachStatementValidator.java,v 1.5 2008/03/13 11:41:50 sefftinge Exp $
*/
package org.eclipse.xpand3.statement.validation;
@@ -20,8 +20,6 @@ public interface ForEachStatementValidator {
boolean validate();
boolean validateTarget(AbstractExpression value);
- boolean validateSeparator(AbstractExpression value);
-
boolean validateSeperator(AbstractExpression value);
boolean validateVariable(Identifier value);
boolean validateIteratorName(Identifier value);
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
deleted file mode 100644
index cef4752..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/DeclarationsContributor.java
+++ /dev/null
@@ -1,49 +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;
-
-import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
-import org.eclipse.xpand3.staticTypesystem.DeclaredFunction;
-import org.eclipse.xpand3.staticTypesystem.DeclaredType;
-
-/**
- * @author Sven Efftinge
- *
- */
-public interface DeclarationsContributor {
-
- /**
- * this method is invoked during setup of this contributor.
- * @param the type system to be used for resolving type and function references.
- */
- void setTypeSystemFactory(TypeSystemFactory tsf);
-
- /**
- * 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);
-
- /**
- * 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/xpand3/analyzation/GenericsUtil.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/GenericsUtil.java
new file mode 100644
index 0000000..7b1c050
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/GenericsUtil.java
@@ -0,0 +1,73 @@
+/**
+ * <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;
+
+import java.util.Arrays;
+
+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.VoidType;
+import org.eclipse.xpand3.staticTypesystem.WildcardType;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class GenericsUtil {
+ private final static StaticTypesystemFactory FACTORY = StaticTypesystemFactory.eINSTANCE;
+ /**
+ *
+ */
+ private static final VoidType VOID_TYPE = FACTORY.createVoidType();
+
+ public static WildcardType wildCardWithLower(AbstractTypeReference... lowerBounds) {
+ WildcardType wildCard = wildCard();
+ for (AbstractTypeReference abstractTypeReference : lowerBounds) {
+ wildCard.getLowerBounds().add(abstractTypeReference);
+ }
+ return wildCard;
+ }
+
+ public static WildcardType wildCard(AbstractTypeReference... upperBounds) {
+ WildcardType wildCard = FACTORY.createWildcardType();
+ for (AbstractTypeReference abstractTypeReference : upperBounds) {
+ wildCard.getUpperBounds().add(abstractTypeReference);
+ }
+ return wildCard;
+ }
+
+ public static Type typeRef(DeclaredType declaredType, AbstractTypeReference... actualArguments) {
+ Type type = FACTORY.createType();
+ type.setDeclaredType(declaredType);
+ type.getActualTypeArguments().addAll(Arrays.asList(actualArguments));
+ return type;
+ }
+
+ public static VoidType voidType() {
+ return VOID_TYPE;
+ }
+
+ public static FunctionType functionTypeRef(DeclaredFunction declaredFunction, AbstractTypeReference... actualArguments) {
+ FunctionType type = FACTORY.createFunctionType();
+ type.setDeclaredFunction(declaredFunction);
+ type.getActualTypeArguments().addAll(Arrays.asList(actualArguments));
+ return type;
+ }
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/LanguageSpecificDeclarationContributorFactory.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/LanguageSpecificTypeSystemFactory.java
index 3dbabc5..a8ee915 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/LanguageSpecificDeclarationContributorFactory.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/LanguageSpecificTypeSystemFactory.java
@@ -20,7 +20,7 @@ package org.eclipse.xpand3.analyzation;
* @author Sven Efftinge
*
*/
-public interface LanguageSpecificDeclarationContributorFactory {
+public interface LanguageSpecificTypeSystemFactory {
/**
* gives the middle end a way to declare if it can and wants to handle a given
* source file / resource. If and only if it returns true, it will be asked for
@@ -33,5 +33,5 @@ public interface LanguageSpecificDeclarationContributorFactory {
* @param resourceName
* @return
*/
- DeclarationsContributor createDeclarationContributor(String resourceName);
+ TypeSystem createTypeSystem(String resourceName);
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/TypeSystem.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/TypeSystem.java
index 0975569..264014b 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/TypeSystem.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/TypeSystem.java
@@ -15,13 +15,10 @@
*/
package org.eclipse.xpand3.analyzation;
-import java.util.List;
-
import org.eclipse.xpand3.analyzation.typesystem.builtin.BuiltinTypeSystem;
import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
-import org.eclipse.xpand3.staticTypesystem.FunctionType;
-import org.eclipse.xpand3.staticTypesystem.Type;
-import org.eclipse.xpand3.staticTypesystem.WildcardType;
+import org.eclipse.xpand3.staticTypesystem.DeclaredFunction;
+import org.eclipse.xpand3.staticTypesystem.DeclaredType;
/**
* @author Sven Efftinge
@@ -35,6 +32,7 @@ public interface TypeSystem {
final String COLLECTION = "Collection";
final String SET = "Set";
final String LIST = "List";
+ final String MAP = "Map";
// Datatypes
final String BOOLEAN = "Boolean";
@@ -45,18 +43,32 @@ public interface TypeSystem {
// reflection layer types
final String FEATURE = "Feature";
final String TYPE = "Type";
- final String OPERATION = "Operation";
+ final String FUNCTION = "Function";
final String PROPERTY = "Property";
final String STATIC_PROPERTY = "StaticProperty";
- final TypeSystem BUILTIN_TYPESYSTEM = new BuiltinTypeSystem(null);
+ final BuiltinTypeSystem BUILTIN_TYPESYSTEM = new BuiltinTypeSystem();
- WildcardType wildCard(AbstractTypeReference...upperBounds);
- WildcardType wildCardWithLower(AbstractTypeReference...lowerBounds);
+ /**
+ * 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);
- Type typeForName(String name, AbstractTypeReference...typeArguments);
+ /**
+ * 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);
- FunctionType functionForNameAndParameterTypes(String name, AbstractTypeReference...parameterTypes);
- FunctionType functionForName(String name, List<AbstractTypeReference> parameterTypes, AbstractTypeReference...typeArguments);
+ /**
+ * this method is invoked during setup of this contributor.
+ * @param the type system to be used for resolving type and function references.
+ */
+ void setTypeSystemFactory(TypeSystemFactory tsf);
}
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 f9247bc..6ebe79c 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,7 +18,6 @@ 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;
@@ -30,36 +29,31 @@ import org.eclipse.xtend.backend.util.Cache;
*/
public class TypeSystemFactory {
- private final static Set<LanguageSpecificDeclarationContributorFactory> factories = new HashSet<LanguageSpecificDeclarationContributorFactory>();
- public static void registerLanguageSpecificFactory(LanguageSpecificDeclarationContributorFactory factory) {
+ private static Set<LanguageSpecificTypeSystemFactory> factories = new HashSet<LanguageSpecificTypeSystemFactory>();
+
+ public void registerLanguageSpecificFactory(LanguageSpecificTypeSystemFactory factory) {
factories.add(factory);
}
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;
+ protected TypeSystem create(String namespace) {
+ for (LanguageSpecificTypeSystemFactory factory : factories) {
+ if (factory.canHandle(namespace)) {
+ TypeSystem typeSystem = factory.createTypeSystem(namespace);
+ typeSystem.setTypeSystemFactory(TypeSystemFactory.this);
+ return typeSystem;
+ }
+ }
+ return null;
}};
public TypeSystem getTypeSystem(String resourceName) {
return cache.get(resourceName);
}
- public TypeSystem getBuiltInTypeSystem() {
+ public BuiltinTypeSystem getBuiltInTypeSystem() {
return BuiltinTypeSystem.BUILTIN_TYPESYSTEM;
}
- public DeclarationsContributor createDeclarationContributor(String namespace) {
- for (LanguageSpecificDeclarationContributorFactory factory : factories) {
- if (factory.canHandle(namespace)) {
- return factory.createDeclarationContributor(namespace);
- }
- }
- return null;
- }
-
-
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/AbstractTypeSystemImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/AbstractTypeSystemImpl.java
deleted file mode 100644
index de33f8f..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/AbstractTypeSystemImpl.java
+++ /dev/null
@@ -1,53 +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;
-
-import org.eclipse.xpand3.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/xpand3/analyzation/typesystem/CompositeTypeSystemImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/CompositeTypeSystemImpl.java
deleted file mode 100644
index 6e7d017..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/CompositeTypeSystemImpl.java
+++ /dev/null
@@ -1,89 +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;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.xpand3.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<TypeSystem> delegates = null;
-
- public CompositeTypeSystemImpl() {
- }
-
- public void addTypeSystem(TypeSystem ts) {
- this.delegates.add(ts);
- }
-
- /*
- * (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) {
- List<FunctionType> possibilities = new ArrayList<FunctionType>();
- for (TypeSystem ts : delegates) {
- FunctionType functionType = ts.functionForName(name, parameterTypes, typeArguments);
- if (functionType!=null)
- possibilities.add(functionType);
- }
- if (possibilities.isEmpty())
- return null;
- //TODO sort by specialization
- return possibilities.get(0);
- }
-
- /*
- * (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));
- }
-
- /*
- * (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/xpand3/analyzation/typesystem/TypeSystemImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/TypeSystemImpl.java
deleted file mode 100644
index 0917923..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/TypeSystemImpl.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.xpand3.analyzation.typesystem;
-
-import java.util.Arrays;
-import java.util.List;
-
-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.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/xpand3/analyzation/typesystem/builtin/BuiltinTypeSystem.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/builtin/BuiltinTypeSystem.java
index 3d93977..becae55 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
@@ -17,30 +17,35 @@ package org.eclipse.xpand3.analyzation.typesystem.builtin;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EFactory;
import org.eclipse.emf.ecore.resource.Resource;
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;
import org.eclipse.xpand3.staticTypesystem.DeclaredType;
import org.eclipse.xpand3.staticTypesystem.Model;
import org.eclipse.xpand3.staticTypesystem.StaticTypesystemPackage;
import org.eclipse.xpand3.util.LoaderFactory;
+import org.eclipse.xtend.backend.common.BackendType;
+import org.eclipse.xtend.backend.common.Function;
+import org.eclipse.xtend.backend.common.Property;
+import org.eclipse.xtend.backend.common.StaticProperty;
/**
* @author Sven Efftinge
*
*/
-public class BuiltinTypeSystem extends TypeSystemImpl implements TypeSystem {
+public class BuiltinTypeSystem implements TypeSystem {
private static Map<String, DeclaredType> types = new HashMap<String, DeclaredType>();
static {
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
@@ -59,25 +64,62 @@ public class BuiltinTypeSystem extends TypeSystemImpl implements TypeSystem {
throw new RuntimeException(e);
}
}
- /**
- * @param contributor
- */
- public BuiltinTypeSystem(DeclarationsContributor contributor) {
- super(new DeclarationsContributor() {
+
+ public DeclaredType getBuiltinTypeForJavaClass(Class<?> cls) {
+ if (List.class.isAssignableFrom (cls))
+ return types.get(LIST);
+ if (Set.class.isAssignableFrom(cls))
+ return types.get(SET);
+ if (Collection.class.isAssignableFrom(cls))
+ return types.get(COLLECTION);
+
+ if (Map.class.isAssignableFrom(cls))
+ return types.get(MAP);
+
+ if (CharSequence.class.isAssignableFrom(cls))
+ return types.get(STRING);
+
+ if (cls == Boolean.class || cls == Boolean.TYPE)
+ return types.get(BOOLEAN);
+
+ if (cls == Long.class || cls == Long.TYPE || cls == Integer.TYPE || cls == Integer.class)
+ return types.get(INTEGER);
+ if (cls == Double.class || cls == Double.TYPE)
+ return types.get(REAL);
- public DeclaredFunction functionForName(String name,
- AbstractTypeReference... parameterTypes) {
- return null;
- }
+ if (Function.class.isAssignableFrom(cls))
+ return types.get(FUNCTION);
+
+ if (BackendType.class.isAssignableFrom(cls))
+ return types.get(TYPE);
+ if (Property.class.isAssignableFrom(cls))
+ return types.get(PROPERTY);
+ if (StaticProperty.class.isAssignableFrom(cls))
+ return types.get(STATIC_PROPERTY);
+ if (Object.class.equals(cls))
+ return types.get(OBJECT);
+ return null;
+ }
- public void setTypeSystemFactory(TypeSystemFactory ts) {
- }
+ /* (non-Javadoc)
+ * @see org.eclipse.xpand3.analyzation.TypeSystem#functionForName(java.lang.String, org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
+ */
+ public DeclaredFunction functionForName(String name,
+ AbstractTypeReference... parameterTypes) {
+ return null;
+ }
- public DeclaredType typeForName(String name) {
- return types.get(name);
- }
-
- });
+ /* (non-Javadoc)
+ * @see org.eclipse.xpand3.analyzation.TypeSystem#setTypeSystemFactory(org.eclipse.xpand3.analyzation.TypeSystemFactory)
+ */
+ public void setTypeSystemFactory(TypeSystemFactory tsf) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xpand3.analyzation.TypeSystem#typeForName(java.lang.String)
+ */
+ public DeclaredType typeForName(String name) {
+ return types.get(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
deleted file mode 100644
index 7dbbf91..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaDeclarationsContributor.java
+++ /dev/null
@@ -1,83 +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.java;
-
-import java.util.HashMap;
-import java.util.Map;
-
-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.DeclaredType;
-import org.eclipse.xpand3.util.LoaderFactory;
-
-/**
- * @author Sven Efftinge
- *
- */
-public class JavaDeclarationsContributor implements DeclarationsContributor {
-
- private Map<String, DeclaredType> types = new HashMap<String, DeclaredType>();
-
- private TypeSystemFactory typeSystemFactory = null;
-
- private Class<?> cls;
-
- /**
- *
- */
- public JavaDeclarationsContributor(String importedNamespace) {
- this.cls = LoaderFactory.getClassLoader(this).loadClass(importedNamespace);
- if (cls==null) {
- throw new IllegalArgumentException("Couldn't find Java Class '"+importedNamespace+"'");
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.xand3.analyzation.typesystem.Xpand3DeclarationsResource#setTypeSystem(org.eclipse.xand3.analyzation.TypeSystem)
- */
- public void setTypeSystemFactory(TypeSystemFactory tsf) {
- this.typeSystemFactory = tsf;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.xand3.analyzation.typesystem.Xpand3DeclarationsResource#getReferencedResources()
- */
- public String[] getReferencedContributors() {
- 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.DeclarationsContributor#functionForName(java.lang.String, org.eclipse.xpand3.staticTypesystem.AbstractTypeReference[])
- */
- public DeclaredFunction functionForName(String name,
- AbstractTypeReference... parameterTypes) {
- return null;
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystem.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystem.java
new file mode 100644
index 0000000..b7354b3
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystem.java
@@ -0,0 +1,391 @@
+/**
+ * <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.java;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.TypeVariable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.xpand3.analyzation.GenericsUtil;
+import org.eclipse.xpand3.analyzation.TypeSystem;
+import org.eclipse.xpand3.analyzation.TypeSystemFactory;
+import org.eclipse.xpand3.analyzation.typesystem.util.PolymorphicResolver;
+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.DeclaredTypeParameter;
+import org.eclipse.xpand3.staticTypesystem.StaticTypesystemFactory;
+import org.eclipse.xpand3.staticTypesystem.Type;
+import org.eclipse.xpand3.util.CreateCache;
+import org.eclipse.xtend.backend.util.ErrorHandler;
+import org.eclipse.xtend.middleend.javaannotations.M2tNoFunction;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class JavaTypeSystem implements TypeSystem {
+
+ private CreateCache<String, DeclaredType> types = new CreateCache<String, DeclaredType>() {
+ @Override
+ protected DeclaredType create(String key) {
+ if (key.equals(cls.getSimpleName())) {
+ return StaticTypesystemFactory.eINSTANCE.createDeclaredType();
+ }
+ return null;
+ }
+
+ @Override
+ protected void initialize(String key, DeclaredType value) {
+ initializeDeclaredType(value, key);
+ }
+ };
+
+ private TypeSystemFactory typeSystemFactory = null;
+ private Class<?> cls;
+
+ /**
+ *
+ */
+ public JavaTypeSystem(Class<?> javaClass) {
+ if (javaClass == null) {
+ throw new IllegalArgumentException("javaClass");
+ }
+ this.cls = javaClass;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xand3.analyzation.typesystem.Xpand3DeclarationsResource#setTypeSystem(org.eclipse.xand3.analyzation.TypeSystem)
+ */
+ public void setTypeSystemFactory(TypeSystemFactory tsf) {
+ this.typeSystemFactory = tsf;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor#typeForName(java.lang.String)
+ */
+ public DeclaredType typeForName(String name) {
+ return types.get(name);
+ }
+
+ /**
+ * @param name
+ * @return
+ */
+ private DeclaredType initializeDeclaredType(DeclaredType dt, String name) {
+ dt.setName(name);
+ TypeVariable<?>[] typeParameters = cls.getTypeParameters();
+ for (TypeVariable<?> typeVariable : typeParameters) {
+ DeclaredTypeParameter dtp = StaticTypesystemFactory.eINSTANCE
+ .createDeclaredTypeParameter();
+ dtp.setName(typeVariable.getName());
+ dtp.getUpperBounds().addAll(toTypeRefs(typeVariable.getBounds()));
+ dt.getDeclaredTypeParameters().add(dtp);
+ }
+
+ // supertypes
+ if (cls.getGenericSuperclass() != null
+ && !cls.getSuperclass().equals(Object.class))
+ dt.getSuperTypes().add(toTypeRef(cls.getGenericSuperclass()));
+ dt.getSuperTypes().addAll(toTypeRefs(cls.getGenericInterfaces()));
+ if (dt.getSuperTypes().isEmpty()) {
+ DeclaredType objectType = typeSystemFactory.getBuiltInTypeSystem()
+ .typeForName(TypeSystem.OBJECT);
+ dt.getSuperTypes().add(GenericsUtil.typeRef(objectType));
+ }
+
+ // properties
+ try {
+ PropertyDescriptor[] propertyDescriptors = Introspector
+ .getBeanInfo(cls).getPropertyDescriptors();
+ for (PropertyDescriptor pd : propertyDescriptors) {
+ if (getDeclaringClass(pd) != cls)
+ continue;
+ DeclaredProperty dp = StaticTypesystemFactory.eINSTANCE
+ .createDeclaredProperty();
+ dp.setName(pd.getName());
+ dp.setType(toTypeRef(getGenericType(pd)));
+ dt.getProperties().add(dp);
+ }
+ } catch (IntrospectionException e) {
+ ErrorHandler.handle(e);
+ return null;
+ }
+
+ // static properties
+ Field[] fields = cls.getFields();
+ for (Field field : fields) {
+ if (Modifier.isPublic(field.getModifiers())) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ DeclaredStaticProperty dsp = StaticTypesystemFactory.eINSTANCE
+ .createDeclaredStaticProperty();
+ dsp.setName(field.getName());
+ dsp.setType((Type) toTypeRef(field.getGenericType()));
+ dt.getStaticProperties().add(dsp);
+ } else {
+ // DeclaredProperty dp = StaticTypesystemFactory.eINSTANCE
+ // .createDeclaredProperty();
+ // dp.setName(field.getName());
+ // dp.setType(toTypeRef(field.getGenericType()));
+ // dt.getProperties().add(dp);
+ }
+ }
+ }
+ return dt;
+ }
+
+ /**
+ * @param pd
+ * @return
+ */
+ private java.lang.reflect.Type getGenericType(PropertyDescriptor pd) {
+ if (pd.getReadMethod() != null)
+ return pd.getReadMethod().getGenericReturnType();
+
+ return pd.getWriteMethod().getGenericParameterTypes()[0];
+ }
+
+ private Class<?> getDeclaringClass(PropertyDescriptor pd) {
+ if (pd.getReadMethod() != null)
+ return pd.getReadMethod().getDeclaringClass();
+
+ return pd.getWriteMethod().getDeclaringClass();
+ }
+
+ /**
+ * @param bounds
+ * @return
+ */
+ private List<? extends AbstractTypeReference> toTypeRefs(
+ java.lang.reflect.Type[] bounds) {
+ List<AbstractTypeReference> result = new ArrayList<AbstractTypeReference>();
+ for (java.lang.reflect.Type jt : bounds) {
+ result.add(toTypeRef(jt));
+ }
+ return result;
+ }
+
+ /**
+ * @param genericSuperclass
+ * @return
+ */
+ private AbstractTypeReference toTypeRef(java.lang.reflect.Type type) {
+ if (type instanceof Class<?>) {
+ Class<?> c = (Class<?>) type;
+ DeclaredType dt = typeSystemFactory.getBuiltInTypeSystem()
+ .getBuiltinTypeForJavaClass((Class<?>) type);
+ if (dt != null) {
+ DeclaredType declaredType = typeSystemFactory
+ .getBuiltInTypeSystem().typeForName(dt.getName());
+ return GenericsUtil.typeRef(declaredType);
+ }
+ TypeSystem typeSystem = typeSystemFactory
+ .getTypeSystem(c.getName());
+ DeclaredType declaredType = typeSystem.typeForName(c
+ .getSimpleName());
+ return GenericsUtil.typeRef(declaredType);
+ } else if (type instanceof TypeVariable) {
+ TypeVariable<?> tv = (TypeVariable<?>) type;
+ Object genericDeclaration = tv.getGenericDeclaration();
+ if (genericDeclaration instanceof Class) {
+ Class<?> c = (Class<?>) genericDeclaration;
+ DeclaredType dt = getDeclaredTypeForJClass(c);
+ EList<DeclaredTypeParameter> parameters = dt
+ .getDeclaredTypeParameters();
+ for (DeclaredTypeParameter declaredTypeParameter : parameters) {
+ if (declaredTypeParameter.getName().equals(tv.getName())) {
+ org.eclipse.xpand3.staticTypesystem.TypeVariable newTv = StaticTypesystemFactory.eINSTANCE
+ .createTypeVariable();
+ newTv.setDeclaredTypeParameter(declaredTypeParameter);
+ return newTv;
+ }
+ }
+ } else if (genericDeclaration instanceof Method) {
+ Method m = (Method) genericDeclaration;
+ DeclaredFunction f = functions.get(m);
+ EList<DeclaredTypeParameter> parameters = f
+ .getDeclaredTypeParameters();
+ for (DeclaredTypeParameter declaredTypeParameter : parameters) {
+ if (declaredTypeParameter.getName().equals(tv.getName())) {
+ org.eclipse.xpand3.staticTypesystem.TypeVariable newTv = StaticTypesystemFactory.eINSTANCE
+ .createTypeVariable();
+ newTv.setDeclaredTypeParameter(declaredTypeParameter);
+ return newTv;
+ }
+ }
+ }
+ throw new IllegalStateException(
+ "Couldn't find declaration for type variable "
+ + tv.getName());
+ } else if (type instanceof java.lang.reflect.ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) type;
+ java.lang.reflect.Type rawType = pt.getRawType();
+ Type t = StaticTypesystemFactory.eINSTANCE.createType();
+ if (rawType instanceof Class) {
+ DeclaredType dt = getDeclaredTypeForJClass((Class<?>) rawType);
+ t.setDeclaredType(dt);
+ } else {
+ throw new IllegalStateException("missing implementation for "
+ + rawType.getClass());
+ }
+ t.getActualTypeArguments().addAll(
+ toTypeRefs(pt.getActualTypeArguments()));
+ return t;
+ }
+ throw new IllegalArgumentException("toTypeRef not implemented for "
+ + type.getClass().getSimpleName() + " - " + type);
+ }
+
+ /**
+ * @param c
+ * @return
+ */
+ private DeclaredType getDeclaredTypeForJClass(Class<?> c) {
+ DeclaredType declaredType = typeSystemFactory.getBuiltInTypeSystem()
+ .getBuiltinTypeForJavaClass(c);
+ if (declaredType != null) {
+ return declaredType;
+ }
+ return typeSystemFactory.getTypeSystem(c.getName()).typeForName(
+ c.getSimpleName());
+ }
+
+ /**
+ * this implementation maps Java methods to functions. Example : interface
+ * Foo<T extends Bar> { T foo(T x); }
+ *
+ * will be mapped to a function with the following signature:
+ *
+ * <T extends Bar> T foo(Foo<T> this, T x)
+ *
+ */
+ public DeclaredFunction functionForName(String name,
+ AbstractTypeReference... parameterTypes) {
+ if (functions.isEmpty()) {
+ initialize();
+ }
+ Collection<DeclaredFunction> values = functions.getMap().values();
+ return PolymorphicResolver.findFunction(values, name, parameterTypes,
+ null);
+ }
+
+ /**
+ *
+ */
+ private void initialize() {
+ Method[] methods = cls.getDeclaredMethods();
+ for (Method method : methods) {
+ if (method.getAnnotation(M2tNoFunction.class) == null) {
+ functions.get(method);
+ }
+ }
+ }
+
+ private final CreateCache<Method, DeclaredFunction> functions = new CreateCache<Method, DeclaredFunction>() {
+
+ @Override
+ protected DeclaredFunction create(Method key) {
+ return StaticTypesystemFactory.eINSTANCE.createDeclaredFunction();
+ }
+
+ @Override
+ protected void initialize(Method method, DeclaredFunction f) {
+ f.setName(method.getName());
+ // parameters
+
+ // if not static add all type parameters from declaring type
+ if (!Modifier.isStatic(method.getModifiers())) {
+ org.eclipse.xpand3.staticTypesystem.DeclaredParameter dp = StaticTypesystemFactory.eINSTANCE
+ .createDeclaredParameter();
+ dp.setName("this");
+ Class<?> declaringClass = method.getDeclaringClass();
+ DeclaredType dt = getDeclaredTypeForJClass(declaringClass);
+ Type typeRef = StaticTypesystemFactory.eINSTANCE.createType();
+ typeRef.setDeclaredType(dt);
+ for (DeclaredTypeParameter dtp : dt.getDeclaredTypeParameters()) {
+ // clone the declared type parameters
+ DeclaredTypeParameter copy = StaticTypesystemFactory.eINSTANCE
+ .createDeclaredTypeParameter();
+ copy.setName(dtp.getName());
+ copy.getUpperBounds()
+ .addAll(cloneAll(dtp.getUpperBounds()));
+ f.getDeclaredTypeParameters().add(copy);
+ // and create a type var for the first argument of the
+ // function
+ org.eclipse.xpand3.staticTypesystem.TypeVariable var = StaticTypesystemFactory.eINSTANCE
+ .createTypeVariable();
+ var.setDeclaredTypeParameter(copy);
+ typeRef.getActualTypeArguments().add(var);
+ }
+ dp.setType(typeRef);
+ f.getDeclaredParameters().add(dp);
+ }
+ // add type parameters declared for the method
+ TypeVariable<Method>[] typeParameters = method.getTypeParameters();
+ for (TypeVariable<Method> tv : typeParameters) {
+ // clone the declared type parameters
+ DeclaredTypeParameter copy = StaticTypesystemFactory.eINSTANCE
+ .createDeclaredTypeParameter();
+ copy.setName(tv.getName());
+ copy.getUpperBounds().addAll(toTypeRefs(tv.getBounds()));
+ f.getDeclaredTypeParameters().add(copy);
+ }
+ // now add the return type
+ java.lang.reflect.Type returnType = method.getGenericReturnType();
+ f.setReturnType(toTypeRef(returnType));
+
+ // now the other parameters
+ java.lang.reflect.Type[] pts = method.getGenericParameterTypes();
+ int i = 1;
+ for (java.lang.reflect.Type pt : pts) {
+ org.eclipse.xpand3.staticTypesystem.DeclaredParameter dp1 = StaticTypesystemFactory.eINSTANCE
+ .createDeclaredParameter();
+ f.getDeclaredParameters().add(dp1);
+ dp1.setName("arg" + (i++));
+ dp1.setType(toTypeRef(pt));
+ }
+ f.setReturnType(toTypeRef(method.getGenericReturnType()));
+
+ }
+
+ };
+
+ /**
+ * @param upperBounds
+ * @return
+ */
+ private Collection<? extends AbstractTypeReference> cloneAll(
+ EList<AbstractTypeReference> upperBounds) {
+ return new EcoreUtil.Copier().copyAll(upperBounds);
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystemFactory.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystemFactory.java
new file mode 100644
index 0000000..291b765
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystemFactory.java
@@ -0,0 +1,59 @@
+/**
+ * <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.java;
+
+import org.eclipse.xpand3.analyzation.LanguageSpecificTypeSystemFactory;
+import org.eclipse.xpand3.analyzation.TypeSystem;
+import org.eclipse.xpand3.util.LoaderFactory;
+import org.eclipse.xtend.backend.util.Cache;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class JavaTypeSystemFactory implements LanguageSpecificTypeSystemFactory {
+
+ private Object ctx;
+ private Cache<String,JavaTypeSystem> typeSystems = new Cache<String, JavaTypeSystem>(){
+
+ @Override
+ protected JavaTypeSystem create(String key) {
+ Class<?> class1 = LoaderFactory.getClassLoader(ctx).loadClass(key);
+ if (class1!=null) {
+ return new JavaTypeSystem(class1);
+ }
+ return null;
+ }};
+
+ public JavaTypeSystemFactory(Object ctx) {
+ this.ctx = ctx;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xpand3.analyzation.LanguageSpecificTypeSystemFactory#canHandle(java.lang.String)
+ */
+ public boolean canHandle(String resourceName) {
+ return LoaderFactory.getClassLoader(ctx).loadClass(resourceName)!=null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xpand3.analyzation.LanguageSpecificTypeSystemFactory#createTypeSystem(java.lang.String)
+ */
+ public TypeSystem createTypeSystem(String resourceName) {
+ return typeSystems.get(resourceName);
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/PolymorphicResolver.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/PolymorphicResolver.java
new file mode 100644
index 0000000..3c42453
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/analyzation/typesystem/util/PolymorphicResolver.java
@@ -0,0 +1,48 @@
+/**
+ * <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 java.util.Collection;
+
+import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
+import org.eclipse.xpand3.staticTypesystem.DeclaredFunction;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class PolymorphicResolver {
+
+ /**
+ * @param values
+ * @param name
+ * @param parameterTypes
+ * @param object
+ */
+ public static DeclaredFunction findFunction(Collection<DeclaredFunction> functions,
+ String name, AbstractTypeReference[] parameterTypes, AbstractTypeReference[] typeArguments) {
+ for (DeclaredFunction f : functions) {
+ if (f.getName().equals(name)) {
+ if (f.getDeclaredParameters().size() == parameterTypes.length) {
+ // TODO check types etc.
+ return f;
+ }
+ }
+ }
+ 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 3dc3c69..0574225 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
@@ -19,23 +19,20 @@ 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
*
*/
public class Xpand3ResourceDeclarationsContributor implements
- DeclarationsContributor {
+ TypeSystem {
private File file = null;
private TypeSystemFactory typeSystemFactory;
@@ -70,35 +67,10 @@ public class Xpand3ResourceDeclarationsContributor implements
AbstractTypeReference[] types = new AbstractTypeReference[def.getParams().size()];
for (int i=0;i<types.length;i++) {
DeclaredParameter declaredParameter = def.getParams().get(i);
- types[i] = getTypeRef(declaredParameter.getType());
}
return types;
}
- /**
- * @param type
- * @return
- */
- private AbstractTypeReference getTypeRef(Identifier type) {
- //TODO type Args
- return getTypeSystem().typeForName(AstUtil.toString(type));
- }
-
- private CompositeTypeSystemImpl ts = null;
- /**
- * @return
- */
- 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 ts;
- }
/**
* @return
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/middlend/XtendFrontendASTConverter.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/middlend/XtendFrontendASTConverter.java
deleted file mode 100644
index 04f741f..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/middlend/XtendFrontendASTConverter.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/**
- * <copyright>
- *
- * Copyright (c) 2002-2007 Kolbware 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:
- * Kolbware, Bernd Kolb - Initial API and implementation
- *
- * </copyright>
- *
- */
-package org.eclipse.xpand3.middlend;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.xpand3.Identifier;
-import org.eclipse.xpand3.SyntaxElement;
-import org.eclipse.xpand3.analyzation.AnalyzeContext;
-import org.eclipse.xpand3.analyzation.TypeSystem;
-import org.eclipse.xpand3.analyzation.AnalyzeContext.Var;
-import org.eclipse.xpand3.expression.AbstractExpression;
-import org.eclipse.xpand3.expression.BooleanLiteral;
-import org.eclipse.xpand3.expression.Case;
-import org.eclipse.xpand3.expression.Cast;
-import org.eclipse.xpand3.expression.ChainExpression;
-import org.eclipse.xpand3.expression.CollectionExpression;
-import org.eclipse.xpand3.expression.ConstructorCallExpression;
-import org.eclipse.xpand3.expression.FeatureCall;
-import org.eclipse.xpand3.expression.GlobalVarExpression;
-import org.eclipse.xpand3.expression.IfExpression;
-import org.eclipse.xpand3.expression.IntegerLiteral;
-import org.eclipse.xpand3.expression.LetExpression;
-import org.eclipse.xpand3.expression.ListLiteral;
-import org.eclipse.xpand3.expression.Literal;
-import org.eclipse.xpand3.expression.NullLiteral;
-import org.eclipse.xpand3.expression.OperationCall;
-import org.eclipse.xpand3.expression.RealLiteral;
-import org.eclipse.xpand3.expression.StringLiteral;
-import org.eclipse.xpand3.expression.SwitchExpression;
-import org.eclipse.xpand3.expression.TypeSelectExpression;
-import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
-import org.eclipse.xpand3.staticTypesystem.FunctionType;
-import org.eclipse.xpand3.staticTypesystem.Type;
-import org.eclipse.xpand3.util.Xpand3Switch;
-import org.eclipse.xtend.backend.common.ExpressionBase;
-import org.eclipse.xtend.backend.common.SourcePos;
-import org.eclipse.xtend.backend.common.StaticProperty;
-import org.eclipse.xtend.backend.expr.CreateUncachedExpression;
-import org.eclipse.xtend.backend.expr.HidingLocalVarDefExpression;
-import org.eclipse.xtend.backend.expr.InitClosureExpression;
-import org.eclipse.xtend.backend.expr.InvocationOnCollectionExpression;
-import org.eclipse.xtend.backend.expr.InvocationOnObjectExpression;
-import org.eclipse.xtend.backend.expr.InvocationOnWhateverExpression;
-import org.eclipse.xtend.backend.expr.ListLiteralExpression;
-import org.eclipse.xtend.backend.expr.LiteralExpression;
-import org.eclipse.xtend.backend.expr.LocalVarEvalExpression;
-import org.eclipse.xtend.backend.expr.NewLocalVarDefExpression;
-import org.eclipse.xtend.backend.expr.PropertyOnCollectionExpression;
-import org.eclipse.xtend.backend.expr.PropertyOnObjectExpression;
-import org.eclipse.xtend.backend.expr.PropertyOnWhateverExpression;
-import org.eclipse.xtend.backend.expr.SequenceExpression;
-import org.eclipse.xtend.backend.syslib.SysLibNames;
-import org.eclipse.xtend.backend.types.builtin.CollectionType;
-import org.eclipse.xtend.backend.types.builtin.ObjectType;
-import org.eclipse.xtend.backend.util.Pair;
-
-/**
- * @author Arno Haase
- * @author Bernd Kolb
- * @author Sven Efftinge
- */
-public class XtendFrontendASTConverter extends Xpand3Switch<>{
-
- private String extensionName;
- private final BackendTypeConverter typeConverter;
- private AnalyzeContext ctx;
- private TypeSystem typeSystem;
-
- public XtendFrontendASTConverter(AnalyzeContext ctx, BackendTypeConverter typeConverter, String extensionName) {
- this.ctx = ctx;
- this.typeConverter = typeConverter;
- this.extensionName = extensionName;
- }
-
-
- public ExpressionBase convert(ConstructorCallExpression expr) {
- return new CreateUncachedExpression(typeConverter.convertToBackendType(expr.getType()), getSourcePos(expr));
- }
-
- public ExpressionBase convert(FeatureCall expr) {
- final SourcePos sourcePos = getSourcePos(expr);
-
- if (expr.getTarget() == null) {
- // 1. check for a static property
- final StaticProperty staticProp = typeConverter.getEnumLiteral(expr.getName());
- if (staticProp != null)
- return new LiteralExpression(staticProp.get(), sourcePos);
-
- // 2. check for a local variable
- if (ctx.getVariable(expr.getName().getValue()) != null)
- return new LocalVarEvalExpression(expr.getName().getValue(), sourcePos);
-
- // 3. check for a type literal
- try {
- return new LiteralExpression(typeConverter.convertToBackendType(expr.getName()), sourcePos);
- } catch (IllegalArgumentException exc) {
- } // do nothing - this means
- // it is not a type literal
-
- // 4. check for "this"
- if (ctx.hasThis()) {
- final ExpressionBase thisExpr = new LocalVarEvalExpression(
- org.eclipse.xtend.backend.common.SyntaxConstants.THIS, sourcePos);
- return createPropertyExpression(thisExpr, ctx.getThis(), expr.getName().getValue(), sourcePos);
- }
-
- throw new IllegalArgumentException("feature call " + expr.toString() + " does not match any feature: "
- + sourcePos);
- } else {
- // evaluate the target and evaluate the property on the result
- return createPropertyExpression(convert(expr.getTarget()), analyze(expr.getTarget()), expr.getName()
- .getValue(), sourcePos);
- }
- }
-
- public ExpressionBase convert(CollectionExpression expr) {
- final SourcePos sourcePos = getSourcePos(expr);
-
- final String functionName = expr.getName().getValue();
-
- final AnalyzeContext oldCtx = ctx;
- ctx = ctx.cloneWith(new AnalyzeContext.Var(BackendTypeConverter.qualify(expr.getEleName()), null) /*
- * TODO
- * ObjectType
- */);
- final ExpressionBase bodyExpr = convert(expr.getClosure());
- ctx = oldCtx;
-
- final InitClosureExpression closureExpr = new InitClosureExpression(
- Arrays.asList(expr.getEleName().getValue()), Arrays.asList(ObjectType.INSTANCE), bodyExpr, sourcePos);
-
- if (expr.getTarget() == null) {
- if (!ctx.hasThis())
- throw new IllegalStateException(functionName + " with neither a target nor an implicit 'this'");
-
- final ExpressionBase thisExpr = new LocalVarEvalExpression(
- org.eclipse.xtend.backend.common.SyntaxConstants.THIS, sourcePos);
- return new InvocationOnObjectExpression(functionName, Arrays.asList(thisExpr, closureExpr), true, sourcePos);
- } else
- return new InvocationOnObjectExpression(functionName,
- Arrays.asList(convert(expr.getTarget()), closureExpr), true, sourcePos);
- }
-
- public ExpressionBase convert(TypeSelectExpression expr) {
- final SourcePos sourcePos = getSourcePos(expr);
-
- final Type t = typeSystem.typeForName(toString(expr.getTypeLiteral()));// TODO
- // type
- // args
- final ExpressionBase typeExpr = new LiteralExpression(typeConverter.convertToBackendType(t), sourcePos);
-
- if (expr.getTarget() == null) {
- if (!ctx.hasThis())
- throw new IllegalStateException("typeSelect with neither a target nor an implicit 'this'");
-
- final ExpressionBase thisExpr = new LocalVarEvalExpression(
- org.eclipse.xtend.backend.common.SyntaxConstants.THIS, sourcePos);
- return new InvocationOnObjectExpression(SysLibNames.TYPE_SELECT, Arrays.asList(thisExpr, typeExpr), true,
- sourcePos);
- } else
- return new InvocationOnObjectExpression(SysLibNames.TYPE_SELECT, Arrays.asList(convert(expr.getTarget()),
- typeExpr), false, sourcePos);
- }
-
- /**
- * @param typeLiteral
- * @return
- */
- private String toString(Identifier id) {
- return BackendTypeConverter.qualify(id);
- }
-
- public ExpressionBase convert(OperationCall expr) {
- final SourcePos sourcePos = getSourcePos(expr);
- final String functionName = transformFunctionName(expr.getName().getValue());
-
- final List<ExpressionBase> params = new ArrayList<ExpressionBase>();
- for (AbstractExpression e : expr.getParams())
- params.add(convert(e));
-
- final List<AbstractTypeReference> paramTypes = new ArrayList<AbstractTypeReference>();
- for (AbstractExpression e : expr.getParams())
- paramTypes.add(analyze(e));
-
- if (expr.getTarget() == null) {
- if (ctx.hasThis()) {
- // if a function matches directly (i.e. without implicitly
- // passing 'this' as a first parameter), that
- // has precedence in matching
- if (hasMatchingOperationCall(functionName, paramTypes.toArray(new AbstractTypeReference[0])))
- return new InvocationOnObjectExpression(functionName, params, false, sourcePos);
- else {
- final ExpressionBase thisExpression = new LocalVarEvalExpression(
- org.eclipse.xtend.backend.common.SyntaxConstants.THIS, sourcePos);
- Var thisVar = ctx.getThis();
- final AbstractTypeReference thisType = thisVar.getValue();
- return createInvocationOnTargetExpression(functionName, thisExpression, thisType, params,
- paramTypes, true, sourcePos);
- }
- } else
- return new InvocationOnObjectExpression(functionName, params, false, sourcePos);
- } else
- return createInvocationOnTargetExpression(functionName, convert(expr.getTarget()),
- analyze(expr.getTarget()), params, paramTypes, true, sourcePos);
- }
-
- public ExpressionBase convert(GlobalVarExpression expr) {
- // TODO: To be impl
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public ExpressionBase convert(IfExpression expr) {
- final ExpressionBase elseExpr = (expr.getElsePart() != null) ? convert(expr.getElsePart())
- : new LiteralExpression(null, getSourcePos(expr));
-
- return new org.eclipse.xtend.backend.expr.IfExpression(convert(expr.getCondition()),
- convert(expr.getThenPart()), elseExpr, getSourcePos(expr));
- }
-
- public ExpressionBase convert(LetExpression expr) {
- final ExpressionBase varExpr = convert(expr.getVarExpression());
- final AbstractTypeReference varType = analyze(expr.getVarExpression());
-
- final AnalyzeContext oldCtx = ctx;
- String varName = toString(expr.getVarName());
- ctx = ctx.cloneWith(new AnalyzeContext.Var(varName, varType));
-
- try {
- if (oldCtx.getVariable(varName) != null)
- return new HidingLocalVarDefExpression(varName, varExpr, convert(expr.getTargetExpression()),
- getSourcePos(expr));
- else
- return new NewLocalVarDefExpression(varName, varExpr, convert(expr.getTargetExpression()),
- getSourcePos(expr));
- } finally {
- ctx = oldCtx;
- }
- }
-
- public ExpressionBase convert(SwitchExpression expr) {
- final List<Pair<ExpressionBase, ExpressionBase>> cases = new ArrayList<Pair<ExpressionBase, ExpressionBase>>();
- for (Case c : expr.getCases())
- cases.add(new Pair<ExpressionBase, ExpressionBase>(convert(c.getCondition()), convert(c.getThenPart())));
-
- return new org.eclipse.xtend.backend.expr.SwitchExpression(convert(expr.getSwitchExpr()), cases, convert(expr
- .getDefaultExpr()), getSourcePos(expr));
- }
-
- /**
- * transform built-in operator names from the old to the new special names
- */
- private String transformFunctionName(String functionName) {
- if ("+".equals(functionName))
- return SysLibNames.OPERATOR_PLUS;
- if ("-".equals(functionName))
- return SysLibNames.OPERATOR_MINUS;
- if ("*".equals(functionName))
- return SysLibNames.OPERATOR_MULT;
- if ("/".equals(functionName))
- return SysLibNames.OPERATOR_DIV;
- if ("%".equals(functionName))
- return SysLibNames.OPERATOR_MOD;
-
- if ("==".equals(functionName))
- return SysLibNames.OPERATOR_EQUALS;
- if ("!=".equals(functionName))
- return SysLibNames.OPERATOR_NOT_EQUALS;
- if ("<".equals(functionName))
- return SysLibNames.OPERATOR_LESS;
- if ("<=".equals(functionName))
- return SysLibNames.OPERATOR_LESS_OR_EQUALS;
- if (">=".equals(functionName))
- return SysLibNames.OPERATOR_GREATER_OR_EQUALS;
- if (">".equals(functionName))
- return SysLibNames.OPERATOR_GREATER;
-
- if ("!".equals(functionName))
- return SysLibNames.OPERATOR_NOT;
-
- if ("subString".equals(functionName))
- return SysLibNames.SUBSTRING;
- if ("replaceAll".equals(functionName))
- return SysLibNames.REPLACE_ALL_REGEX;
-
- return functionName;
- }
-
- private AbstractTypeReference analyze(AbstractExpression target) {
- // TODO: To be impl
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- private ExpressionBase createInvocationOnTargetExpression(String functionName, ExpressionBase targetExpression,
- AbstractTypeReference targetType, List<ExpressionBase> params, List<AbstractTypeReference> paramTypes,
- boolean isMethodStyle, SourcePos sourcePos) {
- final List<ExpressionBase> paramsWithoutFirst = params;
- final List<ExpressionBase> allParams = new ArrayList<ExpressionBase>();
- allParams.add(targetExpression);
- allParams.addAll(params);
-
- if (isCollectionType(targetType)) {
- paramTypes.add(0, targetType);
- final AbstractTypeReference[] paramTypeArray = paramTypes.toArray(new AbstractTypeReference[0]);
-
- if (hasMatchingOperationCall(functionName, paramTypeArray))
- // check if there is a function that directly matches the
- // collection
- return new InvocationOnObjectExpression(functionName, allParams, true, sourcePos);
- else
- // otherwise, do a 'collect' and call the function on all
- // elements of the collection
- return new InvocationOnCollectionExpression(targetExpression, functionName, paramsWithoutFirst,
- sourcePos);
- }
-
- if (isObjectType(targetType))
- // if the static type is "Object", we do not know if it is a
- // collection, so we do the logic at runtime
- return new InvocationOnWhateverExpression(functionName, allParams, isMethodStyle, sourcePos);
-
- // otherwise we know that it is not a collection and can avoid repeating
- // this logic at runtime
- return new InvocationOnObjectExpression(functionName, allParams, true, sourcePos);
- }
-
- private boolean hasMatchingOperationCall(String functionName, AbstractTypeReference[] paramTypes) {
- FunctionType functionType = typeSystem.functionForNameAndParameterTypes(functionName, paramTypes);
- if (functionType != null) {
- return true;
- } else {
- return false;
- }
- }
-
- private ExpressionBase createPropertyExpression(ExpressionBase target, Object type, String varName,
- SourcePos sourcePos) {
- if (isCollectionType(type)) {
- if (CollectionType.INSTANCE.getProperties().keySet().contains(varName))
- return new PropertyOnObjectExpression(target, varName, sourcePos);
- else
- return new PropertyOnCollectionExpression(target, varName, sourcePos);
- }
-
- if (isObjectType(type))
- return new PropertyOnWhateverExpression(target, varName, sourcePos);
-
- return new PropertyOnObjectExpression(target, varName, sourcePos);
- }
-
- private boolean isObjectType(Object t) {
- // TODO : To be impl
- return true;
- // throw new UnsupportedOperationException("Not yet implemented");
- }
-
- private boolean isCollectionType(Object t) {
- // TODO : To be impl
- return false;
- // throw new UnsupportedOperationException("Not yet implemented");
- }
-
-
-
- private SourcePos getSourcePos(SyntaxElement lit) {
- return new SourcePos(lit.getFileName(), extensionName, lit.getLine());
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/util/CreateCache.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/util/CreateCache.java
new file mode 100644
index 0000000..746ec35
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xpand3/util/CreateCache.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.xpand3.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public abstract class CreateCache<K, V> {
+ private final Map<K, V> _cache = new HashMap<K, V>();
+
+ public V get(K key) {
+ if (_cache.containsKey(key))
+ return _cache.get(key);
+
+ final V result = create(key);
+ _cache.put(key, result);
+ if (result != null)
+ initialize(key, result);
+ return result;
+ }
+
+ protected abstract V create(K key);
+
+ protected abstract void initialize(K key, V value);
+
+ public Map<K, V> getMap() {
+ return _cache;
+ }
+
+ /**
+ * @return
+ */
+ public boolean isEmpty() {
+ return _cache.isEmpty();
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.xtend.middleend.xpand3/META-INF/MANIFEST.MF b/plugins/org.eclipse.xtend.middleend.xpand3/META-INF/MANIFEST.MF
deleted file mode 100644
index de0fcf6..0000000
--- a/plugins/org.eclipse.xtend.middleend.xpand3/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,12 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Xpand3 Plug-in
-Bundle-SymbolicName: org.eclipse.xtend.middleend.xpand3
-Bundle-Version: 1.0.0
-Bundle-Activator: org.eclipse.xtend.middleend.internal.xpand3.Activator
-Import-Package: org.osgi.framework;version="1.3.0"
-Eclipse-LazyStart: true
-Require-Bundle: org.eclipse.emf.mwe.core,
- org.apache.commons.logging,
- org.eclipse.xpand3,
- org.eclipse.xtend.backend
diff --git a/plugins/org.eclipse.xtend.middleend.xpand3/TOBEDELETED.TXT b/plugins/org.eclipse.xtend.middleend.xpand3/TOBEDELETED.TXT
new file mode 100644
index 0000000..8003583
--- /dev/null
+++ b/plugins/org.eclipse.xtend.middleend.xpand3/TOBEDELETED.TXT
@@ -0,0 +1 @@
+moved to org.eclipse.xpand3 \ No newline at end of file
diff --git a/plugins/org.eclipse.xtend.middleend.xpand3/build.properties b/plugins/org.eclipse.xtend.middleend.xpand3/build.properties
deleted file mode 100644
index 34d2e4d..0000000
--- a/plugins/org.eclipse.xtend.middleend.xpand3/build.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
diff --git a/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/Activator.java b/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/Activator.java
deleted file mode 100644
index b090442..0000000
--- a/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/Activator.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * <copyright>
- *
- * Copyright (c) 2002-2007 Kolbware 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:
- * Kolbware, Bernd Kolb - Initial API and implementation
- *
- * </copyright>
- *
- */
-package org.eclipse.xtend.middleend.internal.xpand3;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * @author Bernd Kolb
- *
- */
-public class Activator implements BundleActivator {
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- }
-
-}
diff --git a/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/BackendTypeConverter.java b/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/BackendTypeConverter.java
deleted file mode 100644
index 88ded9c..0000000
--- a/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/BackendTypeConverter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * <copyright>
- *
- * Copyright (c) 2002-2007 Kolbware 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:
- * Kolbware, Bernd Kolb - Initial API and implementation
- *
- * </copyright>
- *
- */
-package org.eclipse.xtend.middleend.internal.xpand3;
-
-import org.eclipse.xpand3.Identifier;
-import org.eclipse.xtend.backend.common.BackendType;
-import org.eclipse.xtend.backend.common.StaticProperty;
-
-/**
- * @author Bernd Kolb
- *
- */
-public class BackendTypeConverter {
-
- public BackendType convertToBackendType(Object ex) {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public StaticProperty getEnumLiteral(String value) {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public StaticProperty getEnumLiteral(Identifier name) {
- return getEnumLiteral(qualify(name));
- }
-
- public static String qualify(Identifier name) {
- return name.getValue();
- }
-
-}
diff --git a/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/SyntaxConstants.java b/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/SyntaxConstants.java
deleted file mode 100644
index a1dead9..0000000
--- a/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/SyntaxConstants.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * <copyright>
- *
- * Copyright (c) 2002-2007 Kolbware 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:
- * Kolbware, Bernd Kolb - Initial API and implementation
- *
- * </copyright>
- *
- */
-package org.eclipse.xtend.middleend.internal.xpand3;
-
-/**
- * @author Bernd Kolb
- *
- */
-public interface SyntaxConstants {
-
- String NS_DELIM = "::";
-
-}
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
deleted file mode 100644
index 37dfbde..0000000
--- a/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/XtendBackendFacade.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * <copyright>
- *
- * Copyright (c) 2002-2007 Kolbware 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:
- * Kolbware, Bernd Kolb - Initial API and implementation
- *
- * </copyright>
- *
- */
-package org.eclipse.xtend.middleend.internal.xpand3;
-
-import java.util.Collections;
-
-import org.eclipse.xpand3.File;
-import org.eclipse.xpand3.analyzation.AnalyzeContext;
-import org.eclipse.xtend.backend.common.BackendTypesystem;
-import org.eclipse.xtend.middleend.MiddleEnd;
-import org.eclipse.xtend.middleend.MiddleEndFactory;
-import org.eclipse.xtend.middleend.plugins.LanguageSpecificMiddleEnd;
-
-/**
- * @author Bernd Kolb
- *
- */
-public class XtendBackendFacade {
-
- private MiddleEnd middleEnd;
- private BackendTypeConverter typeConverter;
- private AnalyzeContext ctx;
- private final String extensionFile;
-
- public XtendBackendFacade(String extensionFile) {
- this.extensionFile = extensionFile;
- middleEnd = MiddleEndFactory.create(findBackendTypeSystem(), Collections.<LanguageSpecificMiddleEnd>emptyList());
-
- // TODO: To be impl
- typeConverter = null;
- ctx = null;
- }
-
- private BackendTypesystem findBackendTypeSystem() {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- private static XtendBackendFacade createForFile(String extensionFile) {
- return new XtendBackendFacade(extensionFile);
- }
-
- private File parse() {
- // TODO: To be impl
- throw new UnsupportedOperationException("Not yet impl");
- }
-}
diff --git a/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/XtendFrontendASTConverter.java b/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/XtendFrontendASTConverter.java
deleted file mode 100644
index a2301d2..0000000
--- a/plugins/org.eclipse.xtend.middleend.xpand3/src/org/eclipse/xtend/middleend/internal/xpand3/XtendFrontendASTConverter.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/**
- * <copyright>
- *
- * Copyright (c) 2002-2007 Kolbware 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:
- * Kolbware, Bernd Kolb - Initial API and implementation
- *
- * </copyright>
- *
- */
-package org.eclipse.xtend.middleend.internal.xpand3;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.xpand3.Identifier;
-import org.eclipse.xpand3.SyntaxElement;
-import org.eclipse.xpand3.analyzation.AnalyzeContext;
-import org.eclipse.xpand3.analyzation.TypeSystem;
-import org.eclipse.xpand3.analyzation.AnalyzeContext.Var;
-import org.eclipse.xpand3.expression.AbstractExpression;
-import org.eclipse.xpand3.expression.BooleanLiteral;
-import org.eclipse.xpand3.expression.Case;
-import org.eclipse.xpand3.expression.Cast;
-import org.eclipse.xpand3.expression.ChainExpression;
-import org.eclipse.xpand3.expression.CollectionExpression;
-import org.eclipse.xpand3.expression.ConstructorCallExpression;
-import org.eclipse.xpand3.expression.FeatureCall;
-import org.eclipse.xpand3.expression.GlobalVarExpression;
-import org.eclipse.xpand3.expression.IfExpression;
-import org.eclipse.xpand3.expression.IntegerLiteral;
-import org.eclipse.xpand3.expression.LetExpression;
-import org.eclipse.xpand3.expression.ListLiteral;
-import org.eclipse.xpand3.expression.Literal;
-import org.eclipse.xpand3.expression.NullLiteral;
-import org.eclipse.xpand3.expression.OperationCall;
-import org.eclipse.xpand3.expression.RealLiteral;
-import org.eclipse.xpand3.expression.StringLiteral;
-import org.eclipse.xpand3.expression.SwitchExpression;
-import org.eclipse.xpand3.expression.TypeSelectExpression;
-import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference;
-import org.eclipse.xpand3.staticTypesystem.FunctionType;
-import org.eclipse.xpand3.staticTypesystem.Type;
-import org.eclipse.xtend.backend.common.ExpressionBase;
-import org.eclipse.xtend.backend.common.SourcePos;
-import org.eclipse.xtend.backend.common.StaticProperty;
-import org.eclipse.xtend.backend.expr.CreateUncachedExpression;
-import org.eclipse.xtend.backend.expr.HidingLocalVarDefExpression;
-import org.eclipse.xtend.backend.expr.InitClosureExpression;
-import org.eclipse.xtend.backend.expr.InvocationOnCollectionExpression;
-import org.eclipse.xtend.backend.expr.InvocationOnObjectExpression;
-import org.eclipse.xtend.backend.expr.InvocationOnWhateverExpression;
-import org.eclipse.xtend.backend.expr.ListLiteralExpression;
-import org.eclipse.xtend.backend.expr.LiteralExpression;
-import org.eclipse.xtend.backend.expr.LocalVarEvalExpression;
-import org.eclipse.xtend.backend.expr.NewLocalVarDefExpression;
-import org.eclipse.xtend.backend.expr.PropertyOnCollectionExpression;
-import org.eclipse.xtend.backend.expr.PropertyOnObjectExpression;
-import org.eclipse.xtend.backend.expr.PropertyOnWhateverExpression;
-import org.eclipse.xtend.backend.expr.SequenceExpression;
-import org.eclipse.xtend.backend.syslib.SysLibNames;
-import org.eclipse.xtend.backend.types.builtin.CollectionType;
-import org.eclipse.xtend.backend.types.builtin.ObjectType;
-import org.eclipse.xtend.backend.util.Pair;
-
-/**
- * @author Bernd Kolb
- *
- */
-public class XtendFrontendASTConverter {
-
- private String extensionName;
- private final BackendTypeConverter typeConverter;
- private AnalyzeContext ctx;
- private TypeSystem typeSystem;
-
- public XtendFrontendASTConverter(AnalyzeContext ctx, BackendTypeConverter typeConverter, String extensionName) {
- this.ctx = ctx;
- this.typeConverter = typeConverter;
- this.extensionName = extensionName;
- }
-
- public ExpressionBase convert(SyntaxElement ele) {
- throw new UnsupportedOperationException("Call for abstract class 'SyntaxElement'");
- }
-
- public ExpressionBase convert(Literal ele) {
- throw new UnsupportedOperationException("Call for abstract class 'Literal'");
- }
-
- public ExpressionBase convert(BooleanLiteral lit) {
- return new LiteralExpression("true".equals(lit.getLiteralValue().getValue()), getSourcePos(lit));
- }
-
- public ExpressionBase convert(IntegerLiteral lit) {
- return new LiteralExpression(new Long(lit.getLiteralValue().getValue()), getSourcePos(lit));
- }
-
- public ExpressionBase convert(RealLiteral lit) {
- return new LiteralExpression(new Double(lit.getLiteralValue().getValue()), getSourcePos(lit));
- }
-
- public ExpressionBase convert(NullLiteral lit) {
- return new LiteralExpression(null, getSourcePos(lit));
- }
-
- public ExpressionBase convert(ListLiteral lit) {
- final List<ExpressionBase> inner = new ArrayList<ExpressionBase>();
-
- for (AbstractExpression e : lit.getElements())
- inner.add(convert(e));
-
- return new ListLiteralExpression(inner, getSourcePos(lit));
- }
-
- public ExpressionBase convert(StringLiteral lit) {
- return new LiteralExpression(lit.getLiteralValue().getValue(), getSourcePos(lit));
- }
-
- public ExpressionBase convert(ChainExpression expr) {
- return new SequenceExpression(getInner(expr), getSourcePos(expr));
- }
-
- public ExpressionBase convert(Cast expr) {
- return convert(expr.getTarget());
- }
-
- public ExpressionBase convert(ConstructorCallExpression expr) {
- return new CreateUncachedExpression(typeConverter.convertToBackendType(expr.getType()), getSourcePos(expr));
- }
-
- public ExpressionBase convert(FeatureCall expr) {
- final SourcePos sourcePos = getSourcePos(expr);
-
- if (expr.getTarget() == null) {
- // 1. check for a static property
- final StaticProperty staticProp = typeConverter.getEnumLiteral(expr.getName());
- if (staticProp != null)
- return new LiteralExpression(staticProp.get(), sourcePos);
-
- // 2. check for a local variable
- if (ctx.getVariable(expr.getName().getValue()) != null)
- return new LocalVarEvalExpression(expr.getName().getValue(), sourcePos);
-
- // 3. check for a type literal
- try {
- return new LiteralExpression(typeConverter.convertToBackendType(expr.getName()), sourcePos);
- } catch (IllegalArgumentException exc) {
- } // do nothing - this means
- // it is not a type literal
-
- // 4. check for "this"
- if (ctx.hasThis()) {
- final ExpressionBase thisExpr = new LocalVarEvalExpression(
- org.eclipse.xtend.backend.common.SyntaxConstants.THIS, sourcePos);
- return createPropertyExpression(thisExpr, ctx.getThis(), expr.getName().getValue(), sourcePos);
- }
-
- throw new IllegalArgumentException("feature call " + expr.toString() + " does not match any feature: "
- + sourcePos);
- } else {
- // evaluate the target and evaluate the property on the result
- return createPropertyExpression(convert(expr.getTarget()), analyze(expr.getTarget()), expr.getName()
- .getValue(), sourcePos);
- }
- }
-
- public ExpressionBase convert(CollectionExpression expr) {
- final SourcePos sourcePos = getSourcePos(expr);
-
- final String functionName = expr.getName().getValue();
-
- final AnalyzeContext oldCtx = ctx;
- ctx = ctx.cloneWith(new AnalyzeContext.Var(BackendTypeConverter.qualify(expr.getEleName()), null) /*
- * TODO
- * ObjectType
- */);
- final ExpressionBase bodyExpr = convert(expr.getClosure());
- ctx = oldCtx;
-
- final InitClosureExpression closureExpr = new InitClosureExpression(
- Arrays.asList(expr.getEleName().getValue()), Arrays.asList(ObjectType.INSTANCE), bodyExpr, sourcePos);
-
- if (expr.getTarget() == null) {
- if (!ctx.hasThis())
- throw new IllegalStateException(functionName + " with neither a target nor an implicit 'this'");
-
- final ExpressionBase thisExpr = new LocalVarEvalExpression(
- org.eclipse.xtend.backend.common.SyntaxConstants.THIS, sourcePos);
- return new InvocationOnObjectExpression(functionName, Arrays.asList(thisExpr, closureExpr), true, sourcePos);
- } else
- return new InvocationOnObjectExpression(functionName,
- Arrays.asList(convert(expr.getTarget()), closureExpr), true, sourcePos);
- }
-
- public ExpressionBase convert(TypeSelectExpression expr) {
- final SourcePos sourcePos = getSourcePos(expr);
-
- final Type t = typeSystem.typeForName(toString(expr.getTypeLiteral()));// TODO
- // type
- // args
- final ExpressionBase typeExpr = new LiteralExpression(typeConverter.convertToBackendType(t), sourcePos);
-
- if (expr.getTarget() == null) {
- if (!ctx.hasThis())
- throw new IllegalStateException("typeSelect with neither a target nor an implicit 'this'");
-
- final ExpressionBase thisExpr = new LocalVarEvalExpression(
- org.eclipse.xtend.backend.common.SyntaxConstants.THIS, sourcePos);
- return new InvocationOnObjectExpression(SysLibNames.TYPE_SELECT, Arrays.asList(thisExpr, typeExpr), true,
- sourcePos);
- } else
- return new InvocationOnObjectExpression(SysLibNames.TYPE_SELECT, Arrays.asList(convert(expr.getTarget()),
- typeExpr), false, sourcePos);
- }
-
- /**
- * @param typeLiteral
- * @return
- */
- private String toString(Identifier id) {
- return BackendTypeConverter.qualify(id);
- }
-
- public ExpressionBase convert(OperationCall expr) {
- final SourcePos sourcePos = getSourcePos(expr);
- final String functionName = transformFunctionName(expr.getName().getValue());
-
- final List<ExpressionBase> params = new ArrayList<ExpressionBase>();
- for (AbstractExpression e : expr.getParams())
- params.add(convert(e));
-
- final List<AbstractTypeReference> paramTypes = new ArrayList<AbstractTypeReference>();
- for (AbstractExpression e : expr.getParams())
- paramTypes.add(analyze(e));
-
- if (expr.getTarget() == null) {
- if (ctx.hasThis()) {
- // if a function matches directly (i.e. without implicitly
- // passing 'this' as a first parameter), that
- // has precedence in matching
- if (hasMatchingOperationCall(functionName, paramTypes.toArray(new AbstractTypeReference[0])))
- return new InvocationOnObjectExpression(functionName, params, false, sourcePos);
- else {
- final ExpressionBase thisExpression = new LocalVarEvalExpression(
- org.eclipse.xtend.backend.common.SyntaxConstants.THIS, sourcePos);
- Var thisVar = ctx.getThis();
- final AbstractTypeReference thisType = thisVar.getValue();
- return createInvocationOnTargetExpression(functionName, thisExpression, thisType, params,
- paramTypes, true, sourcePos);
- }
- } else
- return new InvocationOnObjectExpression(functionName, params, false, sourcePos);
- } else
- return createInvocationOnTargetExpression(functionName, convert(expr.getTarget()),
- analyze(expr.getTarget()), params, paramTypes, true, sourcePos);
- }
-
- public ExpressionBase convert(GlobalVarExpression expr) {
- // TODO: To be impl
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public ExpressionBase convert(IfExpression expr) {
- final ExpressionBase elseExpr = (expr.getElsePart() != null) ? convert(expr.getElsePart())
- : new LiteralExpression(null, getSourcePos(expr));
-
- return new org.eclipse.xtend.backend.expr.IfExpression(convert(expr.getCondition()),
- convert(expr.getThenPart()), elseExpr, getSourcePos(expr));
- }
-
- public ExpressionBase convert(LetExpression expr) {
- final ExpressionBase varExpr = convert(expr.getVarExpression());
- final AbstractTypeReference varType = analyze(expr.getVarExpression());
-
- final AnalyzeContext oldCtx = ctx;
- String varName = toString(expr.getVarName());
- ctx = ctx.cloneWith(new AnalyzeContext.Var(varName, varType));
-
- try {
- if (oldCtx.getVariable(varName) != null)
- return new HidingLocalVarDefExpression(varName, varExpr, convert(expr.getTargetExpression()),
- getSourcePos(expr));
- else
- return new NewLocalVarDefExpression(varName, varExpr, convert(expr.getTargetExpression()),
- getSourcePos(expr));
- } finally {
- ctx = oldCtx;
- }
- }
-
- public ExpressionBase convert(SwitchExpression expr) {
- final List<Pair<ExpressionBase, ExpressionBase>> cases = new ArrayList<Pair<ExpressionBase, ExpressionBase>>();
- for (Case c : expr.getCases())
- cases.add(new Pair<ExpressionBase, ExpressionBase>(convert(c.getCondition()), convert(c.getThenPart())));
-
- return new org.eclipse.xtend.backend.expr.SwitchExpression(convert(expr.getSwitchExpr()), cases, convert(expr
- .getDefaultExpr()), getSourcePos(expr));
- }
-
- /**
- * transform built-in operator names from the old to the new special names
- */
- private String transformFunctionName(String functionName) {
- if ("+".equals(functionName))
- return SysLibNames.OPERATOR_PLUS;
- if ("-".equals(functionName))
- return SysLibNames.OPERATOR_MINUS;
- if ("*".equals(functionName))
- return SysLibNames.OPERATOR_MULT;
- if ("/".equals(functionName))
- return SysLibNames.OPERATOR_DIV;
- if ("%".equals(functionName))
- return SysLibNames.OPERATOR_MOD;
-
- if ("==".equals(functionName))
- return SysLibNames.OPERATOR_EQUALS;
- if ("!=".equals(functionName))
- return SysLibNames.OPERATOR_NOT_EQUALS;
- if ("<".equals(functionName))
- return SysLibNames.OPERATOR_LESS;
- if ("<=".equals(functionName))
- return SysLibNames.OPERATOR_LESS_OR_EQUALS;
- if (">=".equals(functionName))
- return SysLibNames.OPERATOR_GREATER_OR_EQUALS;
- if (">".equals(functionName))
- return SysLibNames.OPERATOR_GREATER;
-
- if ("!".equals(functionName))
- return SysLibNames.OPERATOR_NOT;
-
- if ("subString".equals(functionName))
- return SysLibNames.SUBSTRING;
- if ("replaceAll".equals(functionName))
- return SysLibNames.REPLACE_ALL_REGEX;
-
- return functionName;
- }
-
- private AbstractTypeReference analyze(AbstractExpression target) {
- // TODO: To be impl
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- private ExpressionBase createInvocationOnTargetExpression(String functionName, ExpressionBase targetExpression,
- AbstractTypeReference targetType, List<ExpressionBase> params, List<AbstractTypeReference> paramTypes,
- boolean isMethodStyle, SourcePos sourcePos) {
- final List<ExpressionBase> paramsWithoutFirst = params;
- final List<ExpressionBase> allParams = new ArrayList<ExpressionBase>();
- allParams.add(targetExpression);
- allParams.addAll(params);
-
- if (isCollectionType(targetType)) {
- paramTypes.add(0, targetType);
- final AbstractTypeReference[] paramTypeArray = paramTypes.toArray(new AbstractTypeReference[0]);
-
- if (hasMatchingOperationCall(functionName, paramTypeArray))
- // check if there is a function that directly matches the
- // collection
- return new InvocationOnObjectExpression(functionName, allParams, true, sourcePos);
- else
- // otherwise, do a 'collect' and call the function on all
- // elements of the collection
- return new InvocationOnCollectionExpression(targetExpression, functionName, paramsWithoutFirst,
- sourcePos);
- }
-
- if (isObjectType(targetType))
- // if the static type is "Object", we do not know if it is a
- // collection, so we do the logic at runtime
- return new InvocationOnWhateverExpression(functionName, allParams, isMethodStyle, sourcePos);
-
- // otherwise we know that it is not a collection and can avoid repeating
- // this logic at runtime
- return new InvocationOnObjectExpression(functionName, allParams, true, sourcePos);
- }
-
- private boolean hasMatchingOperationCall(String functionName, AbstractTypeReference[] paramTypes) {
- FunctionType functionType = typeSystem.functionForNameAndParameterTypes(functionName, paramTypes);
- if (functionType != null) {
- return true;
- } else {
- return false;
- }
- }
-
- private ExpressionBase createPropertyExpression(ExpressionBase target, Object type, String varName,
- SourcePos sourcePos) {
- if (isCollectionType(type)) {
- if (CollectionType.INSTANCE.getProperties().keySet().contains(varName))
- return new PropertyOnObjectExpression(target, varName, sourcePos);
- else
- return new PropertyOnCollectionExpression(target, varName, sourcePos);
- }
-
- if (isObjectType(type))
- return new PropertyOnWhateverExpression(target, varName, sourcePos);
-
- return new PropertyOnObjectExpression(target, varName, sourcePos);
- }
-
- private boolean isObjectType(Object t) {
- // TODO : To be impl
- return true;
- // throw new UnsupportedOperationException("Not yet implemented");
- }
-
- private boolean isCollectionType(Object t) {
- // TODO : To be impl
- return false;
- // throw new UnsupportedOperationException("Not yet implemented");
- }
-
- /**
- * extract the inner expressions as a "flat" list - they are stored as a
- * binary tree in the ChainExpression...
- */
- private List<ExpressionBase> getInner(ChainExpression expr) {
- final List<ExpressionBase> result = new ArrayList<ExpressionBase>();
-
- if (expr.getFirst() instanceof ChainExpression)
- result.addAll(getInner((ChainExpression) expr.getFirst()));
- else
- result.add(convert(expr.getFirst()));
-
- if (expr.getNext() instanceof ChainExpression)
- result.addAll(getInner((ChainExpression) expr.getNext()));
- else
- result.add(convert(expr.getNext()));
-
- return result;
- }
-
- private SourcePos getSourcePos(SyntaxElement lit) {
- return new SourcePos(lit.getFileName(), extensionName, lit.getLine());
- }
-
-}