novac 1.0.0
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/LICENSE +0 -0
- package/README.md +0 -0
- package/bin/nv+ +84 -0
- package/cli.js +97 -0
- package/package.json +24 -0
- package/scripts/update-bin.js +24 -0
- package/src/core/bstd.js +14 -0
- package/src/core/describe.js +187 -0
- package/src/core/emitter.js +499 -0
- package/src/core/environment.js +0 -0
- package/src/core/error.js +86 -0
- package/src/core/executor.js +1005 -0
- package/src/core/lexer.js +506 -0
- package/src/core/parser.js +762 -0
- package/src/core/types.js +133 -0
- package/src/index.js +0 -0
- package/src/runtime/stdlib.js +3 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
class NovaValue {
|
|
2
|
+
constructor(inner) {
|
|
3
|
+
this.inner = inner;
|
|
4
|
+
}
|
|
5
|
+
get type() {
|
|
6
|
+
return this.constructor.name;
|
|
7
|
+
}
|
|
8
|
+
valueOf() {
|
|
9
|
+
return this.inner?.valueOf?.() ?? this.inner;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return String(this.valueOf());
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class NovaNumber extends NovaValue {
|
|
17
|
+
constructor(num) {
|
|
18
|
+
super(Number(num));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class NovaString extends NovaValue {
|
|
23
|
+
constructor(str) {
|
|
24
|
+
super(String(str));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class NovaObject extends NovaValue {
|
|
29
|
+
constructor(obj = {}) {
|
|
30
|
+
super(obj);
|
|
31
|
+
}
|
|
32
|
+
get(key) {
|
|
33
|
+
return this.inner[key];
|
|
34
|
+
}
|
|
35
|
+
set(key, val) {
|
|
36
|
+
this.inner[key] = val;
|
|
37
|
+
}
|
|
38
|
+
delete(key) {
|
|
39
|
+
delete this.inner[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
class NovaArray extends NovaValue {
|
|
44
|
+
constructor(arr = []) {
|
|
45
|
+
super(arr);
|
|
46
|
+
}
|
|
47
|
+
get(index) {
|
|
48
|
+
return this.inner[index];
|
|
49
|
+
}
|
|
50
|
+
set(index, val) {
|
|
51
|
+
this.inner[index] = val;
|
|
52
|
+
}
|
|
53
|
+
push(val) {
|
|
54
|
+
this.inner.push(val);
|
|
55
|
+
}
|
|
56
|
+
get length() {
|
|
57
|
+
return this.inner.length;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
class NovaFunction extends NovaValue {
|
|
62
|
+
constructor(fn, scope = null, args = []) {
|
|
63
|
+
super(fn);
|
|
64
|
+
this.scope = scope;
|
|
65
|
+
this.args = args;
|
|
66
|
+
}
|
|
67
|
+
call(thisArg, ...args) {
|
|
68
|
+
if (typeof this.inner === "function")
|
|
69
|
+
return this.inner.apply(thisArg, args);
|
|
70
|
+
if (this.inner && this.inner.body)
|
|
71
|
+
return this.scope.executor.runFunctionNode(this.inner, thisArg, args);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
class NovaTemplateString extends NovaString {
|
|
76
|
+
constructor(parts = []) {
|
|
77
|
+
super(parts.join(""));
|
|
78
|
+
this.parts = parts;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
class NovaPointer extends NovaValue {
|
|
83
|
+
constructor(value, readFn = null, writeFn = null, address = null) {
|
|
84
|
+
super(value);
|
|
85
|
+
this.readFn = readFn;
|
|
86
|
+
this.writeFn = writeFn;
|
|
87
|
+
this.address = address ?? Symbol("ptr");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
read() {
|
|
91
|
+
return this.readFn ? this.readFn(this.valueOf()) : this.valueOf();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
write(val) {
|
|
95
|
+
if (this.writeFn) this.writeFn(val, this.address);
|
|
96
|
+
this.inner = val;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
toString() {
|
|
100
|
+
return `<Pointer@${this.address.toString().slice(7, 13)} = ${this.inner}>`;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
class NovaBool extends NovaValue {
|
|
105
|
+
constructor(bool) {
|
|
106
|
+
super(!!bool);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
class NovaNull extends NovaValue {
|
|
111
|
+
constructor() {
|
|
112
|
+
super(null);
|
|
113
|
+
}
|
|
114
|
+
toString() {
|
|
115
|
+
return "null";
|
|
116
|
+
}
|
|
117
|
+
valueOf() {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
NovaValue,
|
|
124
|
+
NovaNumber,
|
|
125
|
+
NovaString,
|
|
126
|
+
NovaArray,
|
|
127
|
+
NovaObject,
|
|
128
|
+
NovaFunction,
|
|
129
|
+
NovaTemplateString,
|
|
130
|
+
NovaPointer,
|
|
131
|
+
NovaBool, // 🔥 NEW EXPORT
|
|
132
|
+
NovaNull, // 🔥 NEW EXPORT
|
|
133
|
+
};
|
package/src/index.js
ADDED
|
File without changes
|