Skip to content

Commit

Permalink
Merge PR #11: Update dependencies and fix some minor details
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr authored Nov 18, 2022
2 parents 0b4d374 + feb4f0c commit 5f6d7a7
Show file tree
Hide file tree
Showing 13 changed files with 950 additions and 1,882 deletions.
2,691 changes: 872 additions & 1,819 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
},
"license": "MIT",
"devDependencies": {
"chai": "4.3.4",
"eslint": "7.32.0",
"eslint-config-airbnb-base": "14.2.1",
"eslint-plugin-import": "2.25.2",
"mocha": "8.2.1"
"chai": "4.3.7",
"eslint": "8.27.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-plugin-import": "2.26.0",
"mocha": "10.1.0"
},
"scripts": {
"browserify": "mkdir -p build && npm run core-lib && npm run browserify:main && npm run browserify:som-core && npm run browserify:core-lib-loader",
Expand Down
3 changes: 2 additions & 1 deletion src/lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
* THE SOFTWARE.
*/
// @ts-check
class AssertionFailedException {
class AssertionFailedException extends Error {
constructor() {
super();
// Use V8's native method if available, otherwise fallback
if ('captureStackTrace' in Error) {
Error.captureStackTrace(this, AssertionFailedException);
Expand Down
53 changes: 36 additions & 17 deletions src/som/compiler/MethodGenerationContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,23 @@ export class MethodGenerationContext {
}

// return the method - the holder field is to be set later on!
return universe.newMethod(this.signature,
return universe.newMethod(
this.signature,
this.getSourceSectionForMethod(sourceSection),
body, this.locals.length);
body,
this.locals.length,
);
}

getSourceSectionForMethod(ssBody) {
return new SourceSection(
`${this.holderGenc.getName().getString()}>>${this.signature.toString()}`,
ssBody.startLine(), ssBody.startColumn(),
ssBody.charIndex(), ssBody.length(),
ssBody.startLine(),

ssBody.startColumn(),
ssBody.charIndex(),

ssBody.length(),
);
}

Expand Down Expand Up @@ -179,7 +186,11 @@ export class MethodGenerationContext {
const self = this.getVariable('self');
return self.getSuperReadNode(
this.getOuterSelfContextLevel(),
this.holderGenc.getName(), this.holderGenc.isClassSide(), source,
this.holderGenc.getName(),

this.holderGenc.isClassSide(),

source,
);
}

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

getLocalWriteNode(variableName, valExpr, source) {
const variable = this.getVariable(variableName);
return variable.getWriteNode(this.getContextLevel(variableName),
valExpr, source);
return variable.getWriteNode(
this.getContextLevel(variableName),
valExpr,

source,
);
}

getNonLocalReturn(expr, source) {
this.makeCatchNonLocalReturn();
return factory.createNonLocalReturn(
expr, this.getOuterSelfContextLevel(), source,
);
return factory.createNonLocalReturn(expr, this.getOuterSelfContextLevel(), source);
}

getSelfRead(source) {
return this.getVariable('self').getReadNode(
this.getContextLevel('self'), source,
);
return this.getVariable('self').getReadNode(this.getContextLevel('self'), source);
}

getObjectFieldRead(fieldName, source) {
if (!this.holderGenc.hasField(fieldName)) {
return null;
}
return factory.createFieldRead(this.getSelfRead(source),
this.holderGenc.getFieldIndex(fieldName), source);
return factory.createFieldRead(
this.getSelfRead(source),
this.holderGenc.getFieldIndex(fieldName),

source,
);
}

getGlobalRead(varName, source) {
Expand All @@ -224,8 +239,12 @@ export class MethodGenerationContext {
return null;
}

return factory.createFieldWrite(this.getSelfRead(source), exp,
this.holderGenc.getFieldIndex(fieldName), source);
return factory.createFieldWrite(
this.getSelfRead(source),
exp,
this.holderGenc.getFieldIndex(fieldName),
source,
);
}

/**
Expand Down
25 changes: 13 additions & 12 deletions src/som/compiler/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ export class Parser {

getSource(coord) {
return new SourceSection(
'method', coord.startLine, coord.startColumn, coord.charIndex,
'method',
coord.startLine,
coord.startColumn,
coord.charIndex,
this.lexer.getNumberOfCharactersRead() - coord.charIndex,
);
}
Expand Down Expand Up @@ -433,9 +436,13 @@ export class Parser {
const coord = this.getCoordinate();

if (!isIdentifier(this.sym)) {
throw new ParseError('Assignments should always target variables or'
throw new ParseError(
'Assignments should always target variables or'
+ ' fields, but found instead a %(found)s',
Sym.Identifier, this);
Sym.Identifier,

this,
);
}
const variable = this.assignment();

Expand Down Expand Up @@ -530,19 +537,15 @@ export class Parser {
unaryMessage(receiver) {
const coord = this.getCoordinate();
const selector = this.unarySelector();
return createMessageSend(
selector, [receiver], this.getSource(coord),
);
return createMessageSend(selector, [receiver], this.getSource(coord));
}

binaryMessage(mgenc, receiver) {
const coord = this.getCoordinate();
const msg = this.binarySelector();
const operand = this.binaryOperand(mgenc);

return createMessageSend(
msg, [receiver, operand], this.getSource(coord),
);
return createMessageSend(msg, [receiver, operand], this.getSource(coord));
}

binaryOperand(mgenc) {
Expand Down Expand Up @@ -572,9 +575,7 @@ export class Parser {

const msg = universe.symbolFor(kw);

return createMessageSend(
msg, args.slice(), this.getSource(coord),
);
return createMessageSend(msg, args.slice(), this.getSource(coord));
}

formula(mgenc) {
Expand Down
4 changes: 1 addition & 3 deletions src/som/compiler/SourcecodeCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ export function compileClassFile(path, file, systemClass, universe) {
return null;
}

const result = compile(
new Parser(source, `${path}/${file}.som`), systemClass, universe,
);
const result = compile(new Parser(source, `${path}/${file}.som`), systemClass, universe);

const cname = result.getName();
const cnameC = cname.getString();
Expand Down
4 changes: 1 addition & 3 deletions src/som/compiler/Variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ export class Argument {
}

getSuperReadNode(contextLevel, holderClass, classSide, source) {
return createSuperRead(
this, contextLevel, holderClass, classSide, source,
);
return createSuperRead(this, contextLevel, holderClass, classSide, source);
}

getIndex() {
Expand Down
3 changes: 2 additions & 1 deletion src/som/interpreter/MessageSendNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export class MessageSendNode extends Node {

if (argumentNodes[0].isSuperNode()) {
this.child_dispatch = this.adopt(new UninitializedSuperDispatchNode(
selector, argumentNodes[0].getHolderClass(),
selector,
argumentNodes[0].getHolderClass(),
argumentNodes[0].isClassSide(),
));
} else {
Expand Down
4 changes: 1 addition & 3 deletions src/som/interpreter/NodeFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ export function createVariableRead(local, contextLevel, source) {

export function createSuperRead(variable, contextLevel, holderClass, classSide, source) {
assert(holderClass instanceof SSymbol);
return new SuperReadNode(
holderClass, classSide, contextLevel, variable, source,
);
return new SuperReadNode(holderClass, classSide, contextLevel, variable, source);
}

export function createVariableWrite(variable, contextLevel, exp, source) {
Expand Down
13 changes: 7 additions & 6 deletions src/som/primitives/Primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,20 @@ export class Primitives {
const signature = universe.symbolFor(selector);

// Install the given primitive as an instance primitive in the holder class
this.holder.addInstancePrimitive(universe.newPrimitive(
signature, primFun, this.holder,
), suppressWarning);
this.holder.addInstancePrimitive(
universe.newPrimitive(signature, primFun, this.holder),
suppressWarning,
);
}

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

// Install the given primitive as an instance primitive in the class of
// the holder class
this.holder.getClass().addInstancePrimitive(universe.newPrimitive(
signature, primFun, this.holder,
));
this.holder.getClass().addInstancePrimitive(
universe.newPrimitive(signature, primFun, this.holder),
);
}

getEmptyPrimitive(selector) {
Expand Down
2 changes: 1 addition & 1 deletion src/som/primitives/StringPrimitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function _isWhiteSpace(_frame, args) {
function _isLetters(_frame, args) {
const s = args[0].getEmbeddedString();

if (RegExp(/^\p{L}+$/, 'u').test(s)) {
if (/^\p{L}+$/u.test(s)) {
return universe.trueObject;
}
return universe.falseObject;
Expand Down
8 changes: 6 additions & 2 deletions src/som/vm/Universe.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,12 @@ class Universe {
const cpEntry = this.classPath[i];

// Load the class from a file and return the loaded class
const result = compileClassFile(cpEntry, name.getString(),
systemClass, this);
const result = compileClassFile(
cpEntry,
name.getString(),
systemClass,
this,
);
if (result == null) {
continue; // continue searching in the class path
}
Expand Down
12 changes: 3 additions & 9 deletions src/som/vmobjects/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ export class SInteger extends SAbstractObject {

primAdd(right) {
if (right instanceof SBigInteger) {
return intOrBigInt(
right.getEmbeddedBigInteger() + BigInt(this.intVal), universe,
);
return intOrBigInt(right.getEmbeddedBigInteger() + BigInt(this.intVal), universe);
} if (right instanceof SDouble) {
return this.toDouble().primAdd(right);
}
Expand All @@ -79,9 +77,7 @@ export class SInteger extends SAbstractObject {

primSubtract(right) {
if (right instanceof SBigInteger) {
return intOrBigInt(
BigInt(this.intVal) - right.getEmbeddedBigInteger(), universe,
);
return intOrBigInt(BigInt(this.intVal) - right.getEmbeddedBigInteger(), universe);
} if (right instanceof SDouble) {
return this.toDouble().primSubtract(right);
}
Expand All @@ -91,9 +87,7 @@ export class SInteger extends SAbstractObject {

primMultiply(right) {
if (right instanceof SBigInteger) {
return intOrBigInt(
right.getEmbeddedBigInteger().multiply(this.intVal), universe,
);
return intOrBigInt(right.getEmbeddedBigInteger().multiply(this.intVal), universe);
} if (right instanceof SDouble) {
return this.toDouble().primMultiply(right);
}
Expand Down

1 comment on commit 5f6d7a7

@rebenchdb
Copy link

@rebenchdb rebenchdb bot commented on 5f6d7a7 Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance changes for 0b4d374...5f6d7a7

Summary Over All Benchmarks
Summary Over All Benchmarks

Full Report

Please sign in to comment.