2014-10-01 08:11:58 +04:00
|
|
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2015-01-30 02:02:57 +03:00
|
|
|
if (typeof console === "undefined") {
|
|
|
|
var console = {
|
|
|
|
log: print
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.print = function (c) {
|
|
|
|
putstr(String.fromCharCode(c));
|
|
|
|
};
|
2015-01-19 06:54:01 +03:00
|
|
|
|
2014-11-18 12:03:00 +03:00
|
|
|
function check() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-10-16 00:42:34 +04:00
|
|
|
if (scriptArgs.length !== 1) {
|
|
|
|
print("error: One main class name must be specified.");
|
|
|
|
print("usage: jsshell <main class name>");
|
|
|
|
quit(1);
|
|
|
|
}
|
|
|
|
|
2015-01-19 06:54:01 +03:00
|
|
|
var callbacks = [];
|
2014-10-01 08:11:58 +04:00
|
|
|
var window = {
|
|
|
|
setZeroTimeout: function(callback) {
|
2015-01-19 06:54:01 +03:00
|
|
|
callbacks.push(callback);
|
2014-10-01 08:11:58 +04:00
|
|
|
},
|
|
|
|
addEventListener: function() {
|
|
|
|
},
|
|
|
|
crypto: {
|
|
|
|
getRandomValues: function() {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
var navigator = {
|
|
|
|
language: "en-US",
|
|
|
|
};
|
|
|
|
|
2014-12-20 01:36:06 +03:00
|
|
|
function Promise() {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
2014-10-01 08:11:58 +04:00
|
|
|
var document = {
|
|
|
|
documentElement: {
|
|
|
|
classList: {
|
|
|
|
add: function() {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
querySelector: function() {
|
|
|
|
return {
|
|
|
|
addEventListener: function() {
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
getElementById: function() {
|
|
|
|
return {
|
|
|
|
addEventListener: function() {
|
|
|
|
},
|
|
|
|
getContext: function() {
|
|
|
|
},
|
2014-11-18 03:25:34 +03:00
|
|
|
getBoundingClientRect: function() {
|
|
|
|
return { top: 0, left: 0, width: 0, height: 0 };
|
|
|
|
}
|
2014-10-01 08:11:58 +04:00
|
|
|
};
|
|
|
|
},
|
2014-11-18 03:25:34 +03:00
|
|
|
addEventListener: function() {
|
|
|
|
},
|
2014-10-01 08:11:58 +04:00
|
|
|
};
|
|
|
|
|
2015-01-14 00:33:17 +03:00
|
|
|
var config = {
|
2014-10-01 08:11:58 +04:00
|
|
|
logConsole: "native",
|
|
|
|
args: "",
|
|
|
|
};
|
|
|
|
|
2014-10-13 23:29:53 +04:00
|
|
|
try {
|
2015-01-30 02:02:57 +03:00
|
|
|
load("libs/relooper.js", "build/j2me.js","libs/zipfile.js", "blackBox.js",
|
2014-12-31 23:45:52 +03:00
|
|
|
"libs/encoding.js", "util.js",
|
|
|
|
"instrument.js",
|
2014-12-01 22:35:09 +03:00
|
|
|
"override.js", "native.js", "tests/override.js",
|
2015-01-19 06:54:01 +03:00
|
|
|
"string.js", "midp/midp.js",
|
2014-12-20 01:36:06 +03:00
|
|
|
"libs/long.js", "midp/crypto.js", "libs/forge/md5.js", "libs/forge/util.js");
|
|
|
|
|
2015-01-19 06:54:01 +03:00
|
|
|
// load("build/classes.jar.js");
|
|
|
|
// load("build/program.jar.js");
|
2015-01-30 02:02:57 +03:00
|
|
|
// load("build/tests.jar.js");
|
2014-10-01 08:11:58 +04:00
|
|
|
|
2014-12-13 02:00:34 +03:00
|
|
|
var dump = putstr;
|
2014-10-01 08:11:58 +04:00
|
|
|
|
2014-11-27 14:28:52 +03:00
|
|
|
CLASSES.addSourceDirectory("java/cldc1.1.1");
|
|
|
|
CLASSES.addSourceDirectory("java/midp");
|
2015-01-19 06:54:01 +03:00
|
|
|
// CLASSES.addSourceDirectory("bench/scimark2src");
|
2014-11-27 14:28:52 +03:00
|
|
|
|
2014-11-26 12:21:11 +03:00
|
|
|
CLASSES.addPath("java/classes.jar", snarf("java/classes.jar", "binary").buffer);
|
2014-12-01 11:04:48 +03:00
|
|
|
CLASSES.addPath("tests/tests.jar", snarf("tests/tests.jar", "binary").buffer);
|
2015-01-19 06:54:01 +03:00
|
|
|
//CLASSES.addPath("program.jar", snarf("program.jar", "binary").buffer);
|
2014-12-08 21:55:05 +03:00
|
|
|
|
2014-11-26 12:21:11 +03:00
|
|
|
CLASSES.initializeBuiltinClasses();
|
2014-10-02 22:50:33 +04:00
|
|
|
|
2014-11-26 12:21:11 +03:00
|
|
|
var start = dateNow();
|
2014-10-13 23:29:53 +04:00
|
|
|
var jvm = new JVM();
|
2014-10-01 08:11:58 +04:00
|
|
|
|
2015-01-30 02:02:57 +03:00
|
|
|
J2ME.writers = J2ME.WriterFlags.JIT;
|
2014-12-20 01:36:06 +03:00
|
|
|
|
2014-10-13 23:29:53 +04:00
|
|
|
print("INITIALIZATION TIME: " + (dateNow() - start));
|
2014-10-02 22:50:33 +04:00
|
|
|
|
2014-10-13 23:29:53 +04:00
|
|
|
start = dateNow();
|
2015-01-14 05:08:48 +03:00
|
|
|
var runtime = jvm.startIsolate0(scriptArgs[0], config.args);
|
2014-10-02 22:50:33 +04:00
|
|
|
|
2015-01-19 06:54:01 +03:00
|
|
|
while (callbacks.length) {
|
|
|
|
(callbacks.shift())();
|
|
|
|
}
|
|
|
|
|
2014-10-13 23:29:53 +04:00
|
|
|
print("RUNNING TIME: " + (dateNow() - start));
|
2014-12-01 03:21:34 +03:00
|
|
|
|
2014-12-12 03:04:20 +03:00
|
|
|
// J2ME.interpreterCounter.traceSorted(new J2ME.IndentingWriter());
|
2014-12-01 03:21:34 +03:00
|
|
|
|
2014-10-13 23:29:53 +04:00
|
|
|
} catch (x) {
|
|
|
|
print(x);
|
|
|
|
print(x.stack);
|
|
|
|
}
|