Skip to content

Commit 5f6d7a7

Browse files
authored
Merge PR #11: Update dependencies and fix some minor details
2 parents 0b4d374 + feb4f0c commit 5f6d7a7

13 files changed

+950
-1882
lines changed

package-lock.json

Lines changed: 872 additions & 1819 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
},
1414
"license": "MIT",
1515
"devDependencies": {
16-
"chai": "4.3.4",
17-
"eslint": "7.32.0",
18-
"eslint-config-airbnb-base": "14.2.1",
19-
"eslint-plugin-import": "2.25.2",
20-
"mocha": "8.2.1"
16+
"chai": "4.3.7",
17+
"eslint": "8.27.0",
18+
"eslint-config-airbnb-base": "15.0.0",
19+
"eslint-plugin-import": "2.26.0",
20+
"mocha": "10.1.0"
2121
},
2222
"scripts": {
2323
"browserify": "mkdir -p build && npm run core-lib && npm run browserify:main && npm run browserify:som-core && npm run browserify:core-lib-loader",

src/lib/assert.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
* THE SOFTWARE.
2121
*/
2222
// @ts-check
23-
class AssertionFailedException {
23+
class AssertionFailedException extends Error {
2424
constructor() {
25+
super();
2526
// Use V8's native method if available, otherwise fallback
2627
if ('captureStackTrace' in Error) {
2728
Error.captureStackTrace(this, AssertionFailedException);

src/som/compiler/MethodGenerationContext.js

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,23 @@ export class MethodGenerationContext {
8080
}
8181

8282
// return the method - the holder field is to be set later on!
83-
return universe.newMethod(this.signature,
83+
return universe.newMethod(
84+
this.signature,
8485
this.getSourceSectionForMethod(sourceSection),
85-
body, this.locals.length);
86+
body,
87+
this.locals.length,
88+
);
8689
}
8790

8891
getSourceSectionForMethod(ssBody) {
8992
return new SourceSection(
9093
`${this.holderGenc.getName().getString()}>>${this.signature.toString()}`,
91-
ssBody.startLine(), ssBody.startColumn(),
92-
ssBody.charIndex(), ssBody.length(),
94+
ssBody.startLine(),
95+
96+
ssBody.startColumn(),
97+
ssBody.charIndex(),
98+
99+
ssBody.length(),
93100
);
94101
}
95102

@@ -179,7 +186,11 @@ export class MethodGenerationContext {
179186
const self = this.getVariable('self');
180187
return self.getSuperReadNode(
181188
this.getOuterSelfContextLevel(),
182-
this.holderGenc.getName(), this.holderGenc.isClassSide(), source,
189+
this.holderGenc.getName(),
190+
191+
this.holderGenc.isClassSide(),
192+
193+
source,
183194
);
184195
}
185196

@@ -190,29 +201,33 @@ export class MethodGenerationContext {
190201

191202
getLocalWriteNode(variableName, valExpr, source) {
192203
const variable = this.getVariable(variableName);
193-
return variable.getWriteNode(this.getContextLevel(variableName),
194-
valExpr, source);
204+
return variable.getWriteNode(
205+
this.getContextLevel(variableName),
206+
valExpr,
207+
208+
source,
209+
);
195210
}
196211

197212
getNonLocalReturn(expr, source) {
198213
this.makeCatchNonLocalReturn();
199-
return factory.createNonLocalReturn(
200-
expr, this.getOuterSelfContextLevel(), source,
201-
);
214+
return factory.createNonLocalReturn(expr, this.getOuterSelfContextLevel(), source);
202215
}
203216

204217
getSelfRead(source) {
205-
return this.getVariable('self').getReadNode(
206-
this.getContextLevel('self'), source,
207-
);
218+
return this.getVariable('self').getReadNode(this.getContextLevel('self'), source);
208219
}
209220

210221
getObjectFieldRead(fieldName, source) {
211222
if (!this.holderGenc.hasField(fieldName)) {
212223
return null;
213224
}
214-
return factory.createFieldRead(this.getSelfRead(source),
215-
this.holderGenc.getFieldIndex(fieldName), source);
225+
return factory.createFieldRead(
226+
this.getSelfRead(source),
227+
this.holderGenc.getFieldIndex(fieldName),
228+
229+
source,
230+
);
216231
}
217232

218233
getGlobalRead(varName, source) {
@@ -224,8 +239,12 @@ export class MethodGenerationContext {
224239
return null;
225240
}
226241

227-
return factory.createFieldWrite(this.getSelfRead(source), exp,
228-
this.holderGenc.getFieldIndex(fieldName), source);
242+
return factory.createFieldWrite(
243+
this.getSelfRead(source),
244+
exp,
245+
this.holderGenc.getFieldIndex(fieldName),
246+
source,
247+
);
229248
}
230249

231250
/**

src/som/compiler/Parser.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ export class Parser {
255255

256256
getSource(coord) {
257257
return new SourceSection(
258-
'method', coord.startLine, coord.startColumn, coord.charIndex,
258+
'method',
259+
coord.startLine,
260+
coord.startColumn,
261+
coord.charIndex,
259262
this.lexer.getNumberOfCharactersRead() - coord.charIndex,
260263
);
261264
}
@@ -433,9 +436,13 @@ export class Parser {
433436
const coord = this.getCoordinate();
434437

435438
if (!isIdentifier(this.sym)) {
436-
throw new ParseError('Assignments should always target variables or'
439+
throw new ParseError(
440+
'Assignments should always target variables or'
437441
+ ' fields, but found instead a %(found)s',
438-
Sym.Identifier, this);
442+
Sym.Identifier,
443+
444+
this,
445+
);
439446
}
440447
const variable = this.assignment();
441448

@@ -530,19 +537,15 @@ export class Parser {
530537
unaryMessage(receiver) {
531538
const coord = this.getCoordinate();
532539
const selector = this.unarySelector();
533-
return createMessageSend(
534-
selector, [receiver], this.getSource(coord),
535-
);
540+
return createMessageSend(selector, [receiver], this.getSource(coord));
536541
}
537542

538543
binaryMessage(mgenc, receiver) {
539544
const coord = this.getCoordinate();
540545
const msg = this.binarySelector();
541546
const operand = this.binaryOperand(mgenc);
542547

543-
return createMessageSend(
544-
msg, [receiver, operand], this.getSource(coord),
545-
);
548+
return createMessageSend(msg, [receiver, operand], this.getSource(coord));
546549
}
547550

548551
binaryOperand(mgenc) {
@@ -572,9 +575,7 @@ export class Parser {
572575

573576
const msg = universe.symbolFor(kw);
574577

575-
return createMessageSend(
576-
msg, args.slice(), this.getSource(coord),
577-
);
578+
return createMessageSend(msg, args.slice(), this.getSource(coord));
578579
}
579580

580581
formula(mgenc) {

src/som/compiler/SourcecodeCompiler.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ export function compileClassFile(path, file, systemClass, universe) {
5353
return null;
5454
}
5555

56-
const result = compile(
57-
new Parser(source, `${path}/${file}.som`), systemClass, universe,
58-
);
56+
const result = compile(new Parser(source, `${path}/${file}.som`), systemClass, universe);
5957

6058
const cname = result.getName();
6159
const cnameC = cname.getString();

src/som/compiler/Variable.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ export class Argument {
4747
}
4848

4949
getSuperReadNode(contextLevel, holderClass, classSide, source) {
50-
return createSuperRead(
51-
this, contextLevel, holderClass, classSide, source,
52-
);
50+
return createSuperRead(this, contextLevel, holderClass, classSide, source);
5351
}
5452

5553
getIndex() {

src/som/interpreter/MessageSendNode.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export class MessageSendNode extends Node {
3434

3535
if (argumentNodes[0].isSuperNode()) {
3636
this.child_dispatch = this.adopt(new UninitializedSuperDispatchNode(
37-
selector, argumentNodes[0].getHolderClass(),
37+
selector,
38+
argumentNodes[0].getHolderClass(),
3839
argumentNodes[0].isClassSide(),
3940
));
4041
} else {

src/som/interpreter/NodeFactory.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ export function createVariableRead(local, contextLevel, source) {
6666

6767
export function createSuperRead(variable, contextLevel, holderClass, classSide, source) {
6868
assert(holderClass instanceof SSymbol);
69-
return new SuperReadNode(
70-
holderClass, classSide, contextLevel, variable, source,
71-
);
69+
return new SuperReadNode(holderClass, classSide, contextLevel, variable, source);
7270
}
7371

7472
export function createVariableWrite(variable, contextLevel, exp, source) {

src/som/primitives/Primitives.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,20 @@ export class Primitives {
4747
const signature = universe.symbolFor(selector);
4848

4949
// Install the given primitive as an instance primitive in the holder class
50-
this.holder.addInstancePrimitive(universe.newPrimitive(
51-
signature, primFun, this.holder,
52-
), suppressWarning);
50+
this.holder.addInstancePrimitive(
51+
universe.newPrimitive(signature, primFun, this.holder),
52+
suppressWarning,
53+
);
5354
}
5455

5556
installClassPrimitive(selector, primFun) {
5657
const signature = universe.symbolFor(selector);
5758

5859
// Install the given primitive as an instance primitive in the class of
5960
// the holder class
60-
this.holder.getClass().addInstancePrimitive(universe.newPrimitive(
61-
signature, primFun, this.holder,
62-
));
61+
this.holder.getClass().addInstancePrimitive(
62+
universe.newPrimitive(signature, primFun, this.holder),
63+
);
6364
}
6465

6566
getEmptyPrimitive(selector) {

src/som/primitives/StringPrimitives.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function _isWhiteSpace(_frame, args) {
9595
function _isLetters(_frame, args) {
9696
const s = args[0].getEmbeddedString();
9797

98-
if (RegExp(/^\p{L}+$/, 'u').test(s)) {
98+
if (/^\p{L}+$/u.test(s)) {
9999
return universe.trueObject;
100100
}
101101
return universe.falseObject;

src/som/vm/Universe.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,12 @@ class Universe {
282282
const cpEntry = this.classPath[i];
283283

284284
// Load the class from a file and return the loaded class
285-
const result = compileClassFile(cpEntry, name.getString(),
286-
systemClass, this);
285+
const result = compileClassFile(
286+
cpEntry,
287+
name.getString(),
288+
systemClass,
289+
this,
290+
);
287291
if (result == null) {
288292
continue; // continue searching in the class path
289293
}

src/som/vmobjects/numbers.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ export class SInteger extends SAbstractObject {
6767

6868
primAdd(right) {
6969
if (right instanceof SBigInteger) {
70-
return intOrBigInt(
71-
right.getEmbeddedBigInteger() + BigInt(this.intVal), universe,
72-
);
70+
return intOrBigInt(right.getEmbeddedBigInteger() + BigInt(this.intVal), universe);
7371
} if (right instanceof SDouble) {
7472
return this.toDouble().primAdd(right);
7573
}
@@ -79,9 +77,7 @@ export class SInteger extends SAbstractObject {
7977

8078
primSubtract(right) {
8179
if (right instanceof SBigInteger) {
82-
return intOrBigInt(
83-
BigInt(this.intVal) - right.getEmbeddedBigInteger(), universe,
84-
);
80+
return intOrBigInt(BigInt(this.intVal) - right.getEmbeddedBigInteger(), universe);
8581
} if (right instanceof SDouble) {
8682
return this.toDouble().primSubtract(right);
8783
}
@@ -91,9 +87,7 @@ export class SInteger extends SAbstractObject {
9187

9288
primMultiply(right) {
9389
if (right instanceof SBigInteger) {
94-
return intOrBigInt(
95-
right.getEmbeddedBigInteger().multiply(this.intVal), universe,
96-
);
90+
return intOrBigInt(right.getEmbeddedBigInteger().multiply(this.intVal), universe);
9791
} if (right instanceof SDouble) {
9892
return this.toDouble().primMultiply(right);
9993
}

0 commit comments

Comments
 (0)