gobstones-code-runner 0.4.2 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0176887479fdb5b906fd02a0d35ecb5cb613be7d1d674649b597510b8a2bc2d3
4
- data.tar.gz: 1af6bdc0a2687a0880b291142bd2dafc900ee3a7a9fdce9e681415062a44fc81
3
+ metadata.gz: a46689b03d4e539d3febe946a4caeefa933767b087f7307a2e4add9dc79bc8fb
4
+ data.tar.gz: 6578e5d6bc23fd76cf07e0e29e23a5920fce6bad0519e188187bf22a184db848
5
5
  SHA512:
6
- metadata.gz: c13a3dd643aa71eaa4fe0ff02bc965ac8f69705dd55e3a537e3fc23b60c5ee9d0051b2ba673f10a18e8adca97e3e6e2f9fcc7e9f0e64081304e0b153b0931427
7
- data.tar.gz: e289d6dea8649ceff3ac87723675b7946bc957b0d9988872464bcd009e768fcbf15b23d3e1e605bde52c6cdbf787bcd37205ff9f6d6ac316305318a47a09051b
6
+ metadata.gz: f35a4ee2c461c7608b2bc16ec63037667ae8a54b1669c011aa6153941d23ba31a2939867b4f277f79c21e6f1231942c10cdd1440d0acffe4cf233c83d690f750
7
+ data.tar.gz: cd2ea0b40c3c573fd570629c041ef254020adbc74c6bbb4bba25aaa77d8901866139fb72b6014aee17ba77fbd269d9bff30b9103abd0f3f4bb5858a108257f6a
@@ -4479,9 +4479,9 @@ exports.ASTConstructorDeclaration = exports.ASTFieldBinding = exports.ASTExprFun
4479
4479
 
4480
4480
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4481
4481
 
4482
- var _reader = __webpack_require__(5);
4482
+ var _reader = __webpack_require__(6);
4483
4483
 
4484
- var _token = __webpack_require__(6);
4484
+ var _token = __webpack_require__(3);
4485
4485
 
4486
4486
  function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
4487
4487
 
@@ -5593,6 +5593,141 @@ var ASTConstructorDeclaration = exports.ASTConstructorDeclaration = function (_A
5593
5593
  "use strict";
5594
5594
 
5595
5595
 
5596
+ Object.defineProperty(exports, "__esModule", {
5597
+ value: true
5598
+ });
5599
+
5600
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
5601
+
5602
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5603
+
5604
+ /* Token tags are constant symbols */
5605
+ var T_EOF = exports.T_EOF = Symbol.for('T_EOF'); // End of file
5606
+ var T_NUM = exports.T_NUM = Symbol.for('T_NUM'); // Number
5607
+ var T_STRING = exports.T_STRING = Symbol.for('T_STRING'); // String constant
5608
+ var T_UPPERID = exports.T_UPPERID = Symbol.for('T_UPPERID'); // Uppercase identifier
5609
+ var T_LOWERID = exports.T_LOWERID = Symbol.for('T_LOWERID'); // Lowercase identifier
5610
+
5611
+ /* Keywords */
5612
+ var T_PROGRAM = exports.T_PROGRAM = Symbol.for('T_PROGRAM');
5613
+ var T_INTERACTIVE = exports.T_INTERACTIVE = Symbol.for('T_INTERACTIVE');
5614
+ var T_PROCEDURE = exports.T_PROCEDURE = Symbol.for('T_PROCEDURE');
5615
+ var T_FUNCTION = exports.T_FUNCTION = Symbol.for('T_FUNCTION');
5616
+ var T_RETURN = exports.T_RETURN = Symbol.for('T_RETURN');
5617
+ var T_IF = exports.T_IF = Symbol.for('T_IF');
5618
+ var T_THEN = exports.T_THEN = Symbol.for('T_THEN');
5619
+ var T_ELSEIF = exports.T_ELSEIF = Symbol.for('T_ELSEIF');
5620
+ var T_ELSE = exports.T_ELSE = Symbol.for('T_ELSE');
5621
+ var T_CHOOSE = exports.T_CHOOSE = Symbol.for('T_CHOOSE');
5622
+ var T_WHEN = exports.T_WHEN = Symbol.for('T_WHEN');
5623
+ var T_OTHERWISE = exports.T_OTHERWISE = Symbol.for('T_OTHERWISE');
5624
+ var T_REPEAT = exports.T_REPEAT = Symbol.for('T_REPEAT');
5625
+ var T_FOREACH = exports.T_FOREACH = Symbol.for('T_FOREACH');
5626
+ var T_IN = exports.T_IN = Symbol.for('T_IN');
5627
+ var T_WHILE = exports.T_WHILE = Symbol.for('T_WHILE');
5628
+ var T_SWITCH = exports.T_SWITCH = Symbol.for('T_SWITCH');
5629
+ var T_TO = exports.T_TO = Symbol.for('T_TO');
5630
+ var T_LET = exports.T_LET = Symbol.for('T_LET');
5631
+ var T_NOT = exports.T_NOT = Symbol.for('T_NOT');
5632
+ var T_DIV = exports.T_DIV = Symbol.for('T_DIV');
5633
+ var T_MOD = exports.T_MOD = Symbol.for('T_MOD');
5634
+ var T_TYPE = exports.T_TYPE = Symbol.for('T_TYPE');
5635
+ var T_IS = exports.T_IS = Symbol.for('T_IS');
5636
+ var T_RECORD = exports.T_RECORD = Symbol.for('T_RECORD');
5637
+ var T_VARIANT = exports.T_VARIANT = Symbol.for('T_VARIANT');
5638
+ var T_CASE = exports.T_CASE = Symbol.for('T_CASE');
5639
+ var T_FIELD = exports.T_FIELD = Symbol.for('T_FIELD');
5640
+ var T_UNDERSCORE = exports.T_UNDERSCORE = Symbol.for('T_UNDERSCORE');
5641
+ var T_TIMEOUT = exports.T_TIMEOUT = Symbol.for('T_TIMEOUT');
5642
+
5643
+ /* Symbols */
5644
+ var T_LPAREN = exports.T_LPAREN = Symbol.for('T_LPAREN');
5645
+ var T_RPAREN = exports.T_RPAREN = Symbol.for('T_RPAREN');
5646
+ var T_LBRACE = exports.T_LBRACE = Symbol.for('T_LBRACE');
5647
+ var T_RBRACE = exports.T_RBRACE = Symbol.for('T_RBRACE');
5648
+ var T_LBRACK = exports.T_LBRACK = Symbol.for('T_LBRACK');
5649
+ var T_RBRACK = exports.T_RBRACK = Symbol.for('T_RBRACK');
5650
+ var T_COMMA = exports.T_COMMA = Symbol.for('T_COMMA');
5651
+ var T_SEMICOLON = exports.T_SEMICOLON = Symbol.for('T_SEMICOLON');
5652
+ var T_ELLIPSIS = exports.T_ELLIPSIS = Symbol.for('T_ELLIPSIS');
5653
+ var T_RANGE = exports.T_RANGE = Symbol.for('T_RANGE');
5654
+ var T_GETS = exports.T_GETS = Symbol.for('T_GETS');
5655
+ var T_PIPE = exports.T_PIPE = Symbol.for('T_PIPE');
5656
+ var T_ARROW = exports.T_ARROW = Symbol.for('T_ARROW');
5657
+ var T_ASSIGN = exports.T_ASSIGN = Symbol.for('T_ASSIGN');
5658
+ var T_EQ = exports.T_EQ = Symbol.for('T_EQ');
5659
+ var T_NE = exports.T_NE = Symbol.for('T_NE');
5660
+ var T_LE = exports.T_LE = Symbol.for('T_LE');
5661
+ var T_GE = exports.T_GE = Symbol.for('T_GE');
5662
+ var T_LT = exports.T_LT = Symbol.for('T_LT');
5663
+ var T_GT = exports.T_GT = Symbol.for('T_GT');
5664
+ var T_AND = exports.T_AND = Symbol.for('T_AND');
5665
+ var T_OR = exports.T_OR = Symbol.for('T_OR');
5666
+ var T_CONCAT = exports.T_CONCAT = Symbol.for('T_CONCAT');
5667
+ var T_PLUS = exports.T_PLUS = Symbol.for('T_PLUS');
5668
+ var T_MINUS = exports.T_MINUS = Symbol.for('T_MINUS');
5669
+ var T_TIMES = exports.T_TIMES = Symbol.for('T_TIMES');
5670
+ var T_POW = exports.T_POW = Symbol.for('T_POW');
5671
+
5672
+ /* A token is given by:
5673
+ * - A token tag (e.g. T_LOWERID, T_NUM).
5674
+ * - Possibly, a value (e.g. 'nroBolitas', 8).
5675
+ * When the value is irrelevant, we provide null by convention.
5676
+ * - Two positions, representing its location in the source. */
5677
+
5678
+ var Token = exports.Token = function () {
5679
+ function Token(tag, value, startPos, endPos) {
5680
+ _classCallCheck(this, Token);
5681
+
5682
+ this._tag = tag;
5683
+ this._value = value;
5684
+ this._startPos = startPos;
5685
+ this._endPos = endPos;
5686
+ }
5687
+
5688
+ _createClass(Token, [{
5689
+ key: 'toString',
5690
+ value: function toString() {
5691
+ var tag = Symbol.keyFor(this._tag).substring(2);
5692
+ switch (tag) {
5693
+ case 'NUM':case 'STRING':case 'UPPERID':case 'LOWERID':
5694
+ return tag + '("' + this._value + '")';
5695
+ default:
5696
+ return tag;
5697
+ }
5698
+ }
5699
+ }, {
5700
+ key: 'tag',
5701
+ get: function get() {
5702
+ return this._tag;
5703
+ }
5704
+ }, {
5705
+ key: 'value',
5706
+ get: function get() {
5707
+ return this._value;
5708
+ }
5709
+ }, {
5710
+ key: 'startPos',
5711
+ get: function get() {
5712
+ return this._startPos;
5713
+ }
5714
+ }, {
5715
+ key: 'endPos',
5716
+ get: function get() {
5717
+ return this._endPos;
5718
+ }
5719
+ }]);
5720
+
5721
+ return Token;
5722
+ }();
5723
+
5724
+ /***/ }),
5725
+ /* 4 */
5726
+ /***/ (function(module, exports, __webpack_require__) {
5727
+
5728
+ "use strict";
5729
+
5730
+
5596
5731
  Object.defineProperty(exports, "__esModule", {
5597
5732
  value: true
5598
5733
  });
@@ -5606,7 +5741,7 @@ exports.typesWithOrder = typesWithOrder;
5606
5741
 
5607
5742
  var _i18n = __webpack_require__(0);
5608
5743
 
5609
- var _value = __webpack_require__(4);
5744
+ var _value = __webpack_require__(5);
5610
5745
 
5611
5746
  var _exceptions = __webpack_require__(1);
5612
5747
 
@@ -5651,10 +5786,10 @@ function dirEnum() {
5651
5786
  * INIT and TIMEOUT. */
5652
5787
  function keyEventEnum() {
5653
5788
  var modifiers = ['', 'CTRL_', 'ALT_', 'SHIFT_', 'CTRL_ALT_', 'CTRL_SHIFT_', 'ALT_SHIFT_', 'CTRL_ALT_SHIFT_'];
5654
- var charKeys = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
5655
- var specialKeys = ['SPACE', 'ENTER', 'TAB', 'BACKSPACE', 'DELETE', 'ESCAPE'];
5656
- var symbolKeys = ['PLUS', 'MINUS', 'ASTERISK', 'SLASH', 'EQUALS', 'L_PARENT', 'R_PARENT', 'L_BRACKET', 'R_BRACKET', 'L_ANGLEBR', 'R_ANGLEBR'];
5657
- var arrowKeys = ['ARROW_LEFT', 'ARROW_RIGHT', 'ARROW_UP', 'ARROW_DOWN'];
5789
+ var charKeys = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
5790
+ var specialKeys = ['SPACE', 'RETURN', 'TAB', 'BACKSPACE', 'ESCAPE', 'INSERT', 'DELETE', 'HOME', 'END', 'PAGEUP', 'PAGEDOWN', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12'];
5791
+ var symbolKeys = ['AMPERSAND', 'ASTERISK', 'AT', 'BACKSLASH', 'CARET', 'COLON', 'DOLLAR', 'EQUALS', 'EXCLAIM', 'GREATER', 'HASH', 'LESS', 'PERCENT', 'PLUS', 'SEMICOLON', 'SLASH', 'QUESTION', 'QUOTE', 'QUOTEDBL', 'UNDERSCORE', 'LEFTPAREN', 'RIGHTPAREN', 'LEFTBRACKET', 'RIGHTBRACKET', 'LEFTBRACE', 'RIGHTBRACE'];
5792
+ var arrowKeys = ['LEFT', 'RIGHT', 'UP', 'DOWN'];
5658
5793
  var keys = charKeys.concat(specialKeys).concat(symbolKeys).concat(arrowKeys);
5659
5794
 
5660
5795
  var eventNames = [];
@@ -6702,7 +6837,7 @@ var RuntimePrimitives = exports.RuntimePrimitives = function () {
6702
6837
 
6703
6838
  this._primitiveFunctions[(0, _i18n.i18n)('PRIM:boom')] = this._primitiveProcedures[(0, _i18n.i18n)('PRIM:BOOM')];
6704
6839
 
6705
- /* List opreators */
6840
+ /* List operators */
6706
6841
  this._primitiveFunctions['++'] = new PrimitiveOperation([typeListAny, typeListAny], function (startPos, endPos, globalState, args) {
6707
6842
  var a = args[0];
6708
6843
  var b = args[1];
@@ -6711,6 +6846,10 @@ var RuntimePrimitives = exports.RuntimePrimitives = function () {
6711
6846
  return a.append(b);
6712
6847
  });
6713
6848
 
6849
+ this._primitiveFunctions[(0, _i18n.i18n)('PRIM:isEmpty')] = new PrimitiveOperation([typeListAny], noValidation, function (globalState, a) {
6850
+ return valueFromBool(a.length() === 0);
6851
+ });
6852
+
6714
6853
  this._primitiveFunctions[(0, _i18n.i18n)('PRIM:head')] = new PrimitiveOperation([typeListAny], function (startPos, endPos, globalState, args) {
6715
6854
  var a = args[0];
6716
6855
  if (a.length() === 0) {
@@ -6841,7 +6980,7 @@ var RuntimePrimitives = exports.RuntimePrimitives = function () {
6841
6980
  }();
6842
6981
 
6843
6982
  /***/ }),
6844
- /* 4 */
6983
+ /* 5 */
6845
6984
  /***/ (function(module, exports, __webpack_require__) {
6846
6985
 
6847
6986
  "use strict";
@@ -7136,7 +7275,11 @@ var TypeList = exports.TypeList = function (_Type5) {
7136
7275
  _createClass(TypeList, [{
7137
7276
  key: 'toString',
7138
7277
  value: function toString() {
7139
- return (0, _i18n.i18n)('TYPE:List') + '(' + this._contentType.toString() + ')';
7278
+ var suffix = '';
7279
+ if (!this._contentType.isAny()) {
7280
+ suffix = '(' + this._contentType.toString() + ')';
7281
+ }
7282
+ return (0, _i18n.i18n)('TYPE:List') + suffix;
7140
7283
  }
7141
7284
  }, {
7142
7285
  key: 'isList',
@@ -7205,11 +7348,8 @@ var TypeStructure = exports.TypeStructure = function (_Type6) {
7205
7348
  }
7206
7349
  }
7207
7350
 
7208
- var qualifiedConstructor = this._typeName + ':' + constructorName;
7209
- if (fieldStrings.length === 0) {
7210
- caseStrings.push(qualifiedConstructor);
7211
- } else {
7212
- caseStrings.push(qualifiedConstructor + '(' + fieldStrings.join(', ') + ')');
7351
+ if (fieldStrings.length !== 0) {
7352
+ caseStrings.push(constructorName + '(' + fieldStrings.join(', ') + ')');
7213
7353
  }
7214
7354
  }
7215
7355
  } catch (err) {
@@ -7230,7 +7370,7 @@ var TypeStructure = exports.TypeStructure = function (_Type6) {
7230
7370
  if (caseStrings.length === 0) {
7231
7371
  return this._typeName;
7232
7372
  } else {
7233
- return caseStrings.join(' + ');
7373
+ return this._typeName + ' { ' + caseStrings.join(' | ') + ' }';
7234
7374
  }
7235
7375
  }
7236
7376
  }, {
@@ -8198,7 +8338,7 @@ var ValueStructure = exports.ValueStructure = function (_Value5) {
8198
8338
  }(Value);
8199
8339
 
8200
8340
  /***/ }),
8201
- /* 5 */
8341
+ /* 6 */
8202
8342
  /***/ (function(module, exports, __webpack_require__) {
8203
8343
 
8204
8344
  "use strict";
@@ -8491,141 +8631,6 @@ var MultifileReader = exports.MultifileReader = function () {
8491
8631
  return MultifileReader;
8492
8632
  }();
8493
8633
 
8494
- /***/ }),
8495
- /* 6 */
8496
- /***/ (function(module, exports, __webpack_require__) {
8497
-
8498
- "use strict";
8499
-
8500
-
8501
- Object.defineProperty(exports, "__esModule", {
8502
- value: true
8503
- });
8504
-
8505
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8506
-
8507
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8508
-
8509
- /* Token tags are constant symbols */
8510
- var T_EOF = exports.T_EOF = Symbol.for('T_EOF'); // End of file
8511
- var T_NUM = exports.T_NUM = Symbol.for('T_NUM'); // Number
8512
- var T_STRING = exports.T_STRING = Symbol.for('T_STRING'); // String constant
8513
- var T_UPPERID = exports.T_UPPERID = Symbol.for('T_UPPERID'); // Uppercase identifier
8514
- var T_LOWERID = exports.T_LOWERID = Symbol.for('T_LOWERID'); // Lowercase identifier
8515
-
8516
- /* Keywords */
8517
- var T_PROGRAM = exports.T_PROGRAM = Symbol.for('T_PROGRAM');
8518
- var T_INTERACTIVE = exports.T_INTERACTIVE = Symbol.for('T_INTERACTIVE');
8519
- var T_PROCEDURE = exports.T_PROCEDURE = Symbol.for('T_PROCEDURE');
8520
- var T_FUNCTION = exports.T_FUNCTION = Symbol.for('T_FUNCTION');
8521
- var T_RETURN = exports.T_RETURN = Symbol.for('T_RETURN');
8522
- var T_IF = exports.T_IF = Symbol.for('T_IF');
8523
- var T_THEN = exports.T_THEN = Symbol.for('T_THEN');
8524
- var T_ELSEIF = exports.T_ELSEIF = Symbol.for('T_ELSEIF');
8525
- var T_ELSE = exports.T_ELSE = Symbol.for('T_ELSE');
8526
- var T_CHOOSE = exports.T_CHOOSE = Symbol.for('T_CHOOSE');
8527
- var T_WHEN = exports.T_WHEN = Symbol.for('T_WHEN');
8528
- var T_OTHERWISE = exports.T_OTHERWISE = Symbol.for('T_OTHERWISE');
8529
- var T_REPEAT = exports.T_REPEAT = Symbol.for('T_REPEAT');
8530
- var T_FOREACH = exports.T_FOREACH = Symbol.for('T_FOREACH');
8531
- var T_IN = exports.T_IN = Symbol.for('T_IN');
8532
- var T_WHILE = exports.T_WHILE = Symbol.for('T_WHILE');
8533
- var T_SWITCH = exports.T_SWITCH = Symbol.for('T_SWITCH');
8534
- var T_TO = exports.T_TO = Symbol.for('T_TO');
8535
- var T_LET = exports.T_LET = Symbol.for('T_LET');
8536
- var T_NOT = exports.T_NOT = Symbol.for('T_NOT');
8537
- var T_DIV = exports.T_DIV = Symbol.for('T_DIV');
8538
- var T_MOD = exports.T_MOD = Symbol.for('T_MOD');
8539
- var T_TYPE = exports.T_TYPE = Symbol.for('T_TYPE');
8540
- var T_IS = exports.T_IS = Symbol.for('T_IS');
8541
- var T_RECORD = exports.T_RECORD = Symbol.for('T_RECORD');
8542
- var T_VARIANT = exports.T_VARIANT = Symbol.for('T_VARIANT');
8543
- var T_CASE = exports.T_CASE = Symbol.for('T_CASE');
8544
- var T_FIELD = exports.T_FIELD = Symbol.for('T_FIELD');
8545
- var T_UNDERSCORE = exports.T_UNDERSCORE = Symbol.for('T_UNDERSCORE');
8546
- var T_TIMEOUT = exports.T_TIMEOUT = Symbol.for('T_TIMEOUT');
8547
-
8548
- /* Symbols */
8549
- var T_LPAREN = exports.T_LPAREN = Symbol.for('T_LPAREN');
8550
- var T_RPAREN = exports.T_RPAREN = Symbol.for('T_RPAREN');
8551
- var T_LBRACE = exports.T_LBRACE = Symbol.for('T_LBRACE');
8552
- var T_RBRACE = exports.T_RBRACE = Symbol.for('T_RBRACE');
8553
- var T_LBRACK = exports.T_LBRACK = Symbol.for('T_LBRACK');
8554
- var T_RBRACK = exports.T_RBRACK = Symbol.for('T_RBRACK');
8555
- var T_COMMA = exports.T_COMMA = Symbol.for('T_COMMA');
8556
- var T_SEMICOLON = exports.T_SEMICOLON = Symbol.for('T_SEMICOLON');
8557
- var T_ELLIPSIS = exports.T_ELLIPSIS = Symbol.for('T_ELLIPSIS');
8558
- var T_RANGE = exports.T_RANGE = Symbol.for('T_RANGE');
8559
- var T_GETS = exports.T_GETS = Symbol.for('T_GETS');
8560
- var T_PIPE = exports.T_PIPE = Symbol.for('T_PIPE');
8561
- var T_ARROW = exports.T_ARROW = Symbol.for('T_ARROW');
8562
- var T_ASSIGN = exports.T_ASSIGN = Symbol.for('T_ASSIGN');
8563
- var T_EQ = exports.T_EQ = Symbol.for('T_EQ');
8564
- var T_NE = exports.T_NE = Symbol.for('T_NE');
8565
- var T_LE = exports.T_LE = Symbol.for('T_LE');
8566
- var T_GE = exports.T_GE = Symbol.for('T_GE');
8567
- var T_LT = exports.T_LT = Symbol.for('T_LT');
8568
- var T_GT = exports.T_GT = Symbol.for('T_GT');
8569
- var T_AND = exports.T_AND = Symbol.for('T_AND');
8570
- var T_OR = exports.T_OR = Symbol.for('T_OR');
8571
- var T_CONCAT = exports.T_CONCAT = Symbol.for('T_CONCAT');
8572
- var T_PLUS = exports.T_PLUS = Symbol.for('T_PLUS');
8573
- var T_MINUS = exports.T_MINUS = Symbol.for('T_MINUS');
8574
- var T_TIMES = exports.T_TIMES = Symbol.for('T_TIMES');
8575
- var T_POW = exports.T_POW = Symbol.for('T_POW');
8576
-
8577
- /* A token is given by:
8578
- * - A token tag (e.g. T_LOWERID, T_NUM).
8579
- * - Possibly, a value (e.g. 'nroBolitas', 8).
8580
- * When the value is irrelevant, we provide null by convention.
8581
- * - Two positions, representing its location in the source. */
8582
-
8583
- var Token = exports.Token = function () {
8584
- function Token(tag, value, startPos, endPos) {
8585
- _classCallCheck(this, Token);
8586
-
8587
- this._tag = tag;
8588
- this._value = value;
8589
- this._startPos = startPos;
8590
- this._endPos = endPos;
8591
- }
8592
-
8593
- _createClass(Token, [{
8594
- key: 'toString',
8595
- value: function toString() {
8596
- var tag = Symbol.keyFor(this._tag).substring(2);
8597
- switch (tag) {
8598
- case 'NUM':case 'STRING':case 'UPPERID':case 'LOWERID':
8599
- return tag + '("' + this._value + '")';
8600
- default:
8601
- return tag;
8602
- }
8603
- }
8604
- }, {
8605
- key: 'tag',
8606
- get: function get() {
8607
- return this._tag;
8608
- }
8609
- }, {
8610
- key: 'value',
8611
- get: function get() {
8612
- return this._value;
8613
- }
8614
- }, {
8615
- key: 'startPos',
8616
- get: function get() {
8617
- return this._startPos;
8618
- }
8619
- }, {
8620
- key: 'endPos',
8621
- get: function get() {
8622
- return this._endPos;
8623
- }
8624
- }]);
8625
-
8626
- return Token;
8627
- }();
8628
-
8629
8634
  /***/ }),
8630
8635
  /* 7 */
8631
8636
  /***/ (function(module, exports, __webpack_require__) {
@@ -8922,6 +8927,8 @@ var LOCALE_ES = exports.LOCALE_ES = {
8922
8927
 
8923
8928
  'errmsg:pattern-number-cannot-be-negative-zero': 'El patrón numérico no puede ser "-0".',
8924
8929
 
8930
+ 'errmsg:return-tuple-cannot-be-empty': 'El return tiene que devolver algo.',
8931
+
8925
8932
  'errmsg:pattern-tuple-cannot-be-singleton': 'El patrón para una tupla no puede tener una sola componente. ' + 'Las tuplas tienen 0, 2, 3, o más componentes, pero no 1.',
8926
8933
 
8927
8934
  'errmsg:assignment-tuple-cannot-be-singleton': 'La asignación a una tupla no puede constar de una sola componente. ' + 'Las tuplas tienen 0, 2, 3, o más componentes, pero no 1.',
@@ -9075,6 +9082,36 @@ var LOCALE_ES = exports.LOCALE_ES = {
9075
9082
 
9076
9083
  'errmsg:forbidden-extension-destructuring-foreach': 'El índice de la repetición indexada debe ser un identificador.',
9077
9084
 
9085
+ 'errmsg:forbidden-extension-allow-recursion': function errmsgForbiddenExtensionAllowRecursion(cycle) {
9086
+ var msg = [];
9087
+ var _iteratorNormalCompletion2 = true;
9088
+ var _didIteratorError2 = false;
9089
+ var _iteratorError2 = undefined;
9090
+
9091
+ try {
9092
+ for (var _iterator2 = cycle[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
9093
+ var call = _step2.value;
9094
+
9095
+ msg.push(' ' + call.caller + ' llama a ' + call.callee + ' (' + call.location.startPos.filename.toString() + ':' + call.location.startPos.line.toString() + ':' + call.location.startPos.column.toString() + ')');
9096
+ }
9097
+ } catch (err) {
9098
+ _didIteratorError2 = true;
9099
+ _iteratorError2 = err;
9100
+ } finally {
9101
+ try {
9102
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
9103
+ _iterator2.return();
9104
+ }
9105
+ } finally {
9106
+ if (_didIteratorError2) {
9107
+ throw _iteratorError2;
9108
+ }
9109
+ }
9110
+ }
9111
+
9112
+ return 'La recursión está deshabilitada. ' + 'Hay un ciclo en las invocaciones:\n' + msg.join('\n');
9113
+ },
9114
+
9078
9115
  'errmsg:patterns-in-foreach-must-not-be-events': 'El patrón de un foreach no puede ser un evento.',
9079
9116
 
9080
9117
  /* Runtime errors (virtual machine) */
@@ -9188,7 +9225,7 @@ var LOCALE_ES = exports.LOCALE_ES = {
9188
9225
 
9189
9226
  'TYPE:Integer': 'Number',
9190
9227
  'TYPE:String': 'String',
9191
- 'TYPE:Tuple': 'Tuple',
9228
+ 'TYPE:Tuple': '',
9192
9229
  'TYPE:List': 'List',
9193
9230
 
9194
9231
  'TYPE:Event': 'Event',
@@ -9233,10 +9270,11 @@ var LOCALE_ES = exports.LOCALE_ES = {
9233
9270
  'PRIM:minDir': 'minDir',
9234
9271
  'PRIM:maxDir': 'maxDir',
9235
9272
 
9273
+ 'PRIM:isEmpty': 'vacía',
9236
9274
  'PRIM:head': 'primero',
9237
9275
  'PRIM:tail': 'resto',
9238
9276
  'PRIM:init': 'comienzo',
9239
- 'PRIM:last': 'ultimo',
9277
+ 'PRIM:last': 'último',
9240
9278
 
9241
9279
  /* Helpers */
9242
9280
  '<alternative>': function alternative(strings) {
@@ -9833,7 +9871,7 @@ exports.ITypeCheck = exports.IRestoreState = exports.ISaveState = exports.IPrimi
9833
9871
 
9834
9872
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
9835
9873
 
9836
- var _reader = __webpack_require__(5);
9874
+ var _reader = __webpack_require__(6);
9837
9875
 
9838
9876
  function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
9839
9877
 
@@ -10687,15 +10725,15 @@ exports.GobstonesInterpreterAPI = undefined;
10687
10725
 
10688
10726
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
10689
10727
 
10690
- var _runtime = __webpack_require__(3);
10728
+ var _runtime = __webpack_require__(4);
10691
10729
 
10692
10730
  var _runner = __webpack_require__(14);
10693
10731
 
10694
10732
  var _i18n = __webpack_require__(0);
10695
10733
 
10696
- var _board_formats = __webpack_require__(20);
10734
+ var _board_formats = __webpack_require__(21);
10697
10735
 
10698
- var _value = __webpack_require__(4);
10736
+ var _value = __webpack_require__(5);
10699
10737
 
10700
10738
  var _ast = __webpack_require__(2);
10701
10739
 
@@ -11450,8 +11488,8 @@ LOCALE_EN['CONS:Dir1'] = 'East';
11450
11488
  LOCALE_EN['CONS:Dir2'] = 'South';
11451
11489
  LOCALE_EN['CONS:Dir3'] = 'West';
11452
11490
 
11453
- LOCALE_EN['PRIM:PutStone'] = 'PutStone';
11454
- LOCALE_EN['PRIM:RemoveStone'] = 'RemoveStone';
11491
+ LOCALE_EN['PRIM:PutStone'] = 'Drop';
11492
+ LOCALE_EN['PRIM:RemoveStone'] = 'Grab';
11455
11493
  LOCALE_EN['PRIM:Move'] = 'Move';
11456
11494
  LOCALE_EN['PRIM:GoToEdge'] = 'GoToEdge';
11457
11495
  LOCALE_EN['PRIM:EmptyBoardContents'] = 'EmptyBoardContents';
@@ -13260,15 +13298,15 @@ var _linter = __webpack_require__(17);
13260
13298
 
13261
13299
  var _symtable = __webpack_require__(8);
13262
13300
 
13263
- var _compiler = __webpack_require__(18);
13301
+ var _compiler = __webpack_require__(19);
13264
13302
 
13265
- var _runtime = __webpack_require__(3);
13303
+ var _runtime = __webpack_require__(4);
13266
13304
 
13267
- var _vm = __webpack_require__(19);
13305
+ var _vm = __webpack_require__(20);
13268
13306
 
13269
- var _reader = __webpack_require__(5);
13307
+ var _reader = __webpack_require__(6);
13270
13308
 
13271
- var _token = __webpack_require__(6);
13309
+ var _token = __webpack_require__(3);
13272
13310
 
13273
13311
  var _ast = __webpack_require__(2);
13274
13312
 
@@ -13409,6 +13447,8 @@ var Runner = exports.Runner = function () {
13409
13447
  value: function _setLanguageOption(option) {
13410
13448
  if (option === 'DestructuringForeach') {
13411
13449
  this.enableLintCheck('forbidden-extension-destructuring-foreach', false);
13450
+ } else if (option === 'AllowRecursion') {
13451
+ this.enableLintCheck('forbidden-extension-allow-recursion', false);
13412
13452
  } else {
13413
13453
  throw Error('Unknown language option: ' + option);
13414
13454
  }
@@ -13649,7 +13689,7 @@ var _lexer = __webpack_require__(16);
13649
13689
 
13650
13690
  var _i18n = __webpack_require__(0);
13651
13691
 
13652
- var _token = __webpack_require__(6);
13692
+ var _token = __webpack_require__(3);
13653
13693
 
13654
13694
  var _ast = __webpack_require__(2);
13655
13695
 
@@ -14037,7 +14077,7 @@ var Parser = exports.Parser = function () {
14037
14077
  value: function _parseStmtReturn() {
14038
14078
  var startPos = this._currentToken.startPos;
14039
14079
  this._match(_token.T_RETURN);
14040
- var tuple = this._parseExprTuple();
14080
+ var tuple = this._parseExprTuple(false /* possiblyEmpty */);
14041
14081
  var result = new _ast.ASTStmtReturn(tuple);
14042
14082
  result.startPos = startPos;
14043
14083
  result.endPos = tuple.endPos;
@@ -14446,7 +14486,7 @@ var Parser = exports.Parser = function () {
14446
14486
  case _token.T_UPPERID:
14447
14487
  return this._parseExprStructureOrStructureUpdate();
14448
14488
  case _token.T_LPAREN:
14449
- return this._parseExprTuple();
14489
+ return this._parseExprTuple(true /* possiblyEmpty */);
14450
14490
  case _token.T_LBRACK:
14451
14491
  return this._parseExprListOrRange();
14452
14492
  default:
@@ -14744,13 +14784,17 @@ var Parser = exports.Parser = function () {
14744
14784
 
14745
14785
  }, {
14746
14786
  key: '_parseExprTuple',
14747
- value: function _parseExprTuple() {
14787
+ value: function _parseExprTuple(possiblyEmpty) {
14748
14788
  var startPos = this._currentToken.startPos;
14749
14789
  this._match(_token.T_LPAREN);
14750
14790
  var expressionList = this._parseExpressionSeq(_token.T_RPAREN);
14751
14791
  var endPos = this._currentToken.startPos;
14752
14792
  this._match(_token.T_RPAREN);
14753
14793
 
14794
+ if (!possiblyEmpty && expressionList === 0) {
14795
+ fail(startPos, endPos, 'return-tuple-cannot-be-empty', []);
14796
+ }
14797
+
14754
14798
  var result = void 0;
14755
14799
  if (expressionList.length === 1) {
14756
14800
  result = expressionList[0];
@@ -14933,9 +14977,9 @@ var _i18n = __webpack_require__(0);
14933
14977
 
14934
14978
  var _exceptions = __webpack_require__(1);
14935
14979
 
14936
- var _reader = __webpack_require__(5);
14980
+ var _reader = __webpack_require__(6);
14937
14981
 
14938
- var _token = __webpack_require__(6);
14982
+ var _token = __webpack_require__(3);
14939
14983
 
14940
14984
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14941
14985
 
@@ -15034,7 +15078,7 @@ var SYMBOLS = [
15034
15078
  ['++', _token.T_CONCAT], ['+', _token.T_PLUS], ['-', _token.T_MINUS], ['*', _token.T_TIMES], ['^', _token.T_POW]];
15035
15079
 
15036
15080
  /* Valid language options accepted by the LANGUAGE pragma */
15037
- var LANGUAGE_OPTIONS = ['DestructuringForeach'];
15081
+ var LANGUAGE_OPTIONS = ['DestructuringForeach', 'AllowRecursion'];
15038
15082
 
15039
15083
  function leadingZeroes(string) {
15040
15084
  return string.length >= 0 && string[0] === '0';
@@ -15525,6 +15569,8 @@ var _exceptions = __webpack_require__(1);
15525
15569
 
15526
15570
  var _i18n = __webpack_require__(0);
15527
15571
 
15572
+ var _recursion_checker = __webpack_require__(18);
15573
+
15528
15574
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15529
15575
 
15530
15576
  function isBlockWithReturn(stmt) {
@@ -15596,7 +15642,8 @@ var Linter = exports.Linter = function () {
15596
15642
  'procedure-used-as-constructor': true,
15597
15643
  'undeclared-constructor': true,
15598
15644
  // Extensions
15599
- 'forbidden-extension-destructuring-foreach': true
15645
+ 'forbidden-extension-destructuring-foreach': true,
15646
+ 'forbidden-extension-allow-recursion': true
15600
15647
  };
15601
15648
  }
15602
15649
 
@@ -15676,6 +15723,8 @@ var Linter = exports.Linter = function () {
15676
15723
 
15677
15724
  this._lintDefinition(_definition);
15678
15725
  }
15726
+
15727
+ /* Disable recursion */
15679
15728
  } catch (err) {
15680
15729
  _didIteratorError2 = true;
15681
15730
  _iteratorError2 = err;
@@ -15690,6 +15739,8 @@ var Linter = exports.Linter = function () {
15690
15739
  }
15691
15740
  }
15692
15741
  }
15742
+
15743
+ this._disableRecursion(ast);
15693
15744
  }
15694
15745
  }, {
15695
15746
  key: '_addDefinitionToSymbolTable',
@@ -16878,6 +16929,16 @@ var Linter = exports.Linter = function () {
16878
16929
  }
16879
16930
  }
16880
16931
  }
16932
+ }, {
16933
+ key: '_disableRecursion',
16934
+ value: function _disableRecursion(ast) {
16935
+ if (this._enabledLinterChecks['forbidden-extension-allow-recursion']) {
16936
+ var cycle = new _recursion_checker.RecursionChecker().callCycle(ast);
16937
+ if (cycle !== null) {
16938
+ this._lintCheck(cycle[0].location.startPos, cycle[0].location.endPos, 'forbidden-extension-allow-recursion', [cycle]);
16939
+ }
16940
+ }
16941
+ }
16881
16942
 
16882
16943
  /* Throw a syntax error indicating that we expected the name of a
16883
16944
  * constructor, but we got a name which is not a constructor.
@@ -16909,6 +16970,224 @@ var Linter = exports.Linter = function () {
16909
16970
  "use strict";
16910
16971
 
16911
16972
 
16973
+ Object.defineProperty(exports, "__esModule", {
16974
+ value: true
16975
+ });
16976
+ exports.RecursionChecker = undefined;
16977
+
16978
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
16979
+
16980
+ var _ast = __webpack_require__(2);
16981
+
16982
+ var _token = __webpack_require__(3);
16983
+
16984
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16985
+
16986
+ var RecursionChecker = exports.RecursionChecker = function () {
16987
+
16988
+ /*
16989
+ * Each routine call (i.e. procedure or function call) in the source
16990
+ * code is of the form:
16991
+ * R(e1, ..., en)
16992
+ * where R is the identifier for the routine.
16993
+ *
16994
+ * The token R is called the 'location' of the call.
16995
+ * Observe that the location includes not only the name of the
16996
+ * routine but also its position in the source code.
16997
+ *
16998
+ * The call graph is a dictionary whose keys are strings
16999
+ * and whose values are again dictionaries.
17000
+ * The outer and the inner dictionaries are indexed by routine names
17001
+ * in such a way that:
17002
+ *
17003
+ * _callGraph[F][G]
17004
+ *
17005
+ * is the location of the first call to G inside the body of F.
17006
+ */
17007
+ function RecursionChecker() {
17008
+ _classCallCheck(this, RecursionChecker);
17009
+
17010
+ this._currentRoutine = null;
17011
+ this._callGraph = {};
17012
+ }
17013
+
17014
+ /*
17015
+ * If there is a cycle in the call graph (using either procedure calls
17016
+ * or function calls), return a list:
17017
+ * [c1, ..., cn]
17018
+ * where ci is the i-th call involved in a cycle.
17019
+ * A call is of the form:
17020
+ * {caller: F , callee: G, location: L}
17021
+ * where F is the name (string) of the caller,
17022
+ * G is the name (string) of the callee,
17023
+ * and L is the location of the call.
17024
+ *
17025
+ * Otherwise return null.
17026
+ */
17027
+
17028
+
17029
+ _createClass(RecursionChecker, [{
17030
+ key: 'callCycle',
17031
+ value: function callCycle(ast) {
17032
+ /* Build the call graph */
17033
+ this._visitNode(ast);
17034
+
17035
+ /* Find a cycle in the call graph */
17036
+ return this._findCallCycle();
17037
+ }
17038
+
17039
+ /* Visitor -- build the call graph */
17040
+
17041
+ }, {
17042
+ key: '_addEdge',
17043
+ value: function _addEdge(caller, callee) {
17044
+ if (!(caller in this._callGraph)) {
17045
+ this._callGraph[caller] = {};
17046
+ }
17047
+ if (!(callee.value in this._callGraph[caller])) {
17048
+ this._callGraph[caller][callee.value] = callee;
17049
+ }
17050
+ }
17051
+ }, {
17052
+ key: '_visitNode',
17053
+ value: function _visitNode(node) {
17054
+ if (node === null || node instanceof _token.Token) {
17055
+ /* Skip */
17056
+ } else if (node instanceof Array) {
17057
+ this._visitNodes(node);
17058
+ } else {
17059
+ this._visitTaggedNode(node);
17060
+ }
17061
+ }
17062
+ }, {
17063
+ key: '_visitNodes',
17064
+ value: function _visitNodes(nodes) {
17065
+ var _iteratorNormalCompletion = true;
17066
+ var _didIteratorError = false;
17067
+ var _iteratorError = undefined;
17068
+
17069
+ try {
17070
+ for (var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
17071
+ var node = _step.value;
17072
+
17073
+ this._visitNode(node);
17074
+ }
17075
+ } catch (err) {
17076
+ _didIteratorError = true;
17077
+ _iteratorError = err;
17078
+ } finally {
17079
+ try {
17080
+ if (!_iteratorNormalCompletion && _iterator.return) {
17081
+ _iterator.return();
17082
+ }
17083
+ } finally {
17084
+ if (_didIteratorError) {
17085
+ throw _iteratorError;
17086
+ }
17087
+ }
17088
+ }
17089
+ }
17090
+ }, {
17091
+ key: '_visitTaggedNode',
17092
+ value: function _visitTaggedNode(node) {
17093
+ switch (node.tag) {
17094
+ case _ast.N_DefProgram:
17095
+ case _ast.N_DefInteractiveProgram:
17096
+ this._visitProgramDefinition(node);
17097
+ break;
17098
+ case _ast.N_DefProcedure:
17099
+ case _ast.N_DefFunction:
17100
+ this._visitRoutineDefinition(node);
17101
+ break;
17102
+ case _ast.N_StmtProcedureCall:
17103
+ this._visitProcedureCall(node);
17104
+ break;
17105
+ case _ast.N_ExprFunctionCall:
17106
+ this._visitFunctionCall(node);
17107
+ break;
17108
+ }
17109
+ this._visitNodes(node.children);
17110
+ }
17111
+ }, {
17112
+ key: '_visitProgramDefinition',
17113
+ value: function _visitProgramDefinition(node) {
17114
+ this._currentRoutine = 'program';
17115
+ }
17116
+ }, {
17117
+ key: '_visitRoutineDefinition',
17118
+ value: function _visitRoutineDefinition(node) {
17119
+ this._currentRoutine = node.name.value;
17120
+ }
17121
+ }, {
17122
+ key: '_visitProcedureCall',
17123
+ value: function _visitProcedureCall(node) {
17124
+ this._addEdge(this._currentRoutine, node.procedureName);
17125
+ }
17126
+ }, {
17127
+ key: '_visitFunctionCall',
17128
+ value: function _visitFunctionCall(node) {
17129
+ this._addEdge(this._currentRoutine, node.functionName);
17130
+ }
17131
+
17132
+ /* Find a cycle in the call graph */
17133
+
17134
+ }, {
17135
+ key: '_findCallCycle',
17136
+ value: function _findCallCycle() {
17137
+ var visited = {};
17138
+ var parents = {};
17139
+ for (var f in this._callGraph) {
17140
+ visited[f] = true;
17141
+ parents[f] = true;
17142
+ var cycle = this._findCallCycleFrom(visited, parents, [], f);
17143
+ if (cycle != null) {
17144
+ return cycle;
17145
+ }
17146
+ delete parents[f];
17147
+ }
17148
+ return null;
17149
+ }
17150
+ }, {
17151
+ key: '_findCallCycleFrom',
17152
+ value: function _findCallCycleFrom(visited, parents, path, f) {
17153
+ for (var g in this._callGraph[f]) {
17154
+ path.push({
17155
+ 'caller': f,
17156
+ 'callee': g,
17157
+ 'location': this._callGraph[f][g]
17158
+ });
17159
+ if (g in parents) {
17160
+ while (path[0].caller !== g) {
17161
+ path.shift();
17162
+ }
17163
+ path.push();
17164
+ return path; /* Cycle */
17165
+ }
17166
+ if (!(g in visited)) {
17167
+ visited[g] = true;
17168
+ parents[g] = true;
17169
+ var cycle = this._findCallCycleFrom(visited, parents, path, g);
17170
+ if (cycle !== null) {
17171
+ return cycle;
17172
+ }
17173
+ delete parents[g];
17174
+ }
17175
+ path.pop();
17176
+ }
17177
+ return null;
17178
+ }
17179
+ }]);
17180
+
17181
+ return RecursionChecker;
17182
+ }();
17183
+
17184
+ /***/ }),
17185
+ /* 19 */
17186
+ /***/ (function(module, exports, __webpack_require__) {
17187
+
17188
+ "use strict";
17189
+
17190
+
16912
17191
  Object.defineProperty(exports, "__esModule", {
16913
17192
  value: true
16914
17193
  });
@@ -16920,9 +17199,9 @@ var _ast = __webpack_require__(2);
16920
17199
 
16921
17200
  var _instruction = __webpack_require__(9);
16922
17201
 
16923
- var _value = __webpack_require__(4);
17202
+ var _value = __webpack_require__(5);
16924
17203
 
16925
- var _runtime = __webpack_require__(3);
17204
+ var _runtime = __webpack_require__(4);
16926
17205
 
16927
17206
  var _i18n = __webpack_require__(0);
16928
17207
 
@@ -18120,7 +18399,7 @@ var Compiler = exports.Compiler = function () {
18120
18399
  }();
18121
18400
 
18122
18401
  /***/ }),
18123
- /* 19 */
18402
+ /* 20 */
18124
18403
  /***/ (function(module, exports, __webpack_require__) {
18125
18404
 
18126
18405
  "use strict";
@@ -18135,13 +18414,13 @@ var _createClass = function () { function defineProperties(target, props) { for
18135
18414
 
18136
18415
  var _instruction = __webpack_require__(9);
18137
18416
 
18138
- var _value = __webpack_require__(4);
18417
+ var _value = __webpack_require__(5);
18139
18418
 
18140
18419
  var _exceptions = __webpack_require__(1);
18141
18420
 
18142
18421
  var _i18n = __webpack_require__(0);
18143
18422
 
18144
- var _runtime = __webpack_require__(3);
18423
+ var _runtime = __webpack_require__(4);
18145
18424
 
18146
18425
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18147
18426
 
@@ -18202,6 +18481,13 @@ function fail(startPos, endPos, reason, args) {
18202
18481
  * - the current instruction pointer
18203
18482
  * - a stack of local values
18204
18483
  * - a map from local names to values
18484
+ *
18485
+ * Each local variable has a type and a value.
18486
+ * - The actual type of the current value held by a variable
18487
+ * should always be an instance of the type.
18488
+ * - The type of a variable should be the join of all the
18489
+ * types held historically by the variable.
18490
+ * - The Frame does not impose these conditions.
18205
18491
  */
18206
18492
 
18207
18493
  var Frame = function () {
@@ -18210,6 +18496,7 @@ var Frame = function () {
18210
18496
 
18211
18497
  this._routineName = routineName;
18212
18498
  this._instructionPointer = instructionPointer;
18499
+ this._variableTypes = {};
18213
18500
  this._variables = {};
18214
18501
  this._stack = [];
18215
18502
 
@@ -18221,7 +18508,16 @@ var Frame = function () {
18221
18508
 
18222
18509
  _createClass(Frame, [{
18223
18510
  key: 'setVariable',
18224
- value: function setVariable(name, value) {
18511
+
18512
+
18513
+ /* Precondition:
18514
+ * Let oldType = this._variableTypes[name]
18515
+ * if this._variableTypes[name] is defined.
18516
+ * Otherwise, let oldType = new TypeAny().
18517
+ * Then the following condition must hold:
18518
+ * type = joinTypes(value.type(), oldType) */
18519
+ value: function setVariable(name, type, value) {
18520
+ this._variableTypes[name] = type;
18225
18521
  this._variables[name] = value;
18226
18522
  }
18227
18523
  }, {
@@ -18229,6 +18525,15 @@ var Frame = function () {
18229
18525
  value: function unsetVariable(name, value) {
18230
18526
  delete this._variables[name];
18231
18527
  }
18528
+ }, {
18529
+ key: 'getVariableType',
18530
+ value: function getVariableType(name) {
18531
+ if (name in this._variableTypes) {
18532
+ return this._variableTypes[name];
18533
+ } else {
18534
+ return new _value.TypeAny();
18535
+ }
18536
+ }
18232
18537
  }, {
18233
18538
  key: 'getVariable',
18234
18539
  value: function getVariable(name) {
@@ -18596,17 +18901,15 @@ var VirtualMachine = exports.VirtualMachine = function () {
18596
18901
  var newValue = frame.popValue();
18597
18902
 
18598
18903
  /* Check that types are compatible */
18599
- var oldValue = frame.getVariable(instruction.variableName);
18600
- if (oldValue !== null) {
18601
- var oldType = oldValue.type();
18602
- var newType = newValue.type();
18603
- if ((0, _value.joinTypes)(oldType, newType) === null) {
18604
- fail(instruction.startPos, instruction.endPos, 'incompatible-types-on-assignment', [instruction.variableName, oldType, newType]);
18605
- }
18904
+ var oldType = frame.getVariableType(instruction.variableName);
18905
+ var valType = newValue.type();
18906
+ var newType = (0, _value.joinTypes)(oldType, valType);
18907
+ if (newType === null) {
18908
+ fail(instruction.startPos, instruction.endPos, 'incompatible-types-on-assignment', [instruction.variableName, oldType, valType]);
18606
18909
  }
18607
18910
 
18608
18911
  /* Proceed with assignment */
18609
- frame.setVariable(instruction.variableName, newValue);
18912
+ frame.setVariable(instruction.variableName, newType, newValue);
18610
18913
  frame.instructionPointer++;
18611
18914
  }
18612
18915
  }, {
@@ -19048,7 +19351,7 @@ var VirtualMachine = exports.VirtualMachine = function () {
19048
19351
  }();
19049
19352
 
19050
19353
  /***/ }),
19051
- /* 20 */
19354
+ /* 21 */
19052
19355
  /***/ (function(module, exports, __webpack_require__) {
19053
19356
 
19054
19357
  "use strict";
@@ -19462,7 +19765,7 @@ function fileBoardFormat(filename) {
19462
19765
  return BOARD_FORMATS[DEFAULT_FORMAT];
19463
19766
  }
19464
19767
 
19465
- var fs = __webpack_require__(21);
19768
+ var fs = __webpack_require__(22);
19466
19769
 
19467
19770
  function readJboardFromFile(filename) {
19468
19771
  var format = fileBoardFormat(filename);
@@ -19477,7 +19780,7 @@ function writeJboardToFile(filename, jboard) {
19477
19780
  }
19478
19781
 
19479
19782
  /***/ }),
19480
- /* 21 */
19783
+ /* 22 */
19481
19784
  /***/ (function(module, exports) {
19482
19785
 
19483
19786
 
@@ -1,5 +1,5 @@
1
1
  module Gobstones
2
2
  module CodeRunner
3
- VERSION = "0.4.2"
3
+ VERSION = "0.5.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gobstones-code-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Alfonso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-24 00:00:00.000000000 Z
11
+ date: 2018-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler