Permalink
Browse files

Merge pull request #62 from jetztgradnet/miscchanges2

Improved startup and auto-detection of Erlang environment + Misc changes
  • Loading branch information...
2 parents 6ab2ac7 + 14888f3 commit 844949844053155a57ac38359762c656f7dd0a96 @krestenkrab krestenkrab committed Apr 14, 2012
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
+<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="true"/>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM Contents (MacOS X Default)"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.launching.remote.InternalAntRunner"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="erjang"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/erjang/weave.xml}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/erjang}"/>
+<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
+</launchConfiguration>
View
@@ -7,4 +7,7 @@ classes
target
*.beam
src/main/java/erjang/beam/interpreter/Interpreter.java
-src/test/java/erjang/*_TEST.java
+src/test/java/erjang/*_TEST.java
+otp-*.jar
+erjang.log*
+*.launch
View
@@ -6,18 +6,18 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.dltk.core.scriptbuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.erjang.kilim_builder.KilimBuilder</name>
+ <name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
+ <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
+ <triggers>full,incremental,</triggers>
<arguments>
+ <dictionary>
+ <key>LaunchConfigHandle</key>
+ <value>&lt;project&gt;/.externalToolBuilders/Kilim Weaver.launch</value>
+ </dictionary>
</arguments>
</buildCommand>
</buildSpec>
View
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<project name="erjang" default="all">
- <property name="erjang.version" value="0.1" />
+ <property name="erjang.version" value="0.2" />
<property file="erjang_cfg.properties" />
<path id="erjang.classpath">
View
10 ej
@@ -7,23 +7,15 @@ EJ_CMD=`which "$0"`
while LINK=`readlink "$EJ_CMD"`; do EJ_CMD=$LINK; done
ERJANG_DIR=`dirname "$EJ_CMD"`
-source "$ERJANG_DIR/env_cfg"
-
## -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=n,suspend=n \
exec java \
-server \
-Xmx1g -Xss50m \
-XX:PermSize=128m \
- -Derjang.configfile="$PROP_FILE" \
- -Derjang.erts.version="$ERTS_VSN" \
- -Derjang.otp.version="$OTP_VSN" \
- -jar $ERJANG_DIR/erjang-0.1.jar \
+ -jar $ERJANG_DIR/erjang-0.2.jar \
\
-progname ej \
- -home "$HOME" \
- -root "$ERL_ROOT" \
+A 10 \
+S 1 \
- +e "$ERTS_VSN" \
"$@"
View
10 ejc
@@ -7,8 +7,6 @@ EJC_CMD=`which "$0"`
while LINK=`readlink "$EJC_CMD"`; do EJC_CMD=$LINK; done
ERJANG_DIR=`dirname "$EJC_CMD"`
-source "$ERJANG_DIR/env_cfg"
-
###########################################################
# OS X - specific config
if [[ $(uname) == "Darwin" ]]; then
@@ -24,14 +22,8 @@ exec java \
-Xmx2g \
$OSX_DOCK_ICON \
$OSX_DOCK_NAME \
- -Derjang.configfile="$PROP_FILE" \
- -Derjang.erts.version="$ERTS_VSN" \
- -Derjang.otp.version="$OTP_VSN" \
- -cp "$ERJANG_DIR/erjang-0.1.jar" erjang.console.ERLConsole \
+ -cp "$ERJANG_DIR/erjang-0.2.jar" erjang.console.ERLConsole \
\
- -root "$ERL_ROOT" \
+A 10 \
+S 1 \
- +e "$ERTS_VSN" \
- -home "$HOME" \
"$@"
View
@@ -1,6 +1,6 @@
-erjang.otp.root = /usr/local/lib/erlang
-erjang.erts.version = 5.8.3
-erjang.otp.version = R14B02
+#erjang.otp.root = /usr/local/lib/erlang
+#erjang.erts.version = 5.8.3
+#erjang.otp.version = R14B02
# erjang.debug.port=true
# erjang.debug.inet=true
View
@@ -2,7 +2,7 @@
IF "x%OTPROOT%" == "x" SET OTPROOT="C:/Program Files/erl5.7.5"
-java -cp erjang-0.1.jar ^
+java -cp erjang-0.2.jar ^
erjang.Main ^
-root %OTPROOT% ^
%1 %2 %3 %4 %5 %6 %7 %8 %9
View
@@ -1,3 +1,3 @@
#!/bin/sh
-java -server -cp erjang-0.1.jar -Derjpath=./src/main/erl/preloaded/ebin:src/main/erl erjang.Erj fib:main
+java -server -cp erjang-0.2.jar -Derjpath=./src/main/erl/preloaded/ebin:src/main/erl erjang.Erj fib:main
@@ -21,14 +21,15 @@
import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;
import java.io.IOException;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
import erjang.m.ets.EMatchContext;
import erjang.m.ets.EPattern;
import erjang.m.ets.ETermPattern;
-public abstract class ECons extends EObject {
+public abstract class ECons extends EObject implements Iterable<EObject> {
@Override
int cmp_order() {
@@ -241,4 +242,8 @@ public void collectCharList(CharCollector out)
} else tail.collectCharList(out);
}
+ @Override
+ public Iterator<EObject> iterator() {
+ return new EObjectIterator(this);
+ }
}
@@ -0,0 +1,58 @@
+package erjang;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+
+public class EObjectIterator implements Iterator<EObject> {
+ private EObject object = null;
+
+ public EObjectIterator(EObject object) {
+ this.object = object;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#hasNext()
+ */
+ public boolean hasNext() {
+ if (object == null) {
+ return false;
+ }
+ return !object.isNil();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#next()
+ */
+ public EObject next() {
+ if ((object == null)
+ || object.isNil()) {
+ throw new NoSuchElementException();
+ }
+
+ EObject next;
+
+ ECons cons = object.testCons();
+ if ((cons != null)
+ // TODO how to handle EString? return each character? Or return it as single element only?
+ // for now we don't treat EString as collection, but as single element
+ && !(cons instanceof EString)) {
+ next = cons.head();
+ object = cons.tail();
+ }
+ else {
+ // simple object, return it and set next object to null
+ next = object;
+ object = null;
+ }
+ return next;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#remove()
+ */
+ public void remove() {
+ // not supported
+ throw new UnsupportedOperationException();
+ }
+}
@@ -626,7 +626,7 @@ public static EFun resolve_fun(EObject mod, EObject fun, int arity) {
final EFun pfun = EModuleManager.resolve(new FunID(pmod, f, arity+1));
- return EFun.get_fun_with_handler(m.toString(), f.toString(), arity, new EFunHandler() {
+ return EFun.get_fun_with_handler(pmod.toString(), f.toString(), arity, new EFunHandler() {
@Override
public EObject invoke(EProc proc, EObject[] args) throws Pausable {
EObject[] real_args = new EObject[args.length+1];
@@ -1141,4 +1141,18 @@ public void write(byte[] b, int off, int len) throws IOException {
}
}
+ /**
+ * contains versions, paths and other information.
+ * use {@link ERT#setRuntimeInfo(RuntimeInfo)} to set this field.
+ */
+ public static RuntimeInfo runtime_info = null;
+
+ public static void setRuntimeInfo(RuntimeInfo info) {
+ // TODO perform synchronization? We usually set this
+ // field only once from Main before ERT is started
+ runtime_info = info;
+ if (runtime_info != null) {
+ System.setProperty("erjang.path", runtime_info.erl_bootstrap_ebindir);
+ }
+ }
}
@@ -36,9 +36,9 @@
static {
String configFileName = System.getProperty("erjang.configfile");
- if (configFileName != null) {
+ if (configFileName != null && configFileName.trim().length() > 0) {
try {
- FileInputStream in = new FileInputStream(configFileName);
+ FileInputStream in = new FileInputStream(configFileName.trim());
try {
Properties properties = new Properties();
properties.load(in);
Oops, something went wrong.

0 comments on commit 8449498

Please sign in to comment.