mevento 1.2.0 → 1.4.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.
@@ -875,7 +875,7 @@ class Parser {
875
875
  if (this.currentToken?.type != TokenType.rbrace) {
876
876
  properties.push(this._property());
877
877
  }
878
- while (this.currentToken?.type == TokenType.comma) {
878
+ while (this.currentToken?.type === TokenType.comma) {
879
879
  this._eat(TokenType.comma);
880
880
  properties.push(this._property());
881
881
  }
@@ -997,8 +997,7 @@ class Parser {
997
997
  // endBlock
998
998
  this._eat(TokenType.rbrace);
999
999
  }
1000
- const ret = new BlockStatementAST(body, this.currentToken);
1001
- return ret;
1000
+ return new BlockStatementAST(body, this.currentToken);
1002
1001
  }
1003
1002
  _ifStatement() {
1004
1003
  this._eat(TokenType.IF);
@@ -1038,7 +1037,7 @@ class Parser {
1038
1037
  const token = this.currentToken;
1039
1038
  this._eat(TokenType.WHILE_TILL);
1040
1039
  const test = this._expression();
1041
- const body = this.currentToken.type == TokenType.lbrace ? this._blockStatement() : this._expression();
1040
+ const body = this.currentToken.type === TokenType.lbrace ? this._blockStatement() : this._expression();
1042
1041
  return new WhileLoopStatement(test, body, token, this.currentToken);
1043
1042
  }
1044
1043
  _forOfIdentifier() {
@@ -1103,13 +1102,13 @@ class Parser {
1103
1102
  else {
1104
1103
  update = new LiteralAST(new Token(TokenType.numberConst, 1, this.currentToken.line, this.currentToken.col), "1");
1105
1104
  }
1106
- const body = (this.currentToken.type == TokenType.lbrace) ? this._blockStatement() : this._expression();
1105
+ const body = (this.currentToken.type === TokenType.lbrace) ? this._blockStatement() : this._expression();
1107
1106
  node = new ForLoopStatement(node, test, update, direction, body, startToken, this.currentToken);
1108
1107
  }
1109
1108
  else if (forOf) {
1110
1109
  this._eat(TokenType.in);
1111
1110
  const collection = this._expression();
1112
- const body = (this.currentToken.type == TokenType.lbrace) ? this._blockStatement() : this._expression();
1111
+ const body = (this.currentToken.type === TokenType.lbrace) ? this._blockStatement() : this._expression();
1113
1112
  node = new ForOfStatement(node, collection, body, startToken, this.currentToken);
1114
1113
  }
1115
1114
  else {
@@ -1198,29 +1197,9 @@ class ANodeVisitor {
1198
1197
  this._nodesVisitors[methodName] = visitor;
1199
1198
  }
1200
1199
  }
1201
- class AsyncNodeVisitor extends ANodeVisitor {
1202
- async visit(node) {
1203
- const methodName = `visit${node.constructor.name}`;
1204
- // const fn = Object.getPrototypeOf(this)[methodName];
1205
- const fn = this._nodesVisitors[methodName];
1206
- return await fn?.call(this, node);
1207
- }
1208
- }
1209
1200
  class NodeVisitor extends ANodeVisitor {
1210
- visit(node) {
1211
- // console.log('node::', node);
1212
- const methodName = `visit${node.constructor.name}`;
1213
- // const fn = Object.getPrototypeOf(this)[methodName];
1214
- const fn = this._nodesVisitors[methodName];
1215
- return fn?.call(this, node);
1216
- }
1217
- }
1218
- class MEvento extends NodeVisitor {
1219
1201
  constructor() {
1220
1202
  super();
1221
- this._memory = {};
1222
- this.debug = false;
1223
- this._functionsRegistry = {};
1224
1203
  this.registerVisitor(RootAST, this.visitRootAST);
1225
1204
  this.registerVisitor(BlockStatementAST, this.visitBlockStatementAST);
1226
1205
  this.registerVisitor(IdentifierAST, this.visitIdentifierAST);
@@ -1240,6 +1219,29 @@ class MEvento extends NodeVisitor {
1240
1219
  this.registerVisitor(ForLoopStatement, this.visitForLoopStatement);
1241
1220
  this.registerVisitor(ForOfStatement, this.visitForOfStatement);
1242
1221
  this.registerVisitor(BreakAST, this.visitBreakAST);
1222
+ }
1223
+ visit(node) {
1224
+ const methodName = `visit${node.constructor.name}`;
1225
+ // const fn = Object.getPrototypeOf(this)[methodName];
1226
+ const fn = this._nodesVisitors[methodName];
1227
+ return fn?.call(this, node);
1228
+ }
1229
+ assignProperty(owner, property, value) {
1230
+ if (Array.isArray(owner)) {
1231
+ owner[property] = value;
1232
+ }
1233
+ else if (typeof owner === 'object') {
1234
+ owner[property] = value;
1235
+ }
1236
+ else { }
1237
+ }
1238
+ }
1239
+ class MEvento extends NodeVisitor {
1240
+ constructor() {
1241
+ super();
1242
+ this._memory = {};
1243
+ this.debug = false;
1244
+ this._functionsRegistry = {};
1243
1245
  this._functionsRegistry = { ...MEvento._globalFunctionsRegistry };
1244
1246
  }
1245
1247
  log(message) {
@@ -1287,15 +1289,6 @@ class MEvento extends NodeVisitor {
1287
1289
  }
1288
1290
  return value;
1289
1291
  }
1290
- assignProperty(owner, property, value) {
1291
- if (Array.isArray(owner)) {
1292
- owner[property] = value;
1293
- }
1294
- else if (typeof owner === 'object') {
1295
- owner[property] = value;
1296
- }
1297
- else { }
1298
- }
1299
1292
  visitExpressionStatementAST(node) {
1300
1293
  const expr = node.expression;
1301
1294
  return this.visit(expr);
@@ -1890,5 +1883,5 @@ class MEventoAsync extends MEvento {
1890
1883
  * Generated bundle index. Do not edit.
1891
1884
  */
1892
1885
 
1893
- export { MEvento, MEventoAsync };
1886
+ export { AST, ArrayExpression, AssignmentExpressionAST, BinaryExpressionAST, BlockStatementAST, BreakAST, BreakBranch, CallExpressionAST, ExpressionStatementAST, ForLoopStatement, ForOfStatement, IdentifierAST, IfStatementAST, IndexAccessorAST, LexerDictionary, LiteralAST, LogicalExpressionAST, MEvento, MEventoAsync, NodeVisitor, ObjectExpression, ObjectProperty, RootAST, Token, TokenType, TupleExpression, UnaryExpressionAST, WhileLoopStatement };
1894
1887
  //# sourceMappingURL=mevento.mjs.map