@quenk/potoo 4.0.7 → 4.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actor/address.js.map +1 -1
- package/lib/actor/api.d.ts +2 -2
- package/lib/actor/api.js.map +1 -1
- package/lib/actor/framework/index.js +2 -2
- package/lib/actor/framework/index.js.map +1 -1
- package/lib/actor/framework/process.d.ts +3 -2
- package/lib/actor/framework/process.js.map +1 -1
- package/lib/actor/framework/resident.d.ts +5 -3
- package/lib/actor/framework/resident.js +2 -0
- package/lib/actor/framework/resident.js.map +1 -1
- package/lib/actor/index.js.map +1 -1
- package/lib/actor/system/vm/allocator/index.js.map +1 -1
- package/lib/actor/system/vm/allocator/map.js +7 -4
- package/lib/actor/system/vm/allocator/map.js.map +1 -1
- package/lib/actor/system/vm/conf.js.map +1 -1
- package/lib/actor/system/vm/event/dispatcher.d.ts +31 -12
- package/lib/actor/system/vm/event/dispatcher.js +72 -20
- package/lib/actor/system/vm/event/dispatcher.js.map +1 -1
- package/lib/actor/system/vm/event/index.js.map +1 -1
- package/lib/actor/system/vm/frame.js.map +1 -1
- package/lib/actor/system/vm/group.js.map +1 -1
- package/lib/actor/system/vm/index.js +2 -2
- package/lib/actor/system/vm/index.js.map +1 -1
- package/lib/actor/system/vm/log/index.js.map +1 -1
- package/lib/actor/system/vm/log/writer.js.map +1 -1
- package/lib/actor/system/vm/object/foreign.js.map +1 -1
- package/lib/actor/system/vm/object/index.js.map +1 -1
- package/lib/actor/system/vm/object/list.js.map +1 -1
- package/lib/actor/system/vm/op/actor.js.map +1 -1
- package/lib/actor/system/vm/op/base.js.map +1 -1
- package/lib/actor/system/vm/op/index.js.map +1 -1
- package/lib/actor/system/vm/op/object.js.map +1 -1
- package/lib/actor/system/vm/registry.js.map +1 -1
- package/lib/actor/system/vm/runtime/error.js.map +1 -1
- package/lib/actor/system/vm/runtime.js.map +1 -1
- package/lib/actor/system/vm/scheduler.js.map +1 -1
- package/lib/actor/system/vm/script/index.js.map +1 -1
- package/lib/actor/system/vm/script/info.js.map +1 -1
- package/lib/actor/system/vm/strategy/error.js.map +1 -1
- package/lib/actor/system/vm/thread/factory.js.map +1 -1
- package/lib/actor/system/vm/thread/index.js.map +1 -1
- package/lib/actor/system/vm/thread/process.js.map +1 -1
- package/lib/actor/system/vm/thread/shared/index.js.map +1 -1
- package/lib/actor/system/vm/thread/shared/js.d.ts +2 -2
- package/lib/actor/system/vm/thread/shared/js.js +3 -3
- package/lib/actor/system/vm/thread/shared/js.js.map +1 -1
- package/lib/actor/system/vm/type.js.map +1 -1
- package/lib/actor/template.d.ts +20 -0
- package/lib/actor/template.js +17 -1
- package/lib/actor/template.js.map +1 -1
- package/package.json +11 -9
- package/lib/actor/address.ts +0 -90
- package/lib/actor/api.ts +0 -57
- package/lib/actor/framework/index.ts +0 -1
- package/lib/actor/framework/process.ts +0 -87
- package/lib/actor/framework/resident.ts +0 -90
- package/lib/actor/index.ts +0 -35
- package/lib/actor/system/vm/allocator/index.ts +0 -43
- package/lib/actor/system/vm/allocator/map.ts +0 -256
- package/lib/actor/system/vm/conf.ts +0 -33
- package/lib/actor/system/vm/event/dispatcher.ts +0 -85
- package/lib/actor/system/vm/event/index.ts +0 -143
- package/lib/actor/system/vm/frame.ts +0 -484
- package/lib/actor/system/vm/group.ts +0 -46
- package/lib/actor/system/vm/index.ts +0 -230
- package/lib/actor/system/vm/log/index.ts +0 -73
- package/lib/actor/system/vm/log/writer.ts +0 -96
- package/lib/actor/system/vm/object/foreign.ts +0 -10
- package/lib/actor/system/vm/object/index.ts +0 -4
- package/lib/actor/system/vm/object/list.ts +0 -8
- package/lib/actor/system/vm/op/actor.ts +0 -126
- package/lib/actor/system/vm/op/base.ts +0 -243
- package/lib/actor/system/vm/op/index.ts +0 -388
- package/lib/actor/system/vm/op/object.ts +0 -81
- package/lib/actor/system/vm/registry.ts +0 -223
- package/lib/actor/system/vm/runtime/error.ts +0 -248
- package/lib/actor/system/vm/runtime.ts +0 -31
- package/lib/actor/system/vm/scheduler.ts +0 -108
- package/lib/actor/system/vm/script/index.ts +0 -64
- package/lib/actor/system/vm/script/info.ts +0 -359
- package/lib/actor/system/vm/strategy/error.ts +0 -88
- package/lib/actor/system/vm/thread/factory.ts +0 -29
- package/lib/actor/system/vm/thread/index.ts +0 -29
- package/lib/actor/system/vm/thread/process.ts +0 -134
- package/lib/actor/system/vm/thread/shared/index.ts +0 -50
- package/lib/actor/system/vm/thread/shared/js.ts +0 -151
- package/lib/actor/system/vm/type.ts +0 -115
- package/lib/actor/template.ts +0 -170
- package/lib/tsconfig.json +0 -22
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import * as error from '../runtime/error';
|
|
2
|
-
|
|
3
|
-
import { JSThread } from '../thread/shared/js';
|
|
4
|
-
import { Frame, DATA_MAX_SAFE_UINT32 } from '../frame';
|
|
5
|
-
import { Operand } from '.';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* nop does nothing.
|
|
9
|
-
*
|
|
10
|
-
* Stack:
|
|
11
|
-
* ->
|
|
12
|
-
*/
|
|
13
|
-
export const nop = (_: JSThread, __: Frame, ___: Operand) => {};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* pushui8 pushes an unsigned 8bit integer onto the stack.
|
|
17
|
-
*
|
|
18
|
-
* Stack:
|
|
19
|
-
* -> <uint8>
|
|
20
|
-
*/
|
|
21
|
-
export const pushui8 = (_: JSThread, f: Frame, oper: Operand) => {
|
|
22
|
-
f.pushUInt8(oper);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* pushui16 pushes an unsigned 16bit integer onto the stack.
|
|
27
|
-
*
|
|
28
|
-
* Stack:
|
|
29
|
-
* -> <uint16>
|
|
30
|
-
*/
|
|
31
|
-
export const pushui16 = (_: JSThread, f: Frame, oper: Operand) => {
|
|
32
|
-
f.pushUInt16(oper);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* pushui32 pushes an unsigned 32bit integer onto the stack.
|
|
37
|
-
*
|
|
38
|
-
* NOTE: In a future revision, the operand may be treated as an index.
|
|
39
|
-
* Stack:
|
|
40
|
-
* -> <uint32>
|
|
41
|
-
*/
|
|
42
|
-
export const pushui32 = (_: JSThread, f: Frame, oper: Operand) => {
|
|
43
|
-
f.pushUInt32(oper);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* lds loads a string from the constant pool onto the stack.
|
|
48
|
-
*
|
|
49
|
-
* Stack:
|
|
50
|
-
* -> <string>
|
|
51
|
-
*/
|
|
52
|
-
export const lds = (_: JSThread, f: Frame, idx: Operand) => {
|
|
53
|
-
f.pushString(idx);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* ldn loads an info object from the compiled script.
|
|
58
|
-
*
|
|
59
|
-
* -> <value>
|
|
60
|
-
*/
|
|
61
|
-
export const ldn = (_: JSThread, f: Frame, idx: Operand) => {
|
|
62
|
-
f.pushName(idx);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* dup duplicates the value on top of the data stack.
|
|
67
|
-
*
|
|
68
|
-
* Stack:
|
|
69
|
-
* <any> -> <any>,<any>
|
|
70
|
-
*/
|
|
71
|
-
export const dup = (_: JSThread, f: Frame, __: Operand) => {
|
|
72
|
-
f.duplicate();
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* store the value at the top of the data stack in the variable indicated
|
|
77
|
-
* by idx.
|
|
78
|
-
*
|
|
79
|
-
* Stack:
|
|
80
|
-
* <any> ->
|
|
81
|
-
*/
|
|
82
|
-
export const store = (_: JSThread, f: Frame, idx: Operand) => {
|
|
83
|
-
f.locals[idx] = f.pop();
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* load the value stored at idx in the variables array onto the top of the
|
|
88
|
-
* stack.
|
|
89
|
-
*
|
|
90
|
-
* If the variable is undefined 0 is placed on the stack.
|
|
91
|
-
*
|
|
92
|
-
* Stack:
|
|
93
|
-
* -> <any>
|
|
94
|
-
*/
|
|
95
|
-
export const load = (_: JSThread, f: Frame, idx: Operand) => {
|
|
96
|
-
let d = f.locals[idx];
|
|
97
|
-
|
|
98
|
-
f.push(d == null ? 0 : d);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* ceq compares two values for equality.
|
|
103
|
-
*
|
|
104
|
-
* Pushes 1 if true, 0 otherwise.
|
|
105
|
-
*
|
|
106
|
-
* Stack:
|
|
107
|
-
*
|
|
108
|
-
* <val1>,<val2> -> <unint32>
|
|
109
|
-
*/
|
|
110
|
-
export const ceq = (r: JSThread, f: Frame, __: Operand) => {
|
|
111
|
-
//TODO: Should null == null or raise an error?
|
|
112
|
-
|
|
113
|
-
let eLhs = f.popValue();
|
|
114
|
-
|
|
115
|
-
let eRhs = f.popValue();
|
|
116
|
-
|
|
117
|
-
if (eLhs.isLeft()) return r.raise(eLhs.takeLeft());
|
|
118
|
-
|
|
119
|
-
if (eRhs.isLeft()) return r.raise(eRhs.takeLeft());
|
|
120
|
-
|
|
121
|
-
if (eLhs.takeRight() === eRhs.takeRight()) f.push(1);
|
|
122
|
-
else f.push(0);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* addui32 treats the top two operands on the data stack as uint32s and adds
|
|
127
|
-
* them.
|
|
128
|
-
*
|
|
129
|
-
* The result is a 32 bit value. If the result is more than MAX_SAFE_INTEGER an
|
|
130
|
-
* IntergerOverflowErr will be raised.
|
|
131
|
-
*/
|
|
132
|
-
export const addui32 = (r: JSThread, f: Frame, _: Operand) => {
|
|
133
|
-
let val = f.pop() + f.pop();
|
|
134
|
-
|
|
135
|
-
if (val > DATA_MAX_SAFE_UINT32)
|
|
136
|
-
return r.raise(new error.IntegerOverflowErr());
|
|
137
|
-
|
|
138
|
-
f.push(val);
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* call a function placing its result on the heap.
|
|
143
|
-
*
|
|
144
|
-
* Stack:
|
|
145
|
-
*
|
|
146
|
-
* <arg>...? -> <result>
|
|
147
|
-
*/
|
|
148
|
-
export const call = (r: JSThread, f: Frame, _: Operand) => {
|
|
149
|
-
let einfo = f.popFunction();
|
|
150
|
-
|
|
151
|
-
if (einfo.isLeft()) return r.raise(einfo.takeLeft());
|
|
152
|
-
|
|
153
|
-
let fn = einfo.takeRight();
|
|
154
|
-
|
|
155
|
-
if (fn.foreign === true) {
|
|
156
|
-
//TODO: This is unsafe but the extent of its effect on overall stability
|
|
157
|
-
// should be compared to the time taken to ensure each value.
|
|
158
|
-
// let args = make(fn.argc || 0, () => f.popValue().takeRight());
|
|
159
|
-
// r.invokeForeign(f, <ForeignFunInfo>fn, args);
|
|
160
|
-
} else {
|
|
161
|
-
// r.invokeVM(f, fn);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* raise an exception.
|
|
167
|
-
*
|
|
168
|
-
* Stack:
|
|
169
|
-
*
|
|
170
|
-
* <message> ->
|
|
171
|
-
*/
|
|
172
|
-
export const raise = (r: JSThread, f: Frame, _: Operand) => {
|
|
173
|
-
let emsg = f.popString();
|
|
174
|
-
|
|
175
|
-
r.raise(new Error(emsg.takeRight()));
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* jmp jumps to the instruction at the specified address.
|
|
180
|
-
*
|
|
181
|
-
* Stack:
|
|
182
|
-
* ->
|
|
183
|
-
*/
|
|
184
|
-
export const jmp = (_: JSThread, f: Frame, oper: Operand) => {
|
|
185
|
-
f.seek(oper);
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* ifzjmp jumps to the instruction at the specified address if the top
|
|
190
|
-
* of the stack is === 0.
|
|
191
|
-
*
|
|
192
|
-
* Stack:
|
|
193
|
-
*
|
|
194
|
-
* <uint32> ->
|
|
195
|
-
*/
|
|
196
|
-
export const ifzjmp = (_: JSThread, f: Frame, oper: Operand) => {
|
|
197
|
-
let eValue = f.popValue();
|
|
198
|
-
|
|
199
|
-
if (eValue.isLeft() || eValue.takeRight() === 0) f.seek(oper);
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* ifnzjmp jumps to the instruction at the specified address if the top
|
|
204
|
-
* of the stack is !== 0.
|
|
205
|
-
*
|
|
206
|
-
* Stack:
|
|
207
|
-
* <uint32> ->
|
|
208
|
-
*/
|
|
209
|
-
export const ifnzjmp = (_: JSThread, f: Frame, oper: Operand) => {
|
|
210
|
-
let eValue = f.popValue();
|
|
211
|
-
|
|
212
|
-
if (eValue.isRight() && eValue.takeRight() !== 0) f.seek(oper);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* ifeqjmp jumps to the instruction at the specified address if the top
|
|
217
|
-
* two elements of the stack are strictly equal to each other.
|
|
218
|
-
* Stack:
|
|
219
|
-
* <any><any> ->
|
|
220
|
-
*/
|
|
221
|
-
export const ifeqjmp = (r: JSThread, f: Frame, oper: Operand) => {
|
|
222
|
-
let eLhs = f.popValue();
|
|
223
|
-
let eRhs = f.popValue();
|
|
224
|
-
|
|
225
|
-
if (eLhs.isLeft()) r.raise(eLhs.takeLeft());
|
|
226
|
-
else if (eRhs.isLeft()) r.raise(eRhs.takeLeft());
|
|
227
|
-
else if (eLhs.takeRight() === eRhs.takeRight()) f.seek(oper);
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* ifneqjmp jumps to the instruction at the specified address if the top
|
|
232
|
-
* two elements of the stack are not strictly equal to each other.
|
|
233
|
-
* Stack:
|
|
234
|
-
* <any><any> ->
|
|
235
|
-
*/
|
|
236
|
-
export const ifneqjmp = (r: JSThread, f: Frame, oper: Operand) => {
|
|
237
|
-
let eLhs = f.popValue();
|
|
238
|
-
let eRhs = f.popValue();
|
|
239
|
-
|
|
240
|
-
if (eLhs.isLeft()) r.raise(eLhs.takeLeft());
|
|
241
|
-
else if (eRhs.isLeft()) r.raise(eRhs.takeLeft());
|
|
242
|
-
else if (eLhs.takeRight() !== eRhs.takeRight()) f.seek(oper);
|
|
243
|
-
};
|
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
import * as base from './base';
|
|
2
|
-
import * as actor from './actor';
|
|
3
|
-
import * as obj from './object';
|
|
4
|
-
|
|
5
|
-
import { Record, map } from '@quenk/noni/lib/data/record';
|
|
6
|
-
import { Either } from '@quenk/noni/lib/data/either';
|
|
7
|
-
import { Err } from '@quenk/noni/lib/control/error';
|
|
8
|
-
import { Type } from '@quenk/noni/lib/data/type';
|
|
9
|
-
|
|
10
|
-
import { JSThread } from '../thread/shared/js';
|
|
11
|
-
import {
|
|
12
|
-
Frame,
|
|
13
|
-
DATA_TYPE_INFO,
|
|
14
|
-
DATA_TYPE_STRING,
|
|
15
|
-
DATA_TYPE_LOCAL
|
|
16
|
-
} from '../frame';
|
|
17
|
-
import { PTValue } from '../type';
|
|
18
|
-
|
|
19
|
-
export const OP_CODE_RANGE_LOW = 0x1000000;
|
|
20
|
-
export const OP_CODE_RANGE_HIGH = 0xff000000;
|
|
21
|
-
export const OP_CODE_RANGE_STEP = 0x1000000;
|
|
22
|
-
|
|
23
|
-
export const OPCODE_MASK = 0xff000000;
|
|
24
|
-
export const OPERAND_MASK = 0x00ffffff;
|
|
25
|
-
export const OPCODE_RANGE_START = 0x1000000;
|
|
26
|
-
export const OPCODE_RANGE_END = 0xff000000;
|
|
27
|
-
export const OPERAND_RANGE_START = 0x0;
|
|
28
|
-
export const OPERAND_RANGE_END = 0xffffff;
|
|
29
|
-
export const MAX_INSTRUCTION = 0xffffffff;
|
|
30
|
-
|
|
31
|
-
//NOTE: these can only be one of the highest byte in a 32 bit number.
|
|
32
|
-
export const NOP = OP_CODE_RANGE_STEP;
|
|
33
|
-
export const PUSHUI8 = OP_CODE_RANGE_STEP * 2;
|
|
34
|
-
export const PUSHUI16 = OP_CODE_RANGE_STEP * 3;
|
|
35
|
-
export const PUSHUI32 = OP_CODE_RANGE_STEP * 4;
|
|
36
|
-
export const LDS = OP_CODE_RANGE_STEP * 5;
|
|
37
|
-
export const LDN = OP_CODE_RANGE_STEP * 6;
|
|
38
|
-
export const DUP = OP_CODE_RANGE_STEP * 15;
|
|
39
|
-
export const STORE = OP_CODE_RANGE_STEP * 16;
|
|
40
|
-
export const LOAD = OP_CODE_RANGE_STEP * 20;
|
|
41
|
-
export const CEQ = OP_CODE_RANGE_STEP * 42;
|
|
42
|
-
export const ADDUI32 = OP_CODE_RANGE_STEP * 52;
|
|
43
|
-
export const CALL = OP_CODE_RANGE_STEP * 62;
|
|
44
|
-
export const RAISE = OP_CODE_RANGE_STEP * 63;
|
|
45
|
-
export const JMP = OP_CODE_RANGE_STEP * 72;
|
|
46
|
-
export const IFZJMP = OP_CODE_RANGE_STEP * 73;
|
|
47
|
-
export const IFNZJMP = OP_CODE_RANGE_STEP * 80;
|
|
48
|
-
export const IFEQJMP = OP_CODE_RANGE_STEP * 81;
|
|
49
|
-
export const IFNEQJMP = OP_CODE_RANGE_STEP * 82;
|
|
50
|
-
export const ALLOC = OP_CODE_RANGE_STEP * 92;
|
|
51
|
-
export const SEND = OP_CODE_RANGE_STEP * 94;
|
|
52
|
-
export const RECV = OP_CODE_RANGE_STEP * 95;
|
|
53
|
-
export const RECVCOUNT = OP_CODE_RANGE_STEP * 96;
|
|
54
|
-
export const MAILCOUNT = OP_CODE_RANGE_STEP * 97;
|
|
55
|
-
export const MAILDQ = OP_CODE_RANGE_STEP * 98;
|
|
56
|
-
export const SELF = OP_CODE_RANGE_STEP * 99;
|
|
57
|
-
export const STOP = OP_CODE_RANGE_STEP * 101;
|
|
58
|
-
export const GETPROP = OP_CODE_RANGE_STEP * 110;
|
|
59
|
-
export const ARLENGTH = OP_CODE_RANGE_STEP * 111;
|
|
60
|
-
export const ARELM = OP_CODE_RANGE_STEP * 112;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Opcode
|
|
64
|
-
*/
|
|
65
|
-
export type Opcode = number;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Operand
|
|
69
|
-
*/
|
|
70
|
-
export type Operand = number;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Instruction
|
|
74
|
-
*/
|
|
75
|
-
export type Instruction = number;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* OpcodeHandler
|
|
79
|
-
*/
|
|
80
|
-
export type OpcodeHandler = (r: JSThread, f: Frame, o: Operand) => void;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* OpcodeInfo provides needed details of a single opcode.
|
|
84
|
-
*/
|
|
85
|
-
export interface OpcodeInfo {
|
|
86
|
-
/**
|
|
87
|
-
* name is the mnemonic for the opcode.
|
|
88
|
-
*/
|
|
89
|
-
name: string;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* handler is the implementation function.
|
|
93
|
-
*/
|
|
94
|
-
handler: OpcodeHandler;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* log is a function that is applied to convert the op into an op log
|
|
98
|
-
* entry.
|
|
99
|
-
*/
|
|
100
|
-
log: (r: JSThread, f: Frame, oper: Operand) => Type[];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* OpcodeInfos is a map of opcode numbers to their respective OpCodeInfo objects.
|
|
105
|
-
*/
|
|
106
|
-
export interface OpcodeInfos extends Record<OpcodeInfo> {}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* OpcodeHandlers
|
|
110
|
-
*/
|
|
111
|
-
export interface OpcodeHandlers {
|
|
112
|
-
[key: number]: OpcodeHandler;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* opcodes
|
|
117
|
-
*/
|
|
118
|
-
export const opcodes: OpcodeInfos = {
|
|
119
|
-
[NOP]: {
|
|
120
|
-
name: 'nop',
|
|
121
|
-
|
|
122
|
-
handler: base.nop,
|
|
123
|
-
|
|
124
|
-
log: () => ['nop']
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
[PUSHUI8]: {
|
|
128
|
-
name: 'pushui8',
|
|
129
|
-
|
|
130
|
-
handler: base.pushui8,
|
|
131
|
-
|
|
132
|
-
log: (_: JSThread, __: Frame, oper: Operand) => ['pushui8', oper]
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
[PUSHUI16]: {
|
|
136
|
-
name: 'pushui16',
|
|
137
|
-
|
|
138
|
-
handler: base.pushui16,
|
|
139
|
-
|
|
140
|
-
log: (_: JSThread, __: Frame, oper: Operand) => ['pushui16', oper]
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
[PUSHUI32]: {
|
|
144
|
-
name: 'pushui32',
|
|
145
|
-
|
|
146
|
-
handler: base.pushui32,
|
|
147
|
-
|
|
148
|
-
log: (_: JSThread, __: Frame, oper: Operand) => ['pushui32', oper]
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
[LDS]: {
|
|
152
|
-
name: 'lds',
|
|
153
|
-
|
|
154
|
-
handler: base.lds,
|
|
155
|
-
|
|
156
|
-
log: (_: JSThread, f: Frame, oper: Operand) => [
|
|
157
|
-
'lds',
|
|
158
|
-
oper,
|
|
159
|
-
eToLog(f.resolve(DATA_TYPE_STRING | oper))
|
|
160
|
-
]
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
[LDN]: {
|
|
164
|
-
name: 'ldn',
|
|
165
|
-
|
|
166
|
-
handler: base.ldn,
|
|
167
|
-
|
|
168
|
-
log: (_: JSThread, f: Frame, oper: Operand) => [
|
|
169
|
-
'ldn',
|
|
170
|
-
oper,
|
|
171
|
-
eToLog(f.resolve(DATA_TYPE_INFO | oper))
|
|
172
|
-
]
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
[DUP]: {
|
|
176
|
-
name: 'dup',
|
|
177
|
-
|
|
178
|
-
handler: base.dup,
|
|
179
|
-
|
|
180
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['dup']
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
[STORE]: {
|
|
184
|
-
name: 'store',
|
|
185
|
-
|
|
186
|
-
handler: base.store,
|
|
187
|
-
|
|
188
|
-
log: (_: JSThread, __: Frame, oper: Operand) => ['store', oper]
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
[LOAD]: {
|
|
192
|
-
name: 'load',
|
|
193
|
-
|
|
194
|
-
handler: base.load,
|
|
195
|
-
|
|
196
|
-
log: (_: JSThread, f: Frame, oper: Operand) => [
|
|
197
|
-
'load',
|
|
198
|
-
oper,
|
|
199
|
-
eToLog(f.resolve(DATA_TYPE_LOCAL | oper))
|
|
200
|
-
]
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
[CEQ]: {
|
|
204
|
-
name: 'ceq',
|
|
205
|
-
|
|
206
|
-
handler: base.ceq,
|
|
207
|
-
|
|
208
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['ceq']
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
[ADDUI32]: {
|
|
212
|
-
name: 'addui32',
|
|
213
|
-
|
|
214
|
-
handler: base.addui32,
|
|
215
|
-
|
|
216
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['addui32']
|
|
217
|
-
},
|
|
218
|
-
|
|
219
|
-
[CALL]: {
|
|
220
|
-
name: 'call',
|
|
221
|
-
|
|
222
|
-
handler: base.call,
|
|
223
|
-
|
|
224
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['call']
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
[RAISE]: {
|
|
228
|
-
name: 'raise',
|
|
229
|
-
|
|
230
|
-
handler: base.raise,
|
|
231
|
-
|
|
232
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['raise']
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
[JMP]: {
|
|
236
|
-
name: 'jmp',
|
|
237
|
-
|
|
238
|
-
handler: base.jmp,
|
|
239
|
-
|
|
240
|
-
log: (_: JSThread, __: Frame, oper: Operand) => ['jmp', oper]
|
|
241
|
-
},
|
|
242
|
-
|
|
243
|
-
[IFZJMP]: {
|
|
244
|
-
name: 'ifzjmp',
|
|
245
|
-
|
|
246
|
-
handler: base.ifzjmp,
|
|
247
|
-
|
|
248
|
-
log: (_: JSThread, __: Frame, oper: Operand) => ['ifzjmp', oper]
|
|
249
|
-
},
|
|
250
|
-
|
|
251
|
-
[IFNZJMP]: {
|
|
252
|
-
name: 'ifnzjmp',
|
|
253
|
-
|
|
254
|
-
handler: base.ifnzjmp,
|
|
255
|
-
|
|
256
|
-
log: (_: JSThread, __: Frame, oper: Operand) => ['ifnzjmp', oper]
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
[IFEQJMP]: {
|
|
260
|
-
name: 'ifeqjmp',
|
|
261
|
-
|
|
262
|
-
handler: base.ifeqjmp,
|
|
263
|
-
|
|
264
|
-
log: (_: JSThread, __: Frame, oper: Operand) => ['ifeqjmp', oper]
|
|
265
|
-
},
|
|
266
|
-
|
|
267
|
-
[IFNEQJMP]: {
|
|
268
|
-
name: 'ifneqjmp',
|
|
269
|
-
|
|
270
|
-
handler: base.ifneqjmp,
|
|
271
|
-
|
|
272
|
-
log: (_: JSThread, __: Frame, oper: Operand) => ['ifneqjmp', oper]
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
[ALLOC]: {
|
|
276
|
-
name: 'alloc',
|
|
277
|
-
|
|
278
|
-
handler: actor.alloc,
|
|
279
|
-
|
|
280
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['alloc']
|
|
281
|
-
},
|
|
282
|
-
|
|
283
|
-
[SEND]: {
|
|
284
|
-
name: 'send',
|
|
285
|
-
|
|
286
|
-
handler: actor.send,
|
|
287
|
-
|
|
288
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['send']
|
|
289
|
-
},
|
|
290
|
-
|
|
291
|
-
[RECV]: {
|
|
292
|
-
name: 'recv',
|
|
293
|
-
|
|
294
|
-
handler: actor.recv,
|
|
295
|
-
|
|
296
|
-
log: (_: JSThread, f: Frame, oper: Operand) => [
|
|
297
|
-
'recv',
|
|
298
|
-
oper,
|
|
299
|
-
eToLog(f.resolve(DATA_TYPE_INFO | oper))
|
|
300
|
-
]
|
|
301
|
-
},
|
|
302
|
-
|
|
303
|
-
[RECVCOUNT]: {
|
|
304
|
-
name: 'recvcount',
|
|
305
|
-
|
|
306
|
-
handler: actor.recvcount,
|
|
307
|
-
|
|
308
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['recvcount']
|
|
309
|
-
},
|
|
310
|
-
|
|
311
|
-
[MAILCOUNT]: {
|
|
312
|
-
name: 'mailcount',
|
|
313
|
-
|
|
314
|
-
handler: actor.mailcount,
|
|
315
|
-
|
|
316
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['mailcount']
|
|
317
|
-
},
|
|
318
|
-
|
|
319
|
-
[MAILDQ]: {
|
|
320
|
-
name: 'maildq',
|
|
321
|
-
|
|
322
|
-
handler: actor.maildq,
|
|
323
|
-
|
|
324
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['maildq']
|
|
325
|
-
},
|
|
326
|
-
|
|
327
|
-
[SELF]: {
|
|
328
|
-
name: 'self',
|
|
329
|
-
|
|
330
|
-
handler: actor.self,
|
|
331
|
-
|
|
332
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['self']
|
|
333
|
-
},
|
|
334
|
-
|
|
335
|
-
[STOP]: {
|
|
336
|
-
name: 'stop',
|
|
337
|
-
|
|
338
|
-
handler: actor.stop,
|
|
339
|
-
|
|
340
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['stop']
|
|
341
|
-
},
|
|
342
|
-
|
|
343
|
-
[GETPROP]: {
|
|
344
|
-
name: 'getprop',
|
|
345
|
-
|
|
346
|
-
handler: obj.getprop,
|
|
347
|
-
|
|
348
|
-
log: (_: JSThread, __: Frame, oper: Operand) => ['getprop', oper]
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
[ARELM]: {
|
|
352
|
-
name: 'arelm',
|
|
353
|
-
|
|
354
|
-
handler: obj.arelm,
|
|
355
|
-
|
|
356
|
-
log: (_: JSThread, __: Frame, oper: Operand) => ['arelm', oper]
|
|
357
|
-
},
|
|
358
|
-
|
|
359
|
-
[ARLENGTH]: {
|
|
360
|
-
name: 'arlength',
|
|
361
|
-
|
|
362
|
-
handler: obj.arlength,
|
|
363
|
-
|
|
364
|
-
log: (_: JSThread, __: Frame, ___: Operand) => ['arlength']
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
const eToLog = (e: Either<Err, PTValue>) =>
|
|
369
|
-
e.isLeft() ? e.takeLeft().message : e.takeRight();
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* handlers maps opcode numbers to their handler
|
|
373
|
-
*/
|
|
374
|
-
export const handlers: OpcodeHandlers = map(opcodes, i => i.handler);
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* toName converts an opcode to it's mnemonic.
|
|
378
|
-
*/
|
|
379
|
-
export const toName = (op: Opcode) =>
|
|
380
|
-
opcodes.hasOwnProperty(op) ? opcodes[op].name : '<unknown>';
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* toLog provides a log line for an op.
|
|
384
|
-
*
|
|
385
|
-
* If the op is invalid an empty line is produced.
|
|
386
|
-
*/
|
|
387
|
-
export const toLog = (op: Opcode, r: JSThread, f: Frame, oper: Operand) =>
|
|
388
|
-
opcodes.hasOwnProperty(op) ? opcodes[op].log(r, f, oper) : [];
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { JSThread } from '../thread/shared/js';
|
|
2
|
-
import { Frame } from '../frame';
|
|
3
|
-
import { Operand } from '.';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* getprop retrieves a property from an object.
|
|
7
|
-
*
|
|
8
|
-
* Stack:
|
|
9
|
-
* <objectref> -> <value>
|
|
10
|
-
*/
|
|
11
|
-
export const getprop = (_r: JSThread, f: Frame, _idx: Operand) => {
|
|
12
|
-
// TODO: This needs to be re-implemented to support user space objects.
|
|
13
|
-
|
|
14
|
-
//This should really push the void value instead of 0.
|
|
15
|
-
f.push(0);
|
|
16
|
-
|
|
17
|
-
/*
|
|
18
|
-
let eobj = f.popObject();
|
|
19
|
-
|
|
20
|
-
if (eobj.isLeft()) return r.raise(eobj.takeLeft());
|
|
21
|
-
|
|
22
|
-
let obj = eobj.takeRight();
|
|
23
|
-
|
|
24
|
-
let mval = obj.get(idx);
|
|
25
|
-
|
|
26
|
-
if (mval.isJust()) {
|
|
27
|
-
f.push(r.vm.objects.intern(f, mval.get()));
|
|
28
|
-
} else {
|
|
29
|
-
//TODO: This is a null reference!
|
|
30
|
-
f.push(0);
|
|
31
|
-
}*/
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* arlength pushes the length of an array on the top of the stack onto
|
|
36
|
-
* the stack.
|
|
37
|
-
*
|
|
38
|
-
* If the reference at the top of the stack is not an array the value will
|
|
39
|
-
* always be zero.
|
|
40
|
-
*
|
|
41
|
-
* Stack:
|
|
42
|
-
* <arrayref> -> <uint32>
|
|
43
|
-
*/
|
|
44
|
-
export const arlength = (r: JSThread, f: Frame, _: Operand) => {
|
|
45
|
-
let eobj = f.popObject();
|
|
46
|
-
|
|
47
|
-
if (eobj.isLeft()) return r.raise(eobj.takeLeft());
|
|
48
|
-
|
|
49
|
-
// let obj = eobj.takeRight();
|
|
50
|
-
|
|
51
|
-
// TODO: Implement this.
|
|
52
|
-
f.push(0);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* arelm provides the array element at the specified index.
|
|
57
|
-
*
|
|
58
|
-
* If the element is not a primitive it will be placed on the heap.
|
|
59
|
-
*
|
|
60
|
-
* Stack:
|
|
61
|
-
*
|
|
62
|
-
* <arrayref>,<index> -> <element>
|
|
63
|
-
*/
|
|
64
|
-
export const arelm = (_r: JSThread, f: Frame, _: Operand) => {
|
|
65
|
-
//TOOO: Same as getprop.
|
|
66
|
-
f.push(0);
|
|
67
|
-
/*
|
|
68
|
-
let earr = f.popObject();
|
|
69
|
-
|
|
70
|
-
if (earr.isLeft()) return r.raise(earr.takeLeft());
|
|
71
|
-
|
|
72
|
-
let arr = earr.takeRight();
|
|
73
|
-
|
|
74
|
-
let melm = arr.get(f.pop());
|
|
75
|
-
|
|
76
|
-
if (melm.isJust()) {
|
|
77
|
-
f.push(r.vm.heap.intern(f, melm.get()));
|
|
78
|
-
} else {
|
|
79
|
-
f.push(0);
|
|
80
|
-
}*/
|
|
81
|
-
};
|