forked from mbebenita/j2me.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jsshell.js
executable file
·102 lines (83 loc) · 2.42 KB
/
jsshell.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
'use strict';
function check() {
}
if (scriptArgs.length !== 1) {
print("error: One main class name must be specified.");
print("usage: jsshell <main class name>");
quit(1);
}
var window = {
setZeroTimeout: function(callback) {
callback();
},
addEventListener: function() {
},
crypto: {
getRandomValues: function() {
},
},
};
var navigator = {
language: "en-US",
};
var document = {
documentElement: {
classList: {
add: function() {
},
},
},
querySelector: function() {
return {
addEventListener: function() {
},
};
},
getElementById: function() {
return {
addEventListener: function() {
},
getContext: function() {
},
getBoundingClientRect: function() {
return { top: 0, left: 0, width: 0, height: 0 };
}
};
},
addEventListener: function() {
},
};
var urlParams = {
logConsole: "native",
args: "",
};
try {
load("libs/zipfile.js", "blackBox.js", "build/j2me.js", "classfile/classfile.js",
"classfile/reader.js", "classfile/tags.js", "classfile/attributetypes.js",
"libs/encoding.js", "util.js", "frame.js",
"classfile/accessflags.js", "instrument.js", "signature.js", "opcodes.js",
"override.js", "native.js", "tests/override.js",
"string.js", "libs/console.js", "midp/midp.js",
"libs/long.js", "midp/crypto.js", "libs/forge/md5.js", "libs/forge/util.js", "build/compiled.js");
var dump = putstr;
var console = window.console;
CLASSES.addSourceDirectory("java/cldc1.1.1");
CLASSES.addSourceDirectory("java/midp");
CLASSES.addSourceDirectory("bench/scimark2src");
CLASSES.addPath("java/classes.jar", snarf("java/classes.jar", "binary").buffer);
CLASSES.addPath("tests/tests.jar", snarf("tests/tests.jar", "binary").buffer);
CLASSES.addPath("bench/scimark2.jar", snarf("bench/scimark2.jar", "binary").buffer);
CLASSES.initializeBuiltinClasses();
var start = dateNow();
var jvm = new JVM();
print("INITIALIZATION TIME: " + (dateNow() - start));
start = dateNow();
var runtime = jvm.startIsolate0(scriptArgs[0], urlParams.args);
print("RUNNING TIME: " + (dateNow() - start));
// J2ME.interpreterCounter.traceSorted(new J2ME.IndentingWriter());
} catch (x) {
print(x);
print(x.stack);
}