Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 00000000..9abfaa1f
--- /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 00000000..d5634986
--- /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;
+ }
+}

Back to the top