summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorahaase2008-01-28 05:57:43 (EST)
committer ahaase2008-01-28 05:57:43 (EST)
commite07b2338575e245b19657f4312229419d7669943 (patch)
treef62d3a1403b44a0454a055ac4c0238f01b93987b
parent404449dd7b1dbc1679c7b38f307fdde7d7fe639f (diff)
downloadorg.eclipse.xpand-e07b2338575e245b19657f4312229419d7669943.zip
org.eclipse.xpand-e07b2338575e245b19657f4312229419d7669943.tar.gz
org.eclipse.xpand-e07b2338575e245b19657f4312229419d7669943.tar.bz2
introduced AbstractExecutionContextAware, a convenience default implementation of the interface
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/functions/java/AbstractExecutionContextAware.java31
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/MapType.java43
2 files changed, 74 insertions, 0 deletions
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/functions/java/AbstractExecutionContextAware.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/functions/java/AbstractExecutionContextAware.java
new file mode 100644
index 0000000..9abfaa1
--- /dev/null
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/functions/java/AbstractExecutionContextAware.java
@@ -0,0 +1,31 @@
+/*
+Copyright (c) 2008 Arno Haase.
+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:
+ Arno Haase - initial API and implementation
+ */
+package org.eclipse.xtend.backend.functions.java;
+
+import org.eclipse.xtend.backend.common.ExecutionContext;
+
+
+/**
+ * This is a convenient default implementation of the marker interface ExecutionContextAware.
+ *
+ * @author Arno Haase (http://www.haase-consulting.com)
+ */
+public abstract class AbstractExecutionContextAware implements ExecutionContextAware {
+ protected ExecutionContext _ctx;
+
+ public final void setExecutionContext (ExecutionContext ctx) {
+ _ctx = ctx;
+ }
+
+ protected ExecutionContext getExecutionContext () {
+ return _ctx;
+ }
+}
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/MapType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/MapType.java
new file mode 100644
index 0000000..d563498
--- /dev/null
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/MapType.java
@@ -0,0 +1,43 @@
+/*
+Copyright (c) 2008 Arno Haase.
+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:
+ Arno Haase - initial API and implementation
+ */
+package org.eclipse.xtend.backend.types.builtin;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+import org.eclipse.xtend.backend.common.BackendType;
+import org.eclipse.xtend.backend.types.AbstractType;
+import org.eclipse.xtend.backend.util.ReflectionHelper;
+
+
+/**
+ *
+ * @author Arno Haase (http://www.haase-consulting.com)
+ */
+public final class MapType extends AbstractType {
+ private MapType () {
+ super ("Map");
+
+ register (new BuiltinProperty (CollectionType.INSTANCE, LongType.INSTANCE, "size", ReflectionHelper.getKnownMethod(Collection.class, "size"), null));
+ register (new BuiltinProperty (CollectionType.INSTANCE, BooleanType.INSTANCE, "isEmpty", ReflectionHelper.getKnownMethod(Collection.class, "isEmpty"), null));
+ }
+
+ public static final MapType INSTANCE = new MapType ();
+
+ @Override
+ public Object create() {
+ return new HashMap <Object,Object> ();
+ }
+
+ public boolean isAssignableFrom (BackendType other) {
+ return other == this || other == VoidType.INSTANCE;
+ }
+}