pxt-core 11.4.7 → 11.4.8

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.
package/built/pxt.js CHANGED
@@ -126305,15 +126305,17 @@ function ${id}(s) {
126305
126305
  write(`r0 = ${emitExprInto(e)};`);
126306
126306
  }
126307
126307
  }
126308
+ function vTableRef(info) {
126309
+ return `${info.id}_VT`;
126310
+ }
126308
126311
  function checkSubtype(info, r0 = "r0") {
126309
- const vt = `${info.id}_VT`;
126310
- return `checkSubtype(${r0}, ${vt})`;
126312
+ return `checkSubtype(${r0}, ${vTableRef(info)})`;
126311
126313
  }
126312
126314
  function emitInstanceOf(info, tp, r0 = "r0") {
126313
126315
  if (tp == "bool")
126314
126316
  write(`r0 = ${checkSubtype(info)};`);
126315
126317
  else if (tp == "validate") {
126316
- write(`if (!${checkSubtype(info, r0)}) failedCast(${r0});`);
126318
+ write(`if (!${checkSubtype(info, r0)}) failedCast(${r0}, ${vTableRef(info)});`);
126317
126319
  }
126318
126320
  else {
126319
126321
  pxtc.U.oops();
@@ -153245,6 +153247,9 @@ var pxsim;
153245
153247
  }
153246
153248
  pxtrt.mapSet = mapSet;
153247
153249
  function mapGetByString(map, key) {
153250
+ if (!map) {
153251
+ pxsim.throwFailedPropertyAccessError(map, key);
153252
+ }
153248
153253
  key += "";
153249
153254
  if (map instanceof RefRecord) {
153250
153255
  let r = map;
@@ -153258,8 +153263,12 @@ var pxsim;
153258
153263
  }
153259
153264
  pxtrt.mapGetByString = mapGetByString;
153260
153265
  function mapDeleteByString(map, key) {
153261
- if (!(map instanceof RefMap))
153262
- pxtrt.panic(923);
153266
+ if (map === undefined || map === null) {
153267
+ pxsim.throwNullUndefinedAsObjectError();
153268
+ }
153269
+ if (!(map instanceof RefMap)) {
153270
+ pxsim.throwFailedCastError(map, "object");
153271
+ }
153263
153272
  let i = map.findIdx(key);
153264
153273
  if (i >= 0)
153265
153274
  map.data.splice(i, 1);
@@ -153269,6 +153278,9 @@ var pxsim;
153269
153278
  pxtrt.mapSetGeneric = mapSetByString;
153270
153279
  pxtrt.mapGetGeneric = mapGetByString;
153271
153280
  function mapSetByString(map, key, val) {
153281
+ if (!map) {
153282
+ pxsim.throwFailedPropertyAccessError(map, key);
153283
+ }
153272
153284
  key += "";
153273
153285
  if (map instanceof RefRecord) {
153274
153286
  let r = map;
@@ -153288,6 +153300,9 @@ var pxsim;
153288
153300
  }
153289
153301
  pxtrt.mapSetByString = mapSetByString;
153290
153302
  function keysOf(v) {
153303
+ if (v === undefined || v === null) {
153304
+ pxsim.throwNullUndefinedAsObjectError();
153305
+ }
153291
153306
  let r = new pxsim.RefCollection();
153292
153307
  if (v instanceof RefMap)
153293
153308
  for (let k of v.data) {
@@ -153326,6 +153341,7 @@ var pxsim;
153326
153341
  }
153327
153342
  thread.pause = pause;
153328
153343
  function runInBackground(a) {
153344
+ typeCheck(a);
153329
153345
  pxsim.runtime.runFiberAsync(a);
153330
153346
  }
153331
153347
  thread.runInBackground = runInBackground;
@@ -153335,10 +153351,16 @@ var pxsim;
153335
153351
  .then(() => pxsim.U.delay(20))
153336
153352
  .then(loop);
153337
153353
  }
153338
- pxtrt.nullCheck(a);
153354
+ typeCheck(a);
153339
153355
  loop();
153340
153356
  }
153341
153357
  thread.forever = forever;
153358
+ function typeCheck(a) {
153359
+ if (!a || !(a instanceof RefAction) && !a.info) {
153360
+ pxsim.throwFailedCastError(a, "function");
153361
+ }
153362
+ }
153363
+ thread.typeCheck = typeCheck;
153342
153364
  })(thread = pxsim.thread || (pxsim.thread = {}));
153343
153365
  })(pxsim || (pxsim = {}));
153344
153366
  var pxsim;
@@ -153437,35 +153459,35 @@ var pxsim;
153437
153459
  }
153438
153460
  Array_.isArray = isArray;
153439
153461
  function length(c) {
153440
- pxsim.pxtrt.nullCheck(c);
153462
+ typeCheck(c);
153441
153463
  return c.getLength();
153442
153464
  }
153443
153465
  Array_.length = length;
153444
153466
  function setLength(c, x) {
153445
- pxsim.pxtrt.nullCheck(c);
153467
+ typeCheck(c);
153446
153468
  c.setLength(x);
153447
153469
  }
153448
153470
  Array_.setLength = setLength;
153449
153471
  function push(c, x) {
153450
- pxsim.pxtrt.nullCheck(c);
153472
+ typeCheck(c);
153451
153473
  c.push(x);
153452
153474
  }
153453
153475
  Array_.push = push;
153454
153476
  function pop(c, x) {
153455
- pxsim.pxtrt.nullCheck(c);
153477
+ typeCheck(c);
153456
153478
  let ret = c.pop();
153457
153479
  // no decr() since we're returning it
153458
153480
  return ret;
153459
153481
  }
153460
153482
  Array_.pop = pop;
153461
153483
  function getAt(c, x) {
153462
- pxsim.pxtrt.nullCheck(c);
153484
+ typeCheck(c);
153463
153485
  let tmp = c.getAt(x);
153464
153486
  return tmp;
153465
153487
  }
153466
153488
  Array_.getAt = getAt;
153467
153489
  function removeAt(c, x) {
153468
- pxsim.pxtrt.nullCheck(c);
153490
+ typeCheck(c);
153469
153491
  if (!c.isValidIndex(x))
153470
153492
  return;
153471
153493
  // no decr() since we're returning it
@@ -153473,22 +153495,22 @@ var pxsim;
153473
153495
  }
153474
153496
  Array_.removeAt = removeAt;
153475
153497
  function insertAt(c, x, y) {
153476
- pxsim.pxtrt.nullCheck(c);
153498
+ typeCheck(c);
153477
153499
  c.insertAt(x, y);
153478
153500
  }
153479
153501
  Array_.insertAt = insertAt;
153480
153502
  function setAt(c, x, y) {
153481
- pxsim.pxtrt.nullCheck(c);
153503
+ typeCheck(c);
153482
153504
  c.setAt(x, y);
153483
153505
  }
153484
153506
  Array_.setAt = setAt;
153485
153507
  function indexOf(c, x, start) {
153486
- pxsim.pxtrt.nullCheck(c);
153508
+ typeCheck(c);
153487
153509
  return c.indexOf(x, start);
153488
153510
  }
153489
153511
  Array_.indexOf = indexOf;
153490
153512
  function removeElement(c, x) {
153491
- pxsim.pxtrt.nullCheck(c);
153513
+ typeCheck(c);
153492
153514
  let idx = indexOf(c, x, 0);
153493
153515
  if (idx >= 0) {
153494
153516
  removeAt(c, idx);
@@ -153497,6 +153519,12 @@ var pxsim;
153497
153519
  return 0;
153498
153520
  }
153499
153521
  Array_.removeElement = removeElement;
153522
+ function typeCheck(c) {
153523
+ if (!(c instanceof RefCollection)) {
153524
+ pxsim.throwFailedCastError(c, "Array");
153525
+ }
153526
+ }
153527
+ Array_.typeCheck = typeCheck;
153500
153528
  })(Array_ = pxsim.Array_ || (pxsim.Array_ = {}));
153501
153529
  let Math_;
153502
153530
  (function (Math_) {
@@ -153712,24 +153740,28 @@ var pxsim;
153712
153740
  }
153713
153741
  String_.fromCharCode = fromCharCode;
153714
153742
  function toNumber(s) {
153743
+ typeCheck(s);
153715
153744
  return parseFloat(s);
153716
153745
  }
153717
153746
  String_.toNumber = toNumber;
153718
153747
  // TODO check edge-conditions
153719
153748
  function concat(a, b) {
153749
+ typeCheck(a);
153720
153750
  return (a + b);
153721
153751
  }
153722
153752
  String_.concat = concat;
153723
153753
  function substring(s, i, j) {
153724
- pxsim.pxtrt.nullCheck(s);
153754
+ typeCheck(s);
153725
153755
  return (s.slice(i, i + j));
153726
153756
  }
153727
153757
  String_.substring = substring;
153728
153758
  function equals(s1, s2) {
153759
+ typeCheck(s1);
153729
153760
  return s1 == s2;
153730
153761
  }
153731
153762
  String_.equals = equals;
153732
153763
  function compare(s1, s2) {
153764
+ typeCheck(s1);
153733
153765
  if (s1 == s2)
153734
153766
  return 0;
153735
153767
  if (s1 < s2)
@@ -153738,6 +153770,7 @@ var pxsim;
153738
153770
  }
153739
153771
  String_.compare = compare;
153740
153772
  function compareDecr(s1, s2) {
153773
+ typeCheck(s1);
153741
153774
  if (s1 == s2) {
153742
153775
  return 0;
153743
153776
  }
@@ -153747,47 +153780,56 @@ var pxsim;
153747
153780
  }
153748
153781
  String_.compareDecr = compareDecr;
153749
153782
  function length(s) {
153783
+ typeCheck(s);
153750
153784
  return s.length;
153751
153785
  }
153752
153786
  String_.length = length;
153753
153787
  function substr(s, start, length) {
153788
+ typeCheck(s);
153754
153789
  return (s.substr(start, length));
153755
153790
  }
153756
153791
  String_.substr = substr;
153757
153792
  function inRange(s, i) {
153758
- pxsim.pxtrt.nullCheck(s);
153793
+ typeCheck(s);
153759
153794
  return 0 <= i && i < s.length;
153760
153795
  }
153761
153796
  function charAt(s, i) {
153797
+ typeCheck(s);
153762
153798
  return (s.charAt(i));
153763
153799
  }
153764
153800
  String_.charAt = charAt;
153765
153801
  function charCodeAt(s, i) {
153766
- pxsim.pxtrt.nullCheck(s);
153802
+ typeCheck(s);
153767
153803
  return inRange(s, i) ? s.charCodeAt(i) : 0;
153768
153804
  }
153769
153805
  String_.charCodeAt = charCodeAt;
153770
153806
  function indexOf(s, searchValue, start) {
153771
- pxsim.pxtrt.nullCheck(s);
153807
+ typeCheck(s);
153772
153808
  if (searchValue == null)
153773
153809
  return -1;
153774
153810
  return s.indexOf(searchValue, start);
153775
153811
  }
153776
153812
  String_.indexOf = indexOf;
153777
153813
  function lastIndexOf(s, searchValue, start) {
153778
- pxsim.pxtrt.nullCheck(s);
153814
+ typeCheck(s);
153779
153815
  if (searchValue == null)
153780
153816
  return -1;
153781
153817
  return s.lastIndexOf(searchValue, start);
153782
153818
  }
153783
153819
  String_.lastIndexOf = lastIndexOf;
153784
153820
  function includes(s, searchValue, start) {
153785
- pxsim.pxtrt.nullCheck(s);
153821
+ typeCheck(s);
153786
153822
  if (searchValue == null)
153787
153823
  return false;
153788
153824
  return s.includes(searchValue, start);
153789
153825
  }
153790
153826
  String_.includes = includes;
153827
+ function typeCheck(s) {
153828
+ if (typeof s !== "string") {
153829
+ pxsim.throwFailedCastError(s, "string");
153830
+ }
153831
+ }
153832
+ String_.typeCheck = typeCheck;
153791
153833
  })(String_ = pxsim.String_ || (pxsim.String_ = {}));
153792
153834
  let Boolean_;
153793
153835
  (function (Boolean_) {
@@ -153880,6 +153922,7 @@ var pxsim;
153880
153922
  return { size, signed, swap, isFloat };
153881
153923
  }
153882
153924
  function getNumber(buf, fmt, offset) {
153925
+ typeCheck(buf);
153883
153926
  let inf = fmtInfo(fmt);
153884
153927
  if (inf.isFloat) {
153885
153928
  let subarray = buf.data.buffer.slice(offset, offset + inf.size);
@@ -153909,6 +153952,7 @@ var pxsim;
153909
153952
  }
153910
153953
  BufferMethods.getNumber = getNumber;
153911
153954
  function setNumber(buf, fmt, offset, r) {
153955
+ typeCheck(buf);
153912
153956
  let inf = fmtInfo(fmt);
153913
153957
  if (inf.isFloat) {
153914
153958
  let arr = new Uint8Array(inf.size);
@@ -153935,6 +153979,7 @@ var pxsim;
153935
153979
  }
153936
153980
  BufferMethods.createBuffer = createBuffer;
153937
153981
  function createBufferFromHex(hex) {
153982
+ String_.typeCheck(hex);
153938
153983
  let r = createBuffer(hex.length >> 1);
153939
153984
  for (let i = 0; i < hex.length; i += 2)
153940
153985
  r.data[i >> 1] = parseInt(hex.slice(i, i + 2), 16);
@@ -153943,23 +153988,26 @@ var pxsim;
153943
153988
  }
153944
153989
  BufferMethods.createBufferFromHex = createBufferFromHex;
153945
153990
  function isReadOnly(buf) {
153991
+ typeCheck(buf);
153946
153992
  return buf.isStatic;
153947
153993
  }
153948
153994
  BufferMethods.isReadOnly = isReadOnly;
153949
153995
  function getBytes(buf) {
153996
+ typeCheck(buf);
153950
153997
  // not sure if this is any useful...
153951
153998
  return buf.data;
153952
153999
  }
153953
154000
  BufferMethods.getBytes = getBytes;
153954
154001
  function inRange(buf, off) {
153955
- pxsim.pxtrt.nullCheck(buf);
153956
154002
  return 0 <= off && off < buf.data.length;
153957
154003
  }
153958
154004
  function getUint8(buf, off) {
154005
+ typeCheck(buf);
153959
154006
  return getByte(buf, off);
153960
154007
  }
153961
154008
  BufferMethods.getUint8 = getUint8;
153962
154009
  function getByte(buf, off) {
154010
+ typeCheck(buf);
153963
154011
  if (inRange(buf, off))
153964
154012
  return buf.data[off];
153965
154013
  else
@@ -153967,6 +154015,7 @@ var pxsim;
153967
154015
  }
153968
154016
  BufferMethods.getByte = getByte;
153969
154017
  function setUint8(buf, off, v) {
154018
+ typeCheck(buf);
153970
154019
  setByte(buf, off, v);
153971
154020
  }
153972
154021
  BufferMethods.setUint8 = setUint8;
@@ -153975,6 +154024,7 @@ var pxsim;
153975
154024
  pxsim.U.userError("Writing to read only buffer.");
153976
154025
  }
153977
154026
  function setByte(buf, off, v) {
154027
+ typeCheck(buf);
153978
154028
  if (inRange(buf, off)) {
153979
154029
  checkWrite(buf);
153980
154030
  buf.data[off] = v;
@@ -153982,10 +154032,12 @@ var pxsim;
153982
154032
  }
153983
154033
  BufferMethods.setByte = setByte;
153984
154034
  function length(buf) {
154035
+ typeCheck(buf);
153985
154036
  return buf.data.length;
153986
154037
  }
153987
154038
  BufferMethods.length = length;
153988
154039
  function fill(buf, value, offset = 0, length = -1) {
154040
+ typeCheck(buf);
153989
154041
  if (offset < 0 || offset > buf.data.length)
153990
154042
  return;
153991
154043
  if (length < 0)
@@ -153996,6 +154048,7 @@ var pxsim;
153996
154048
  }
153997
154049
  BufferMethods.fill = fill;
153998
154050
  function slice(buf, offset, length) {
154051
+ typeCheck(buf);
153999
154052
  offset = Math.min(buf.data.length, offset);
154000
154053
  if (length < 0)
154001
154054
  length = buf.data.length;
@@ -154004,6 +154057,7 @@ var pxsim;
154004
154057
  }
154005
154058
  BufferMethods.slice = slice;
154006
154059
  function toHex(buf) {
154060
+ typeCheck(buf);
154007
154061
  const hex = "0123456789abcdef";
154008
154062
  let res = "";
154009
154063
  for (let i = 0; i < buf.data.length; ++i) {
@@ -154014,6 +154068,7 @@ var pxsim;
154014
154068
  }
154015
154069
  BufferMethods.toHex = toHex;
154016
154070
  function toString(buf) {
154071
+ typeCheck(buf);
154017
154072
  return pxsim.U.fromUTF8Array(buf.data);
154018
154073
  }
154019
154074
  BufferMethods.toString = toString;
@@ -154028,6 +154083,7 @@ var pxsim;
154028
154083
  }
154029
154084
  const INT_MIN = -0x80000000;
154030
154085
  function shift(buf, offset, start, len) {
154086
+ typeCheck(buf);
154031
154087
  if (len < 0)
154032
154088
  len = buf.data.length - start;
154033
154089
  if (start < 0 || start + len > buf.data.length || start + len < start
@@ -154053,6 +154109,7 @@ var pxsim;
154053
154109
  }
154054
154110
  BufferMethods.shift = shift;
154055
154111
  function rotate(buf, offset, start, len) {
154112
+ typeCheck(buf);
154056
154113
  if (len < 0)
154057
154114
  len = buf.data.length - start;
154058
154115
  if (start < 0 || start + len > buf.data.length || start + len < start
@@ -154083,6 +154140,8 @@ var pxsim;
154083
154140
  }
154084
154141
  BufferMethods.rotate = rotate;
154085
154142
  function write(buf, dstOffset, src, srcOffset = 0, length = -1) {
154143
+ typeCheck(buf);
154144
+ typeCheck(src);
154086
154145
  if (length < 0)
154087
154146
  length = src.data.length;
154088
154147
  if (srcOffset < 0 || dstOffset < 0 || dstOffset > buf.data.length)
@@ -154094,12 +154153,19 @@ var pxsim;
154094
154153
  memmove(buf.data, dstOffset, src.data, srcOffset, length);
154095
154154
  }
154096
154155
  BufferMethods.write = write;
154156
+ function typeCheck(buf) {
154157
+ if (!(buf instanceof RefBuffer)) {
154158
+ pxsim.throwFailedCastError(buf, "Buffer");
154159
+ }
154160
+ }
154161
+ BufferMethods.typeCheck = typeCheck;
154097
154162
  })(BufferMethods = pxsim.BufferMethods || (pxsim.BufferMethods = {}));
154098
154163
  })(pxsim || (pxsim = {}));
154099
154164
  (function (pxsim) {
154100
154165
  var control;
154101
154166
  (function (control) {
154102
154167
  function createBufferFromUTF8(str) {
154168
+ pxsim.String_.typeCheck(str);
154103
154169
  return new pxsim.RefBuffer(pxsim.U.toUTF8Array(str));
154104
154170
  }
154105
154171
  control.createBufferFromUTF8 = createBufferFromUTF8;
@@ -155394,11 +155460,12 @@ var pxsim;
155394
155460
  return true;
155395
155461
  return vt2 && vt.classNo <= vt2.classNo && vt2.classNo <= vt.lastSubtypeNo;
155396
155462
  }
155397
- function failedCast(v) {
155463
+ function failedCast(v, expectedType) {
155398
155464
  // TODO generate the right panic codes
155399
- if (pxsim.control && pxsim.control.dmesgValue)
155465
+ if (pxsim.control && pxsim.control.dmesgValue) {
155400
155466
  pxsim.control.dmesgValue(v);
155401
- oops("failed cast on " + v);
155467
+ }
155468
+ throwFailedCastError(v, expectedType === null || expectedType === void 0 ? void 0 : expectedType.name);
155402
155469
  }
155403
155470
  function buildResume(s, retPC) {
155404
155471
  if (currResume)
@@ -155923,6 +155990,69 @@ var pxsim;
155923
155990
  }
155924
155991
  }
155925
155992
  pxsim.Runtime = Runtime;
155993
+ function throwUserException(message) {
155994
+ throw new Error(message);
155995
+ }
155996
+ pxsim.throwUserException = throwUserException;
155997
+ function throwTypeError(message) {
155998
+ throwUserException(pxsim.localization.lf("TypeError: {0}", message));
155999
+ }
156000
+ pxsim.throwTypeError = throwTypeError;
156001
+ function throwFailedCastError(value, expectedType) {
156002
+ const typename = getType(value);
156003
+ if (expectedType) {
156004
+ if (value === null || value === undefined) {
156005
+ throwTypeError(pxsim.localization.lf("Expected type {0} but received type {1}. Did you forget to assign a variable?", expectedType, typename));
156006
+ }
156007
+ else {
156008
+ throwTypeError(pxsim.localization.lf("Expected type {0} but received type {1}", expectedType, typename));
156009
+ }
156010
+ }
156011
+ else {
156012
+ throwTypeError(pxsim.localization.lf("Cannot read properties of {0}", typename));
156013
+ }
156014
+ }
156015
+ pxsim.throwFailedCastError = throwFailedCastError;
156016
+ function throwFailedPropertyAccessError(value, propertyName) {
156017
+ const typename = getType(value);
156018
+ if (propertyName) {
156019
+ throwTypeError(pxsim.localization.lf("Cannot read properties of {0} (reading '{1}')", typename, propertyName));
156020
+ }
156021
+ else {
156022
+ throwTypeError(pxsim.localization.lf("Cannot read properties of {0}", typename));
156023
+ }
156024
+ }
156025
+ pxsim.throwFailedPropertyAccessError = throwFailedPropertyAccessError;
156026
+ function throwNullUndefinedAsObjectError() {
156027
+ throwTypeError(pxsim.localization.lf("Cannot convert undefined or null to object"));
156028
+ }
156029
+ pxsim.throwNullUndefinedAsObjectError = throwNullUndefinedAsObjectError;
156030
+ function getType(value) {
156031
+ let typename;
156032
+ const vtable = value === null || value === void 0 ? void 0 : value.vtable;
156033
+ if (vtable) {
156034
+ typename = vtable.name;
156035
+ }
156036
+ else if (value === null) {
156037
+ typename = "null";
156038
+ }
156039
+ else if (value === undefined) {
156040
+ typename = "undefined";
156041
+ }
156042
+ else if (value instanceof pxsim.RefCollection) {
156043
+ typename = "Array";
156044
+ }
156045
+ else if (value instanceof pxsim.RefBuffer) {
156046
+ typename = "Buffer";
156047
+ }
156048
+ else if (value instanceof pxsim.RefAction) {
156049
+ typename = "function";
156050
+ }
156051
+ else {
156052
+ typename = typeof value;
156053
+ }
156054
+ return typename;
156055
+ }
155926
156056
  function setParentMuteState(state) {
155927
156057
  Runtime.postMessage({
155928
156058
  type: "setmutebuttonstate",
@@ -2640,15 +2640,17 @@ function ${id}(s) {
2640
2640
  write(`r0 = ${emitExprInto(e)};`);
2641
2641
  }
2642
2642
  }
2643
+ function vTableRef(info) {
2644
+ return `${info.id}_VT`;
2645
+ }
2643
2646
  function checkSubtype(info, r0 = "r0") {
2644
- const vt = `${info.id}_VT`;
2645
- return `checkSubtype(${r0}, ${vt})`;
2647
+ return `checkSubtype(${r0}, ${vTableRef(info)})`;
2646
2648
  }
2647
2649
  function emitInstanceOf(info, tp, r0 = "r0") {
2648
2650
  if (tp == "bool")
2649
2651
  write(`r0 = ${checkSubtype(info)};`);
2650
2652
  else if (tp == "validate") {
2651
- write(`if (!${checkSubtype(info, r0)}) failedCast(${r0});`);
2653
+ write(`if (!${checkSubtype(info, r0)}) failedCast(${r0}, ${vTableRef(info)});`);
2652
2654
  }
2653
2655
  else {
2654
2656
  pxtc.U.oops();
package/built/pxtsim.d.ts CHANGED
@@ -836,6 +836,7 @@ declare namespace pxsim {
836
836
  function pause(ms: number): void;
837
837
  function runInBackground(a: RefAction): void;
838
838
  function forever(a: RefAction): void;
839
+ function typeCheck(a: RefAction): void;
839
840
  }
840
841
  }
841
842
  declare namespace pxsim {
@@ -874,6 +875,7 @@ declare namespace pxsim {
874
875
  function setAt(c: RefCollection, x: number, y: any): void;
875
876
  function indexOf(c: RefCollection, x: any, start: number): number;
876
877
  function removeElement(c: RefCollection, x: any): 0 | 1;
878
+ function typeCheck(c: RefCollection): void;
877
879
  }
878
880
  namespace Math_ {
879
881
  const imul: (x: number, y: number) => number;
@@ -964,6 +966,7 @@ declare namespace pxsim {
964
966
  function indexOf(s: string, searchValue: string, start?: number): number;
965
967
  function lastIndexOf(s: string, searchValue: string, start?: number): number;
966
968
  function includes(s: string, searchValue: string, start?: number): boolean;
969
+ function typeCheck(s: string): void;
967
970
  }
968
971
  namespace Boolean_ {
969
972
  function toString(v: boolean): "true" | "false";
@@ -1017,6 +1020,7 @@ declare namespace pxsim {
1017
1020
  function shift(buf: RefBuffer, offset: number, start: number, len: number): void;
1018
1021
  function rotate(buf: RefBuffer, offset: number, start: number, len: number): void;
1019
1022
  function write(buf: RefBuffer, dstOffset: number, src: RefBuffer, srcOffset?: number, length?: number): void;
1023
+ function typeCheck(buf: RefBuffer): void;
1020
1024
  }
1021
1025
  }
1022
1026
  declare namespace pxsim.control {
@@ -1308,6 +1312,11 @@ declare namespace pxsim {
1308
1312
  cleanScheduledExpired(): void;
1309
1313
  registerUserInteraction(): void;
1310
1314
  }
1315
+ export function throwUserException(message: string): void;
1316
+ export function throwTypeError(message: string): void;
1317
+ export function throwFailedCastError(value: any, expectedType?: string): void;
1318
+ export function throwFailedPropertyAccessError(value: any, propertyName?: string): void;
1319
+ export function throwNullUndefinedAsObjectError(): void;
1311
1320
  export function setParentMuteState(state: "muted" | "unmuted" | "disabled"): void;
1312
1321
  export class PerfCounter {
1313
1322
  name: string;