summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsefftinge2008-03-03 10:43:48 (EST)
committer sefftinge2008-03-03 10:43:48 (EST)
commit758e79f06d06fd3cfa83922f4b4ad4c3b18e205e (patch)
treed28559ae549240fe0bbd10ea7b3733ada27ea6a8
parent3a9cb61162669da98df050531ac2f1d0a8185eb5 (diff)
downloadorg.eclipse.xpand-758e79f06d06fd3cfa83922f4b4ad4c3b18e205e.zip
org.eclipse.xpand-758e79f06d06fd3cfa83922f4b4ad4c3b18e205e.tar.gz
org.eclipse.xpand-758e79f06d06fd3cfa83922f4b4ad4c3b18e205e.tar.bz2
static typesystem (third draft)
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BooleanTypeImpl.java57
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinBaseType.java20
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java4
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/CollectionTypeImpl.java327
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/FeatureTypeImpl.java90
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/IntegerTypeImpl.java271
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ListTypeImpl.java128
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ObjectTypeImpl.java148
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/OperationTypeImpl.java72
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/PropertyTypeImpl.java68
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/RealTypeImpl.java190
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/SetTypeImpl.java58
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StaticPropertyTypeImpl.java62
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StringTypeImpl.java330
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/TypeTypeImpl.java187
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/VoidType.java60
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclarationsContributor.java4
17 files changed, 42 insertions, 2034 deletions
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BooleanTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BooleanTypeImpl.java
index f1a432c..494a3e5 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BooleanTypeImpl.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BooleanTypeImpl.java
@@ -11,52 +11,31 @@
package org.eclipse.xand3.analyzation.typesystem.builtin;
-import java.util.Collections;
+import java.util.List;
import java.util.Set;
-import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.Type;
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredTypeParameter;
+import org.eclipse.xand3.analyzation.typesystem.type.Type;
-public final class BooleanTypeImpl extends BuiltinBaseType implements Type {
- public BooleanTypeImpl(final TypeSystem ts, final String name) {
- super(ts, name);
- }
-
- public boolean isInstance(final Object o) {
- return o instanceof Boolean;
- }
-
- @Override
- public Object convert(final Object src, final Class targetType) {
- if (targetType == Boolean.class || targetType == Boolean.TYPE)
- return src;
- return super.convert(src, targetType);
- }
- public Object newInstance() {
- return Boolean.FALSE;
+public final class BooleanTypeImpl extends BuiltinBaseType {
+ public BooleanTypeImpl(final String name) {
+ super(name);
}
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] {
- new OperationImpl(this, "!",BooleanTypeImpl.this) {
- @Override
- public Object evaluateInternal(final Object target,
- final Object[] params) {
- return target == null ? null : new Boolean(!((Boolean) target)
- .booleanValue());
- }
- }
-
- };
- }
-
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredType#getSuperTypes()
+ */
public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getObjectType());
+ // TODO Auto-generated method stub
+ return null;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredType#getTypeParameters()
+ */
+ public List<DeclaredTypeParameter> getTypeParameters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinBaseType.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinBaseType.java
index ff656aa..55aded1 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinBaseType.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinBaseType.java
@@ -1,6 +1,10 @@
package org.eclipse.xand3.analyzation.typesystem.builtin;
+import java.util.Set;
+
import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredFeature;
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredOperation;
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredProperty;
import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredType;
public abstract class BuiltinBaseType implements DeclaredType {
@@ -14,7 +18,21 @@ public abstract class BuiltinBaseType implements DeclaredType {
/* (non-Javadoc)
* @see org.eclipse.xand3.analyzation.typesystem.DeclaredType#getDeclaredFeatures()
*/
- public DeclaredFeature[] getDeclaredFeatures() {
+ public Set<DeclaredFeature> getDeclaredFeatures() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredType#getDeclaredOperations()
+ */
+ public Set<DeclaredOperation> getDeclaredOperations() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredType#getDeclaredProperties()
+ */
+ public Set<DeclaredProperty> getDeclaredProperties() {
return null;
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java
index a9d44a8..1cb12d5 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java
@@ -15,6 +15,8 @@
*/
package org.eclipse.xand3.analyzation.typesystem.builtin;
+import java.util.Set;
+
import org.eclipse.xand3.analyzation.typesystem.declaration.DeclarationsContributor;
import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredFunction;
import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredType;
@@ -28,7 +30,7 @@ public class BuiltinDeclarationsContributor implements DeclarationsContributor {
/* (non-Javadoc)
* @see org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor#functionsForName(java.lang.String)
*/
- public DeclaredFunction[] functionsForName(String name) {
+ public Set<DeclaredFunction> functionsForName(String name) {
// TODO Auto-generated method stub
return null;
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/CollectionTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/CollectionTypeImpl.java
deleted file mode 100644
index 5bca95c..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/CollectionTypeImpl.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
-import org.eclipse.internal.xtend.type.baseimpl.PropertyImpl;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.ParameterizedType;
-import org.eclipse.xtend.typesystem.Type;
-
-/**
- * @author Sven Efftinge (http://www.efftinge.de)
- * @author Arno Haase
- */
-public class CollectionTypeImpl extends BuiltinBaseType implements ParameterizedType {
- private Type innerType;
-
- public CollectionTypeImpl(final Type innerType, final TypeSystem ts, final String name) {
- super(ts, name);
- this.innerType = innerType;
- }
-
- public Type getInnerType() {
- return innerType;
- }
-
- public ParameterizedType cloneWithInnerType(final Type innerType) {
- return (ParameterizedType) getTypeSystem().getCollectionType(innerType);
- }
-
- @Override
- protected boolean internalIsAssignableFrom(final Type t) {
- return super.internalIsAssignableFrom(t);
- }
-
- public boolean isInstance(final Object o) {
- return o instanceof Collection;
- }
-
- public Object newInstance() {
- return new ArrayList<Object>();
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] {
- new OperationImpl(this, "toList", getTypeSystem().getListType(getInnerType())) {
-
- @Override
- public String getDocumentation() {
- return "converts this collection to List";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return new ArrayList<Object>(((Collection<?>) target));
- }
-
- @Override
- public Type getReturnType(final Type targetType, final Type[] paramTypes) {
- if (!(targetType instanceof ParameterizedType))
- return getReturnType();
- final TypeSystem ts = getTypeSystem();
- return ts.getListType(((ParameterizedType) targetType).getInnerType());
- }
- },
-
- new OperationImpl(this, "toSet", getTypeSystem().getSetType(getInnerType())) {
-
- @Override
- public String getDocumentation() {
- return "converts this collection to Set";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return new java.util.HashSet<Object>((Collection<?>) target);
- }
-
- @Override
- public Type getReturnType(final Type targetType, final Type[] paramTypes) {
- if (!(targetType instanceof ParameterizedType))
- return getReturnType();
- final TypeSystem ts = getTypeSystem();
- return ts.getSetType(((ParameterizedType) targetType).getInnerType());
- }
- },
-
- new OperationImpl(this, "toString", getTypeSystem().getStringType(), getTypeSystem()
- .getStringType() ) {
-
- @Override
- public String getDocumentation() {
- return "concatenates each contained element (using toString()), separated by the specified String.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final StringBuffer buff = new StringBuffer();
- for (final Iterator<?> iter = ((Collection<?>) target).iterator(); iter.hasNext();) {
- buff.append(iter.next().toString());
- if (iter.hasNext()) {
- buff.append(params[0].toString());
- }
- }
- return buff.toString();
- }
- },
-
- new PropertyImpl(this, "size", getTypeSystem().getIntegerType()) {
-
- @Override
- public String getDocumentation() {
- return "returns the size of this Collection";
- }
-
- public Object get(final Object target) {
- return new Long(((Collection<?>) target).size());
- }
- },
-
- new PropertyImpl(this, "isEmpty", getTypeSystem().getBooleanType()) {
-
- @Override
- public String getDocumentation() {
- return "returns true if this Collection is empty";
- }
-
- public Object get(final Object target) {
- return new Boolean(((Collection<?>) target).size() == 0);
- }
- },
-
- new OperationImpl(this, "add", this, getInnerType() ) {
-
- @Override
- public String getDocumentation() {
- return "adds an element to the Collection (modifies it!). returns this Collection.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- ((Collection<Object>) target).add(params[0]);
- return target;
- }
- },
-
- new OperationImpl(this, "addAll", this, getTypeSystem().getCollectionType(
- getInnerType()) ) {
-
- @Override
- public String getDocumentation() {
- return "adds all elements to the Collection (modifies it!). returns this Collection.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- ((Collection<?>) target).addAll((Collection) params[0]);
- return target;
- }
- },
-
- new OperationImpl(this, "contains", getTypeSystem().getBooleanType(), getTypeSystem()
- .getObjectType() ) {
-
- @Override
- public String getDocumentation() {
- return "returns true if this collection contains the specified object. otherwise false. returns this Collection.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return Boolean.valueOf(((Collection) target).contains(params[0]));
- }
- },
-
- new OperationImpl(this, "containsAll", getTypeSystem().getBooleanType(), getTypeSystem()
- .getCollectionType(getTypeSystem().getObjectType()) ) {
-
- @Override
- public String getDocumentation() {
- return "returns true if this collection contains each element contained in the specified collection. otherwise false. returns this Collection.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return Boolean.valueOf(((Collection) target).containsAll((Collection) params[0]));
- }
- },
-
- new OperationImpl(this, "remove", this, getTypeSystem().getObjectType() ) {
-
- @Override
- public String getDocumentation() {
- return "removes the specified element from this Collection if contained (modifies it!). returns this Collection.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- ((Collection) target).remove(params[0]);
- return target;
- }
- },
-
- new OperationImpl(this, "removeAll", this, getTypeSystem().getObjectType() ) {
-
- @Override
- public String getDocumentation() {
- return "removes all elements contained in the specified collection from this Collection if contained (modifies it!). returns this Collection.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- ((Collection) target).removeAll((Collection) params[0]);
- return target;
- }
- },
-
- new OperationImpl(this, "union", getTypeSystem().getSetType(getInnerType()),
- getTypeSystem().getCollectionType(getTypeSystem().getObjectType())) {
-
- @Override
- public String getDocumentation() {
- return "returns a new Set, containing all elements from this and the specified Collection";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final Set r = new HashSet((Collection) target);
- r.addAll((Collection) params[0]);
- return r;
- }
- },
-
- new OperationImpl(this, "without", getTypeSystem().getSetType(getInnerType()),
- getTypeSystem().getCollectionType(getTypeSystem().getObjectType()) ) {
-
- @Override
- public String getDocumentation() {
- return "returns a new Set, containing all elements from this Collection without the elements from specified Collection";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final Set r = new HashSet((Collection) target);
- r.removeAll((Collection) params[0]);
- return r;
- }
- },
-
- new OperationImpl(this, "intersect", getTypeSystem().getSetType(getInnerType()),
- getTypeSystem().getCollectionType(getTypeSystem().getObjectType()) ) {
-
- @Override
- public String getDocumentation() {
- return "returns a new Set, containing only the elements contained in this and the specified Collection";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final Set r = new HashSet((Collection) target);
- r.retainAll((Collection) params[0]);
- return r;
- }
- },
-
- new OperationImpl(this, "flatten", getTypeSystem().getListType(getTypeSystem().getObjectType()),
- new Type[0]) {
-
- @Override
- public String getDocumentation() {
- return "returns a flatten List.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return flattenRec((Collection) target);
- }
-
- public List<Object> flattenRec(final Collection col) {
- final List<Object> result = new ArrayList<Object>();
- for (final Object element : col) {
- if (element instanceof Collection) {
- result.addAll(flattenRec((Collection) element));
- } else {
- result.add(element);
- }
- }
- return result;
- }
- }
-
- };
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getObjectType());
- }
-
- @Override
- public String toString() {
- String s = getName();
- if (innerType != null) {
- s += "[" + innerType + "]";
- }
- return s;
- }
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/FeatureTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/FeatureTypeImpl.java
deleted file mode 100644
index 115f66f..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/FeatureTypeImpl.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.internal.xtend.type.baseimpl.PropertyImpl;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.Type;
-
-/**
- * @author Sven Efftinge (http://www.efftinge.de)
- * @author Arno Haase
- */
-public class FeatureTypeImpl extends BuiltinBaseType implements Type {
-
- public FeatureTypeImpl(final TypeSystem ts, final String name) {
- super(ts, name);
- }
-
- public boolean isInstance(final Object o) {
- return o instanceof Feature;
- }
-
- public Object newInstance() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isAbstract() {
- return true;
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getObjectType());
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] { new PropertyImpl(this, "name", getTypeSystem().getStringType()) {
- public Object get(final Object target) {
- return ((Feature) target).getName();
- }
-
- @Override
- public void set(final Object target, final Object val) {
- throw new UnsupportedOperationException("property name is unsettable!");
- }
-
- }, new PropertyImpl(this, "returnType", getTypeSystem().getTypeType()) {
- public Object get(final Object target) {
- return ((Feature) target).getReturnType();
- }
-
- @Override
- public void set(final Object target, final Object val) {
- throw new UnsupportedOperationException("property name is unsettable!");
- }
-
- }, new PropertyImpl(this, "owner", getTypeSystem().getTypeType()) {
- public Object get(final Object target) {
- return ((Feature) target).getOwner();
- }
-
- @Override
- public void set(final Object target, final Object val) {
- throw new UnsupportedOperationException("property name is unsettable!");
- }
-
- }, new PropertyImpl(this, "documentation", getTypeSystem().getStringType()) {
-
- public Object get(final Object target) {
- return ((Feature) target).getDocumentation();
- }
- } };
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/IntegerTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/IntegerTypeImpl.java
deleted file mode 100644
index dfc0c2d..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/IntegerTypeImpl.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.Type;
-
-public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
-
- public IntegerTypeImpl(final TypeSystem ts, final String name) {
- super(ts, name);
- }
-
- public boolean isInstance(final Object o) {
- return o instanceof Integer || o instanceof BigInteger || o instanceof Byte || o instanceof Long
- || o instanceof Short;
- }
-
- public Object newInstance() {
- return new Long(-1);
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] {
- new OperationImpl(this, "+", IntegerTypeImpl.this, new Type[] { IntegerTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (params[0] == null)
- return null;
- return new Long(((Number) target).longValue() + ((Number) params[0]).longValue());
- }
- },
- new OperationImpl(this, "-", IntegerTypeImpl.this, new Type[] { IntegerTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (params[0] == null)
- return null;
- return new Long(((Number) target).longValue() - ((Number) params[0]).longValue());
- }
- },
- new OperationImpl(this, "-", IntegerTypeImpl.this, new Type[] {}) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return new Long(((Number) target).longValue() * -1l);
- }
- },
- new OperationImpl(this, "*", IntegerTypeImpl.this, new Type[] { IntegerTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (params[0] == null)
- return null;
-
- return new Long(((Number) target).longValue() * ((Number) params[0]).longValue());
- }
- },
- new OperationImpl(this, "/", IntegerTypeImpl.this, new Type[] { IntegerTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (params[0] == null)
- return null;
-
- return new Long(((Number) target).longValue() / ((Number) params[0]).longValue());
- }
- },
- new OperationImpl(this, "==", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return new Boolean(target == params[0]);
-
- try {
- return toLong(target).equals(toLong(params[0]));
- }
- catch (Exception exc) {
- if (target instanceof Number && params[0] instanceof Number)
- return ((Number) target).doubleValue() == ((Number) params[0]).doubleValue();
-
- return false;
- }
- }
-
- },
- new OperationImpl(this, "!=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return params[0] != null;
-
- try {
- return ! toLong(target).equals(toLong(params[0]));
- }
- catch (Exception exc) {
- if (target instanceof Number && params[0] instanceof Number)
- return ((Number) target).doubleValue() != ((Number) params[0]).doubleValue();
-
- return true;
- }
- }
- },
- new OperationImpl(this, ">", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
-
- try {
- return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) > 0;
- }
- catch (Exception exc) {
- return ((Number) target).doubleValue() > ((Number) params[0]).doubleValue();
- }
- }
- },
- new OperationImpl(this, ">=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
-
- try {
- return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) >= 0;
- }
- catch (Exception exc) {
- return ((Number) target).doubleValue() >= ((Number) params[0]).doubleValue();
- }
- }
- },
- new OperationImpl(this, "<", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
-
- try {
- return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) < 0;
- }
- catch (Exception exc) {
- return ((Number) target).doubleValue() < ((Number) params[0]).doubleValue();
- }
- }
- },
- new OperationImpl(this, "<=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
-
- try {
- return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) <= 0;
- }
- catch (Exception exc) {
- return ((Number) target).doubleValue() <= ((Number) params[0]).doubleValue();
- }
- }
- }, new OperationImpl(this, "upTo", getTypeSystem().getListType(this), new Type[] { this }) {
-
- @Override
- public String getDocumentation() {
- return "returns a List of Integers starting with the value of the target expression, up to "
- + "the value of the specified Integer, incremented by one."
- + "e.g. '1.upTo(5)' evaluates to {1,2,3,4,5}";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final List<Long> result = new ArrayList<Long>();
- long l1 = toLong(target).longValue();
- final long l2 = toLong(params[0]).longValue();
-
- while (l1 <= l2) {
- result.add(new Long(l1));
- l1++;
- }
- return result;
- }
- }, new OperationImpl(this, "upTo", getTypeSystem().getListType(this), new Type[] { this, this }) {
-
- @Override
- public String getDocumentation() {
- return "returns a List of Integers starting with the value of the target expression, up to "
- + "the value of the first paramter, incremented by the second parameter."
- + "e.g. '1.upTo(10, 2)' evaluates to {1,3,5,7,9}";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final List<Long> result = new ArrayList<Long>();
- long l1 = toLong(target).longValue();
- final long l2 = toLong(params[0]).longValue();
- final long l3 = toLong(params[1]).longValue();
-
- while (l1 <= l2) {
- result.add(new Long(l1));
- l1 = l1 + l3;
- }
- return result;
- }
- } };
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getRealType());
- }
-
- Long toLong(final Object o) {
- if (o == null)
- return null;
-
- if (o instanceof Integer)
- return new Long(((Integer) o).longValue());
- else if (o instanceof BigInteger)
- return new Long(((BigInteger) o).longValue());
- else if (o instanceof Byte)
- return new Long(((Byte) o).longValue());
- else if (o instanceof Long)
- return (Long) o;
- else if (o instanceof Short)
- return new Long(((Short) o).longValue());
- throw new IllegalArgumentException(o.getClass().getName() + " not supported");
- }
-
- @Override
- public Object convert(final Object src, final Class<?> targetType) {
- final Long l = toLong(src);
- if (targetType.isAssignableFrom(Integer.class) || targetType.isAssignableFrom(Integer.TYPE))
- return new Integer(l.intValue());
- else if (targetType.isAssignableFrom(BigInteger.class))
- return BigInteger.valueOf(l.longValue());
- else if (targetType.isAssignableFrom(Byte.class) || targetType.isAssignableFrom(Byte.TYPE))
- return new Byte(l.byteValue());
- else if (targetType.isAssignableFrom(Long.class) || targetType.isAssignableFrom(Long.TYPE))
- return src;
- else if (targetType.isAssignableFrom(Short.class) || targetType.isAssignableFrom(Short.TYPE))
- return new Short(l.shortValue());
- return super.convert(src, targetType);
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ListTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ListTypeImpl.java
deleted file mode 100644
index e4299ab..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ListTypeImpl.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.ParameterizedType;
-import org.eclipse.xtend.typesystem.Type;
-
-/**
- * @author Sven Efftinge (http://www.efftinge.de)
- * @author Arno Haase
- */
-public class ListTypeImpl extends CollectionTypeImpl implements Type {
-
- public ListTypeImpl(final Type innerType, final TypeSystem ts, final String name) {
- super(innerType, ts, name);
- }
-
- @Override
- public boolean isInstance(final Object o) {
- return o instanceof List;
- }
-
- @Override
- public Object newInstance() {
- return new ArrayList<Object>();
- }
-
- @Override
- public ParameterizedType cloneWithInnerType(final Type innerType) {
- return (ParameterizedType) getTypeSystem().getListType(innerType);
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] { new OperationImpl(this, "get", getInnerType(), new Type[] { getTypeSystem().getIntegerType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return ((List<?>) target).get(((Number) params[0]).intValue());
- }
- }, new OperationImpl(this, "indexOf", getTypeSystem().getIntegerType(), new Type[] { getTypeSystem().getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return new Long(((List<?>) target).indexOf(params[0]));
- }
- }, new OperationImpl(this, "first", getInnerType(), new Type[0]) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target instanceof List) {
- List<?> l = (List<?>) target;
- if (l.size() > 0)
- return l.get(0);
- }
- return null;
- }
- }, new OperationImpl(this, "reverse", getInnerType(), new Type[0]) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target instanceof List) {
- List<?> l = new ArrayList ((List<?>) target);
- Collections.reverse(l);
- return l;
- }
- return null;
- }
- }, new OperationImpl(this, "last", getInnerType(), new Type[0]) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target instanceof List) {
- List<?> l = (List<?>) target;
- if (l.size() > 0)
- return l.get(l.size() - 1);
- }
- return null;
- }
- }, new OperationImpl(this, "withoutFirst", this, new Type[0]) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target instanceof List) {
- List l = (List) target;
- List r = new ArrayList();
- for (int i = 1; i < l.size(); i++) {
- r.add(l.get(i));
- }
- return r;
- }
- return null;
- }
- }, new OperationImpl(this, "withoutLast", this, new Type[0]) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target instanceof List) {
- List l = (List) target;
- List r = new ArrayList();
- for (int i = 0; i < l.size() - 1; i++) {
- r.add(l.get(i));
- }
- return r;
- }
- return null;
- }
- }
-
- };
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getCollectionType(getInnerType()));
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ObjectTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ObjectTypeImpl.java
deleted file mode 100644
index c39fcaf..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ObjectTypeImpl.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
-import org.eclipse.internal.xtend.type.baseimpl.PropertyImpl;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.Operation;
-import org.eclipse.xtend.typesystem.Type;
-
-/**
- * @author Sven Efftinge (http://www.efftinge.de)
- * @author Arno Haase
- */
-public class ObjectTypeImpl extends BuiltinBaseType implements Type {
-
- public ObjectTypeImpl(final TypeSystem ts, final String name) {
- super(ts, name);
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] {
- new OperationImpl(this, "==", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return new Boolean(target == params[0]);
- return new Boolean(target.equals(params[0]));
- }
- }, new OperationImpl(this, "!=", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return new Boolean(target != params[0]);
- return new Boolean(!target.equals(params[0]));
- }
- }, new OperationImpl(this, ">", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
- return new Boolean(((Comparable<Object>) target).compareTo(params[0]) > 0);
- }
- }, new OperationImpl(this, ">=", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
- return new Boolean(((Comparable<Object>) target).compareTo(params[0]) >= 0);
- }
- }, new OperationImpl(this, "<", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
- return new Boolean(((Comparable<Object>) target).compareTo(params[0]) < 0);
- }
- }, new OperationImpl(this, "<=", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
- return new Boolean(((Comparable<Object>) target).compareTo(params[0]) <= 0);
- }
- }, new PropertyImpl(this, "metaType", getTypeSystem().getTypeType()) {
- @Override
- public String getDocumentation() {
- return "returns this object's meta type.";
- }
-
- public Object get(final Object target) {
- return getTypeSystem().getType(target);
- }
- }, new OperationImpl(this, "toString", getTypeSystem().getStringType()) {
- @Override
- public String getDocumentation() {
- return "returns the String representation of this object. (Calling Java's toString() method)";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return target != null ? target.toString() : "null";
- }
- }, new OperationImpl(this, "compareTo", getTypeSystem().getIntegerType(), new Type[] { this }) {
- @Override
- public String getDocumentation() {
- return "Compares this object with the specified object for order. Returns a negative "
- + "integer, zero, or a positive integer as this object is less than, equal to, "
- + "or greater than the specified object.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return params[0] == null ? new Long(0) : new Long(-1);
- if (params[0] == null)
- return new Long(1);
- if (target instanceof Comparable)
- return new Long(((Comparable<Object>) target).compareTo(params[0]));
- else {
- final TypeSystem ts = getTypeSystem();
- Operation op = ts.findOperation("toString", target, null);
- final String s1 = (String) op.evaluate(target, null);
- op = ts.findOperation("toString", params[0], null);
- final String s2 = (String) op.evaluate(params[0], null);
- ;
- return new Long(s1.compareTo(s2));
- }
- }
- } };
- }
-
- public boolean isInstance(final Object o) {
- return true;
- }
-
- public Object newInstance() {
- return new Object();
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.EMPTY_SET;
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/OperationTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/OperationTypeImpl.java
deleted file mode 100644
index e49d372..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/OperationTypeImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.Operation;
-import org.eclipse.xtend.typesystem.Type;
-
-public final class OperationTypeImpl extends FeatureTypeImpl implements Type {
-
- public OperationTypeImpl(final TypeSystem ts, final String name) {
- super(ts, name);
- }
-
- @Override
- public boolean isInstance(final Object o) {
- return o instanceof Operation;
- }
-
- @Override
- public Object newInstance() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isAbstract() {
- return true;
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getFeatureType());
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] {
- new OperationImpl(this, "evaluate", getTypeSystem().getObjectType(),
- getTypeSystem().getObjectType(), getTypeSystem().getListType(null)) {
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return ((Operation) target).evaluate(target, ((List<?>) params[0]).toArray());
- }
-
- },
- new OperationImpl(this, "getParameterTypes",
- getTypeSystem().getListType(getTypeSystem().getTypeType())) {
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return ((Operation) target).getParameterTypes();
- }
-
- } };
- }
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/PropertyTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/PropertyTypeImpl.java
deleted file mode 100644
index 9286b89..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/PropertyTypeImpl.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.Property;
-import org.eclipse.xtend.typesystem.Type;
-
-public final class PropertyTypeImpl extends BuiltinBaseType {
-
- public PropertyTypeImpl(final TypeSystem ts, final String name) {
- super(ts, name);
- }
-
- public boolean isInstance(final Object o) {
- return o instanceof Property;
- }
-
- public Object newInstance() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isAbstract() {
- return true;
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getFeatureType());
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] {
- new OperationImpl(this, "get", getTypeSystem().getObjectType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return ((Property) target).get(params[0]);
- }
- },
- new OperationImpl(this, "set", getTypeSystem().getVoidType(), new Type[] {
- getTypeSystem().getObjectType(), getTypeSystem().getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- ((Property) target).set(params[0], params[1]);
- return null;
- }
- }
-
- };
- }
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/RealTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/RealTypeImpl.java
deleted file mode 100644
index e961596..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/RealTypeImpl.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.math.BigDecimal;
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.Type;
-
-/**
- * @author Sven Efftinge (http://www.efftinge.de)
- * @author Arno Haase
- */
-public class RealTypeImpl extends BuiltinBaseType implements Type {
-
- public RealTypeImpl(final TypeSystem ts, final String name) {
- super(ts, name);
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] {
- new OperationImpl(this, "+", RealTypeImpl.this, new Type[] { RealTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (params[0] == null)
- return null;
-
- return new Double(((Number) target).doubleValue() + ((Number) params[0]).doubleValue());
- }
- },
- new OperationImpl(this, "-", RealTypeImpl.this, new Type[] { RealTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (params[0] == null)
- return null;
-
- return new Double(((Number) target).doubleValue() - ((Number) params[0]).doubleValue());
- }
- },
- new OperationImpl(this, "-", RealTypeImpl.this, new Type[] {}) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return new Double(((Number) target).doubleValue() * -1.0d);
- }
- },
- new OperationImpl(this, "*", RealTypeImpl.this, new Type[] { RealTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (params[0] == null)
- return null;
-
- return new Double(((Number) target).doubleValue() * ((Number) params[0]).doubleValue());
- }
- },
- new OperationImpl(this, "/", RealTypeImpl.this, new Type[] { RealTypeImpl.this }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (params[0] == null)
- return null;
-
- return new Double(((Number) target).doubleValue() / ((Number) params[0]).doubleValue());
- }
- },
- new OperationImpl(this, "==", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return new Boolean(target == params[0]);
-
- try {
- return toDouble(target).equals(toDouble(params[0]));
- }
- catch (Exception exc) {
- return false;
- }
- }
-
- },
- new OperationImpl(this, "!=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return new Boolean(target != params[0]);
-
- try {
- return !toDouble(target).equals(toDouble(params[0]));
- }
- catch (Exception exc) {
- return true;
- }
- }
- },
- new OperationImpl(this, ">", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
- return new Boolean(((Comparable<Double>) toDouble(target)).compareTo(toDouble(params[0])) > 0);
- }
- },
- new OperationImpl(this, ">=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
- return new Boolean(((Comparable<Double>) toDouble(target)).compareTo(toDouble(params[0])) >= 0);
- }
- },
- new OperationImpl(this, "<", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
- return new Boolean(((Comparable<Double>) toDouble(target)).compareTo(toDouble(params[0])) < 0);
- }
- },
- new OperationImpl(this, "<=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- if (target == null)
- return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
- if (params[0] == null)
- return Boolean.FALSE;
- return new Boolean(((Comparable<Double>) toDouble(target)).compareTo(toDouble(params[0])) <= 0);
- }
- } };
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getObjectType());
- }
-
- public boolean isInstance(final Object o) {
- return o instanceof Double || o instanceof Float || o instanceof BigDecimal;
- }
-
- public Object newInstance() {
- return new Double(1);
- }
-
- private Double toDouble(final Object o) {
- if (o == null)
- return null;
-
- if (o instanceof Number)
- return ((Number) o).doubleValue();
-
- throw new IllegalArgumentException(o.getClass().getName() + " not supported");
- }
-
- @Override
- public Object convert(final Object src, final Class<?> targetType) {
- final Double l = toDouble(src);
- if (targetType.isAssignableFrom(Double.class) || targetType.isAssignableFrom(Double.TYPE))
- return l;
- else if (targetType.isAssignableFrom(Float.class) || targetType.isAssignableFrom(Float.TYPE))
- return new Float(l.doubleValue());
- else if (targetType.isAssignableFrom(BigDecimal.class))
- return new BigDecimal(l.doubleValue());
- return super.convert(src, targetType);
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/SetTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/SetTypeImpl.java
deleted file mode 100644
index a905407..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/SetTypeImpl.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.ParameterizedType;
-import org.eclipse.xtend.typesystem.Type;
-
-/**
- * @author Sven Efftinge (http://www.efftinge.de)
- * @author Arno Haase
- */
-public class SetTypeImpl extends CollectionTypeImpl {
-
- public SetTypeImpl(final Type innerType, final TypeSystem ts, final String name) {
- super(innerType, ts, name);
- }
-
- @Override
- public boolean isInstance(final Object o) {
- return o instanceof Set;
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] {};
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getCollectionType(getInnerType()));
- }
-
- @Override
- public Object newInstance() {
- return new HashSet<Object>();
- }
-
- @Override
- public ParameterizedType cloneWithInnerType(final Type innerType) {
- return (ParameterizedType) getTypeSystem().getSetType(innerType);
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StaticPropertyTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StaticPropertyTypeImpl.java
deleted file mode 100644
index 1ef725f..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StaticPropertyTypeImpl.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.StaticProperty;
-import org.eclipse.xtend.typesystem.Type;
-
-public final class StaticPropertyTypeImpl extends BuiltinBaseType {
-
- public StaticPropertyTypeImpl(final TypeSystem ts, final String name) {
- super(ts, name);
- }
-
- public boolean isInstance(final Object o) {
- return o instanceof StaticProperty;
- }
-
- public Object newInstance() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isAbstract() {
- return true;
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getFeatureType());
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] { new OperationImpl(this, "get", getTypeSystem().getObjectType(), new Type[] {}) {
-
- @Override
- public String getDocumentation() {
- return "returns the static value";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return ((StaticProperty) target).get();
- }
- } };
- }
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StringTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StringTypeImpl.java
deleted file mode 100644
index 0c790bf..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StringTypeImpl.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
-import org.eclipse.internal.xtend.type.baseimpl.PropertyImpl;
-import org.eclipse.internal.xtend.util.StringHelper;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.Type;
-
-/**
- * @author Sven Efftinge (http://www.efftinge.de)
- * @author Arno Haase
- */
-public class StringTypeImpl extends BuiltinBaseType implements Type {
- final Log log = LogFactory.getLog(getClass());
-
- public StringTypeImpl(final TypeSystem ts, final String name) {
- super(ts, name);
- }
-
- public boolean isInstance(final Object o) {
- return o instanceof String || o instanceof StringBuffer || o instanceof Character;
- }
-
- public Object newInstance() {
- return "";
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] {
- new PropertyImpl(this, "length", getTypeSystem().getIntegerType()) {
-
- @Override
- public String getDocumentation() {
- return "the length of this string";
- }
-
- public Object get(final Object target) {
- return new Long(target.toString().length());
- }
- },
-
- new OperationImpl(this, "+", getTypeSystem().getStringType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
-
- @Override
- public String getDocumentation() {
- return "concatenates two strings";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return target.toString() + params[0];
- }
- },
-
- new OperationImpl(this, "startsWith", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getStringType() }) {
-
- @Override
- public String getDocumentation() {
- return "Tests if this string starts with the specified prefix.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final String token = (String) params[0];
- return new Boolean(target.toString().startsWith(token));
- }
- },
- new OperationImpl(this, "contains", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getStringType() }) {
-
- @Override
- public String getDocumentation() {
- return "Tests if this string contains substring.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final String token = (String) params[0];
- return new Boolean(target.toString().indexOf(token) >= 0);
- }
- },
- new OperationImpl(this, "endsWith", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getStringType() }) {
-
- @Override
- public String getDocumentation() {
- return "Tests if this string ends with the specified prefix.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final String token = (String) params[0];
- return new Boolean(target.toString().endsWith(token));
- }
- },
- new OperationImpl(this, "subString", getTypeSystem().getStringType(), new Type[] { getTypeSystem()
- .getIntegerType(),getTypeSystem().getIntegerType() }) {
-
- @Override
- public String getDocumentation() {
- return "Tests if this string ends with the specified prefix.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final Number from = (Number) params[0];
- final Number to = (Number) params[1];
- return target.toString().substring(from.intValue(),to.intValue());
- }
- },
-
- new OperationImpl(this, "toUpperCase", getTypeSystem().getStringType(), new Type[] {}) {
-
- @Override
- public String getDocumentation() {
- return "Converts all of the characters in this String to upper"
- + " case using the rules of the default locale (from Java)";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return target.toString().toUpperCase();
- }
- },
-
- new OperationImpl(this, "toLowerCase", getTypeSystem().getStringType(), new Type[] {}) {
- @Override
- public String getDocumentation() {
- return "Converts all of the characters in this String to lower"
- + " case using the rules of the default locale (from Java)";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return target.toString().toLowerCase();
- }
- },
-
- new OperationImpl(this, "toFirstUpper", getTypeSystem().getStringType(), new Type[] {}) {
- @Override
- public String getDocumentation() {
- return "Converts the first character in this String to upper"
- + " case using the rules of the default locale (from Java)";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return StringHelper.firstUpper(target.toString());
- }
- },
-
- new OperationImpl(this, "toFirstLower", getTypeSystem().getStringType(), new Type[] {}) {
- @Override
- public String getDocumentation() {
- return "Converts the first character in this String to lower"
- + " case using the rules of the default locale (from Java)";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return StringHelper.firstLower(target.toString());
- }
- },
-
- new OperationImpl(this, "toCharList", getTypeSystem().getListType(getTypeSystem().getStringType()),
- new Type[] {}) {
-
- @Override
- public String getDocumentation() {
- return "splits this String into a List[String] containing Strings of length 1";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final String txt = target.toString();
- final List<String> result = new ArrayList<String>();
- final char[] chars = txt.toCharArray();
- for (int i = 0; i < chars.length; i++) {
- result.add(String.valueOf(chars[i]));
- }
- return result;
- }
- },
-
- new OperationImpl(this, "replaceAll", getTypeSystem().getStringType(), new Type[] {
- getTypeSystem().getStringType(), getTypeSystem().getStringType() }) {
-
- @Override
- public String getDocumentation() {
- return "Replaces each substring of this string that matches the given "
- + "regular expression with the given replacement.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return target.toString().replaceAll(params[0].toString(), params[1].toString());
- }
- },
-
- new OperationImpl(this, "replaceFirst", getTypeSystem().getStringType(), new Type[] {
- getTypeSystem().getStringType(), getTypeSystem().getStringType() }) {
-
- @Override
- public String getDocumentation() {
- return "Replaces the first substring of this string that matches the given"
- + " regular expression with the given replacement.";
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return target.toString().replaceFirst(params[0].toString(), params[1].toString());
- }
- },
-
- new OperationImpl(this, "split", getTypeSystem().getListType(getTypeSystem().getStringType()),
- new Type[] { getTypeSystem().getStringType() }) {
-
- @Override
- public String getDocumentation() {
- return "Splits this string around matches of the given regular expression (from Java 1.4)";
-
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return new ArrayList<String>(Arrays.asList(target.toString().split(params[0].toString())));
- }
- },
-
- new OperationImpl(this, "matches", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getStringType() }) {
-
- @Override
- public String getDocumentation() {
- return "Tells whether or not this string matches the given regular expression. (from Java 1.4)";
-
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return Boolean.valueOf(((String) target).matches((String) params[0]));
- }
- },
-
- new OperationImpl(this, "trim", getTypeSystem().getStringType(), new Type[] {}) {
-
- @Override
- public String getDocumentation() {
- return "Returns a copy of the string, with leading and trailing whitespace omitted. (from Java 1.4)";
-
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return ((String) target).trim();
- }
- },
-
- new OperationImpl(this, "asInteger", getTypeSystem().getIntegerType(), new Type[] {}) {
-
- @Override
- public String getDocumentation() {
- return "Returns an Integer object holding the value of the specified String (from Java 1.5)";
-
- }
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- try {
- return Integer.valueOf((String) target);
- } catch (NumberFormatException nfe) {
- log.error("'asInteger' on '"+target+"' returned null!");
- return null;
- }
- }
- }
-
- };
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getObjectType());
- }
-
- private String toString(final Object o) {
- if (o == null)
- return null;
- if (isInstance(o))
- return o.toString();
- throw new IllegalArgumentException(o.getClass().getName() + " not supported");
- }
-
- @Override
- public Object convert(final Object src, final Class targetType) {
- final String s = toString(src);
- if (targetType.isAssignableFrom(String.class))
- return s;
- else if (targetType.isAssignableFrom(Character.class) || targetType.isAssignableFrom(Character.TYPE)) {
- if (s.length() == 1)
- return new Character(s.charAt(0));
- } else if (targetType.isAssignableFrom(StringBuffer.class))
- return new StringBuffer(s);
- return super.convert(src, targetType);
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/TypeTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/TypeTypeImpl.java
deleted file mode 100644
index 7ac8383..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/TypeTypeImpl.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
-import org.eclipse.internal.xtend.type.baseimpl.PropertyImpl;
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.Type;
-
-/**
- * @author Sven Efftinge (http://www.efftinge.de)
- * @author Arno Haase
- */
-public class TypeTypeImpl extends BuiltinBaseType {
-
- public TypeTypeImpl(final TypeSystem ts, final String name) {
- super(ts, name);
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getObjectType());
- }
-
- public boolean isInstance(final Object o) {
- return o instanceof Type;
- }
-
- public Object newInstance() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isAbstract() {
- return true;
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[] {
- new PropertyImpl(this, "name", getTypeSystem().getStringType()) {
- public Object get(final Object target) {
- final Type t = (Type) target;
- return t.getName();
- }
-
- @Override
- public void set(final Object target, final Object val) {
- throw new UnsupportedOperationException("unsettable!");
- }
-
- },
-
- new PropertyImpl(this, "superTypes", getTypeSystem().getSetType(getTypeSystem().getTypeType())) {
- public Object get(final Object target) {
- return ((Type) target).getSuperTypes();
- }
-
- @Override
- public void set(final Object target, final Object val) {
- throw new UnsupportedOperationException("unsettable!");
- }
- },
-
- new PropertyImpl(this, "allFeatures", getTypeSystem().getSetType(getTypeSystem().getFeatureType())) {
- public Object get(final Object target) {
- return ((Type) target).getAllFeatures();
- }
-
- @Override
- public void set(final Object target, final Object val) {
- throw new UnsupportedOperationException("unsettable!");
- }
- },
-
- new PropertyImpl(this, "allProperties", getTypeSystem().getSetType(getTypeSystem().getPropertyType())) {
- public Object get(final Object target) {
- return ((Type) target).getAllProperties();
- }
-
- @Override
- public void set(final Object target, final Object val) {
- throw new UnsupportedOperationException("unsettable!");
- }
- },
- new PropertyImpl(this, "allOperations", getTypeSystem().getSetType(getTypeSystem().getOperationType())) {
- public Object get(final Object target) {
- return ((Type) target).getAllOperations();
- }
-
- @Override
- public void set(final Object target, final Object val) {
- throw new UnsupportedOperationException("unsettable!");
- }
- },
-
- new PropertyImpl(this, "allStaticProperties", getTypeSystem().getSetType(
- getTypeSystem().getStaticPropertyType())) {
- public Object get(final Object target) {
- return ((Type) target).getAllStaticProperties();
- }
-
- @Override
- public void set(final Object target, final Object val) {
- throw new UnsupportedOperationException("unsettable!");
- }
- },
- new OperationImpl(this, "getFeature", getTypeSystem().getFeatureType(), new Type[] {
- getTypeSystem().getStringType(), getTypeSystem().getListType(null) }) {
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final List l = (List) params[1];
- final Type[] ta = (Type[]) l.toArray(new Type[l.size()]);
- return ((Type) target).getFeature((String) params[0], ta);
- }
- },
-
- new OperationImpl(this, "getProperty", getTypeSystem().getPropertyType(), new Type[] { getTypeSystem()
- .getStringType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return ((Type) target).getProperty((String) params[0]);
- }
- },
-
- new OperationImpl(this, "getOperation", getTypeSystem().getOperationType(), new Type[] {
- getTypeSystem().getStringType(), getTypeSystem().getListType(null) }) {
-
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- final List l = (List) params[1];
- final Type[] ta = (Type[]) l.toArray(new Type[l.size()]);
- return ((Type) target).getOperation((String) params[0], ta);
- }
- },
-
- new OperationImpl(this, "getStaticProperty", getTypeSystem().getStaticPropertyType(),
- new Type[] { getTypeSystem().getStringType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return ((Type) target).getStaticProperty((String) params[0]);
- }
- },
-
- new OperationImpl(this, "newInstance", getTypeSystem().getObjectType(), new Type[0]) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return ((Type) target).newInstance();
- }
- },
- new OperationImpl(this, "isInstance", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getObjectType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return new Boolean(((Type) target).isInstance(params[0]));
- }
- }, new OperationImpl(this, "isAssignableFrom", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
- .getTypeType() }) {
- @Override
- public Object evaluateInternal(final Object target, final Object[] params) {
- return ((Type) target).isAssignableFrom((Type) params[0]);
- }
- }, new PropertyImpl(this, "documentation", getTypeSystem().getStringType()) {
-
- public Object get(final Object target) {
- return ((Type) target).getDocumentation();
- }
- }
-
- };
- }
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/VoidType.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/VoidType.java
deleted file mode 100644
index f320de1..0000000
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/VoidType.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xand3.analyzation.typesystem.builtin;
-
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.xtend.expression.TypeSystem;
-import org.eclipse.xtend.typesystem.AbstractTypeImpl;
-import org.eclipse.xtend.typesystem.Feature;
-import org.eclipse.xtend.typesystem.Type;
-
-/**
- * @author Sven Efftinge (http://www.efftinge.de)
- * @author Arno Haase
- */
-public class VoidType extends AbstractTypeImpl implements Type {
-
- public VoidType(final TypeSystem ts, final String name) {
- super(ts, name);
- }
-
- @Override
- public Feature[] getContributedFeatures() {
- return new Feature[0];
- }
-
- public boolean isInstance(final Object o) {
- return o == null;
- }
-
- public Object newInstance() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isAbstract() {
- return true;
- }
-
- @Override
- public Set<Type> getSuperTypes() {
- return Collections.singleton(getTypeSystem().getObjectType());
- }
-
- @Override
- public String getDocumentation() {
- return "Void is used as an undefined type. It's only instance is the null reference.";
- }
-
-}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclarationsContributor.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclarationsContributor.java
index 8f9be02..6e0a214 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclarationsContributor.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclarationsContributor.java
@@ -15,7 +15,7 @@
*/
package org.eclipse.xand3.analyzation.typesystem.declaration;
-import java.util.List;
+import java.util.Set;
/**
* @author Sven Efftinge
@@ -23,5 +23,5 @@ import java.util.List;
*/
public interface DeclarationsContributor {
DeclaredType typeForName(String name);
- List<DeclaredFunction> functionsForName(String name);
+ Set<DeclaredFunction> functionsForName(String name);
}