gobstones-code-runner 0.3.1 → 0.4.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e4285778bfc03d0ece1c37c5279f61d1c0696f25943ef5c4bf9abb7136ae3f5
4
- data.tar.gz: 3851219e420573ce04cd2510da0dd1c8c0c01be823298830ead2577c7da3b53f
3
+ metadata.gz: c753732e0686c2b15d104e5040fe90f3ac732f63acb4782eaff3f0651823a13c
4
+ data.tar.gz: 9377a6de2f1e8daca3eb45064a4a64ad3797b07d9ecd74c7ea8bb6216cdd968e
5
5
  SHA512:
6
- metadata.gz: fa4f7b969ff2ed2626478dd0db313d5e24261bb16d573fce02d8d085bf7e321e645ff790e11b9b5db5def4da64eed3cb8802c4b67fa566b854c0628c592c5c87
7
- data.tar.gz: a219c627c4f4b9bae47d9e18faed329848ce10e143ccf8358f8f3557bf159e9920ffc1d1f40c311a6d910c9a79ec3f9d7b256f59fe3e533bfd6d3f259bb930d8
6
+ metadata.gz: 218aa61a1d56e59cc195c534912f4b8f0a3d9c298221ef80c0e0d851702a7a421b531a48d553329a02af436695032659b264287e85cc4a8fb6938f84f7e2bd3b
7
+ data.tar.gz: 77b564c6fe24a79bb1913e753084acfe39dfb77e6b7a52ce3b0ba87ff3f2928e49328e4ecdde3225b64603f5f170539ff2407f6c65223f2d17872de2a154e6f2
@@ -4367,7 +4367,7 @@ function i18n(message) {
4367
4367
 
4368
4368
  function i18nWithLanguage(code, thunk) {
4369
4369
  if (!(code in dictionaries)) {
4370
- throw Error('Invlid language code: ' + code);
4370
+ throw Error('Invalid language code: ' + code);
4371
4371
  }
4372
4372
  var oldLanguage = CURRENT_LANGUAGE;
4373
4373
  CURRENT_LANGUAGE = code;
@@ -6394,6 +6394,17 @@ var RuntimePrimitives = exports.RuntimePrimitives = function () {
6394
6394
  }
6395
6395
  }
6396
6396
 
6397
+ this._primitiveProcedures[(0, _i18n.i18n)('PRIM:TypeCheck')] = new PrimitiveOperation([typeAny, typeAny, typeString], function (startPos, endPos, globalState, args) {
6398
+ var v1 = args[0];
6399
+ var v2 = args[1];
6400
+ var errorMessage = args[2];
6401
+ if ((0, _value.joinTypes)(v1.type(), v2.type()) === null) {
6402
+ fail(startPos, endPos, 'typecheck-failed', [errorMessage.string, v1.type(), v2.type()]);
6403
+ }
6404
+ }, function (globalState, color) {
6405
+ return null;
6406
+ });
6407
+
6397
6408
  this._primitiveProcedures[(0, _i18n.i18n)('PRIM:PutStone')] = new PrimitiveOperation([typeColor()], noValidation, function (globalState, color) {
6398
6409
  globalState.putStone(colorFromValue(color));
6399
6410
  return null;
@@ -6607,6 +6618,15 @@ var RuntimePrimitives = exports.RuntimePrimitives = function () {
6607
6618
  return a.mod(b);
6608
6619
  });
6609
6620
 
6621
+ this._primitiveFunctions['^'] = new PrimitiveOperation([typeInteger, typeInteger], function (startPos, endPos, globalState, args) {
6622
+ var b = args[1];
6623
+ if (b.lt(new _value.ValueInteger(0))) {
6624
+ fail(startPos, endPos, 'negative-exponent', []);
6625
+ }
6626
+ }, function (globalState, a, b) {
6627
+ return a.pow(b);
6628
+ });
6629
+
6610
6630
  this._primitiveFunctions['-(unary)'] = new PrimitiveOperation([typeAny], function (startPos, endPos, globalState, args) {
6611
6631
  var a = args[0];
6612
6632
  validateTypeAmong(startPos, endPos, a, typesWithOpposite());
@@ -7557,6 +7577,16 @@ var ValueInteger = exports.ValueInteger = function (_Value) {
7557
7577
  var q = this.div(other);
7558
7578
  return this.sub(q.mul(other));
7559
7579
  }
7580
+
7581
+ /* Assumes that 'other' is non-negative */
7582
+
7583
+ }, {
7584
+ key: 'pow',
7585
+ value: function pow(other) {
7586
+ var a = (0, _bigint.Integer)(this._number);
7587
+ var b = (0, _bigint.Integer)(other._number);
7588
+ return new ValueInteger(a.pow(b).toString());
7589
+ }
7560
7590
  }, {
7561
7591
  key: 'eq',
7562
7592
  value: function eq(other) {
@@ -8751,6 +8781,29 @@ function openingDelimiterName(delimiter) {
8751
8781
  }
8752
8782
  }
8753
8783
 
8784
+ function formatTypes(string, type1, type2) {
8785
+ var result = '';
8786
+ for (var i = 0; i < string.length; i++) {
8787
+ if (string[i] === '%' && i + 1 < string.length) {
8788
+ if (string[i + 1] === '%') {
8789
+ result += '%';
8790
+ i++;
8791
+ } else if (string[i + 1] === '1') {
8792
+ result += typeAsNoun(type1);
8793
+ i++;
8794
+ } else if (string[i + 1] === '2') {
8795
+ result += typeAsNoun(type2);
8796
+ i++;
8797
+ } else {
8798
+ result += '%';
8799
+ }
8800
+ } else {
8801
+ result += string[i];
8802
+ }
8803
+ }
8804
+ return result;
8805
+ }
8806
+
8754
8807
  var LOCALE_ES = exports.LOCALE_ES = {
8755
8808
 
8756
8809
  /* Descriptions of syntactic constructions and tokens */
@@ -9109,12 +9162,19 @@ var LOCALE_ES = exports.LOCALE_ES = {
9109
9162
 
9110
9163
  'errmsg:cannot-divide-by-zero': 'No se puede dividir por cero.',
9111
9164
 
9165
+ 'errmsg:negative-exponent': 'El exponente de la potencia no puede ser negativo.',
9166
+
9112
9167
  'errmsg:list-cannot-be-empty': 'La lista no puede ser vacía.',
9113
9168
 
9114
9169
  'errmsg:timeout': function errmsgTimeout(millisecs) {
9115
9170
  return 'La ejecución del programa demoró más de ' + millisecs.toString() + 'ms.';
9116
9171
  },
9117
9172
 
9173
+ /* Typecheck */
9174
+ 'errmsg:typecheck-failed': function errmsgTypecheckFailed(errorMessage, type1, type2) {
9175
+ return formatTypes(errorMessage, type1, type2);
9176
+ },
9177
+
9118
9178
  /* Board operations */
9119
9179
  'errmsg:cannot-move-to': function errmsgCannotMoveTo(dirName) {
9120
9180
  return 'No se puede mover hacia la dirección ' + dirName + ': cae afuera del tablero.';
@@ -9151,6 +9211,7 @@ var LOCALE_ES = exports.LOCALE_ES = {
9151
9211
  'CONS:Dir2': 'Sur',
9152
9212
  'CONS:Dir3': 'Oeste',
9153
9213
 
9214
+ 'PRIM:TypeCheck': 'TypeCheck',
9154
9215
  'PRIM:BOOM': 'BOOM',
9155
9216
  'PRIM:boom': 'boom',
9156
9217
 
@@ -1,5 +1,5 @@
1
1
  module Gobstones
2
2
  module CodeRunner
3
- VERSION = "0.3.1"
3
+ VERSION = "0.4.1"
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.3.1
4
+ version: 0.4.1
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-05-09 00:00:00.000000000 Z
11
+ date: 2018-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.7.6
91
+ rubygems_version: 2.7.7
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Gobstones Code Runner