pxt-core 8.2.3 → 8.2.6

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.
@@ -12931,9 +12931,6 @@ var pxtblockly;
12931
12931
  }
12932
12932
  }
12933
12933
  containerSize.height += addedHeight;
12934
- if (this.sourceBlock_.RTL) {
12935
- Blockly.utils.uiMenu.adjustBBoxesForRTL(viewportBBox, anchorBBox, containerSize);
12936
- }
12937
12934
  // Position the menu.
12938
12935
  Blockly.WidgetDiv.positionWithAnchor(viewportBBox, anchorBBox, containerSize, this.sourceBlock_.RTL);
12939
12936
  // (<any>scrollContainer).focus();
@@ -15424,6 +15421,8 @@ var pxtblockly;
15424
15421
  this.options.interpolationFieldName = "interpolation";
15425
15422
  if (!this.options.effectFieldName)
15426
15423
  this.options.effectFieldName = "effect";
15424
+ if (!this.options.useMixerSynthesizer)
15425
+ this.options.useMixerSynthesizer = false;
15427
15426
  this.redrawPreview();
15428
15427
  if (this.sourceBlock_.workspace) {
15429
15428
  this.workspace = this.sourceBlock_.workspace;
@@ -15540,7 +15539,8 @@ var pxtblockly;
15540
15539
  this.updateSiblingBlocks(newSound);
15541
15540
  this.redrawPreview();
15542
15541
  },
15543
- initialSound: initialSound
15542
+ initialSound: initialSound,
15543
+ useMixerSynthesizer: isTrue(this.options.useMixerSynthesizer)
15544
15544
  };
15545
15545
  const fv = pxt.react.getFieldEditorView("soundeffect-editor", initialSound, opts, widgetDiv);
15546
15546
  const block = this.sourceBlock_;
@@ -15734,6 +15734,23 @@ var pxtblockly;
15734
15734
  function reverseLookup(map, value) {
15735
15735
  return Object.keys(map).find(k => map[k] === value);
15736
15736
  }
15737
+ function isTrue(value) {
15738
+ if (!value)
15739
+ return false;
15740
+ if (typeof value === "string") {
15741
+ switch (value.toLowerCase().trim()) {
15742
+ case "1":
15743
+ case "yes":
15744
+ case "y":
15745
+ case "on":
15746
+ case "true":
15747
+ return true;
15748
+ default:
15749
+ return false;
15750
+ }
15751
+ }
15752
+ return !!value;
15753
+ }
15737
15754
  })(pxtblockly || (pxtblockly = {}));
15738
15755
  /// <reference path="../../localtypings/blockly.d.ts"/>
15739
15756
  /// <reference path="../../built/pxtsim.d.ts"/>
@@ -1187,6 +1187,7 @@ declare namespace pxtblockly {
1187
1187
  waveFieldName: string;
1188
1188
  interpolationFieldName: string;
1189
1189
  effectFieldName: string;
1190
+ useMixerSynthesizer: any;
1190
1191
  }
1191
1192
  class FieldSoundEffect extends FieldBase<FieldSoundEffectParams> {
1192
1193
  protected mostRecentValue: pxt.assets.Sound;
@@ -9369,9 +9369,6 @@ var pxtblockly;
9369
9369
  }
9370
9370
  }
9371
9371
  containerSize.height += addedHeight;
9372
- if (this.sourceBlock_.RTL) {
9373
- Blockly.utils.uiMenu.adjustBBoxesForRTL(viewportBBox, anchorBBox, containerSize);
9374
- }
9375
9372
  // Position the menu.
9376
9373
  Blockly.WidgetDiv.positionWithAnchor(viewportBBox, anchorBBox, containerSize, this.sourceBlock_.RTL);
9377
9374
  // (<any>scrollContainer).focus();
@@ -11862,6 +11859,8 @@ var pxtblockly;
11862
11859
  this.options.interpolationFieldName = "interpolation";
11863
11860
  if (!this.options.effectFieldName)
11864
11861
  this.options.effectFieldName = "effect";
11862
+ if (!this.options.useMixerSynthesizer)
11863
+ this.options.useMixerSynthesizer = false;
11865
11864
  this.redrawPreview();
11866
11865
  if (this.sourceBlock_.workspace) {
11867
11866
  this.workspace = this.sourceBlock_.workspace;
@@ -11978,7 +11977,8 @@ var pxtblockly;
11978
11977
  this.updateSiblingBlocks(newSound);
11979
11978
  this.redrawPreview();
11980
11979
  },
11981
- initialSound: initialSound
11980
+ initialSound: initialSound,
11981
+ useMixerSynthesizer: isTrue(this.options.useMixerSynthesizer)
11982
11982
  };
11983
11983
  const fv = pxt.react.getFieldEditorView("soundeffect-editor", initialSound, opts, widgetDiv);
11984
11984
  const block = this.sourceBlock_;
@@ -12172,6 +12172,23 @@ var pxtblockly;
12172
12172
  function reverseLookup(map, value) {
12173
12173
  return Object.keys(map).find(k => map[k] === value);
12174
12174
  }
12175
+ function isTrue(value) {
12176
+ if (!value)
12177
+ return false;
12178
+ if (typeof value === "string") {
12179
+ switch (value.toLowerCase().trim()) {
12180
+ case "1":
12181
+ case "yes":
12182
+ case "y":
12183
+ case "on":
12184
+ case "true":
12185
+ return true;
12186
+ default:
12187
+ return false;
12188
+ }
12189
+ }
12190
+ return !!value;
12191
+ }
12175
12192
  })(pxtblockly || (pxtblockly = {}));
12176
12193
  /// <reference path="../../localtypings/blockly.d.ts"/>
12177
12194
  /// <reference path="../../built/pxtsim.d.ts"/>
@@ -121,6 +121,7 @@ declare namespace ts.pxtc {
121
121
  private emitFieldAccess;
122
122
  private writeFailBranch;
123
123
  private emitClassCall;
124
+ private helperObject;
124
125
  private emitBindHelper;
125
126
  private ifaceCallCore;
126
127
  private emitIfaceCall;
@@ -665,6 +665,7 @@ var ts;
665
665
  const info = utf8AsmStringLiteral(strLit);
666
666
  return `
667
667
  .balign 4
668
+ .object ${lbl}
668
669
  ${lbl}: ${this.obj_header(info.vt)}
669
670
  ${info.asm}
670
671
  `;
@@ -675,6 +676,7 @@ var ts;
675
676
  const align = /f{16}/i.test(data) ? 8 : 4;
676
677
  return `
677
678
  .balign ${align}
679
+ .object ${lbl}
678
680
  ${lbl}: ${this.obj_header("pxt::buffer_vt")}
679
681
  ${hexLiteralAsm(data)}
680
682
  `;
@@ -784,6 +786,7 @@ ${hexLiteralAsm(data)}
784
786
  ;
785
787
  `);
786
788
  let baseLabel = this.proc.label();
789
+ this.write(`.object ${baseLabel} ${JSON.stringify(this.proc.getFullName())}`);
787
790
  let preLabel = baseLabel + "_pre";
788
791
  let bkptLabel = baseLabel + "_bkpt";
789
792
  let locLabel = baseLabel + "_locals";
@@ -1148,9 +1151,13 @@ ${baseLabel}_nochk:
1148
1151
  this.writeFailBranch();
1149
1152
  });
1150
1153
  }
1154
+ helperObject(desc) {
1155
+ return `.object _pxt_helper_${desc.replace(/[^\w]+/g, "_")} "helper: ${desc}"`;
1156
+ }
1151
1157
  emitBindHelper() {
1152
1158
  const maxArgs = 12;
1153
1159
  this.write(`
1160
+ ${this.helperObject("bind")}
1154
1161
  .section code
1155
1162
  _pxt_bind_helper:
1156
1163
  push {r0, r2}
@@ -1625,6 +1632,7 @@ ${baseLabel}_nochk:
1625
1632
  emitFieldMethods() {
1626
1633
  for (let op of ["get", "set"]) {
1627
1634
  this.write(`
1635
+ ${this.helperObject(op)}
1628
1636
  .section code
1629
1637
  _pxt_map_${op}:
1630
1638
  `);
@@ -1666,6 +1674,7 @@ ${baseLabel}_nochk:
1666
1674
  }
1667
1675
  emitArrayMethod(op, isBuffer) {
1668
1676
  this.write(`
1677
+ ${this.helperObject(op + " " + (isBuffer ? "buffer" : "array"))}
1669
1678
  .section code
1670
1679
  _pxt_${isBuffer ? "buffer" : "array"}_${op}:
1671
1680
  `);
@@ -1750,6 +1759,7 @@ ${baseLabel}_nochk:
1750
1759
  emitLambdaTrampoline() {
1751
1760
  let r3 = pxtc.target.stackAlign ? "r3," : "";
1752
1761
  this.write(`
1762
+ ${this.helperObject("trampoline")}
1753
1763
  .section code
1754
1764
  _pxt_lambda_trampoline:
1755
1765
  push {${r3} r4, r5, r6, r7, lr}
@@ -1789,6 +1799,7 @@ ${baseLabel}_nochk:
1789
1799
  mov r11, r7
1790
1800
  pop {${r3} r4, r5, r6, r7, pc}`);
1791
1801
  this.write(`
1802
+ ${this.helperObject("exn")}
1792
1803
  .section code
1793
1804
  ; r0 - try frame
1794
1805
  ; r1 - handler PC
@@ -1817,6 +1828,7 @@ ${baseLabel}_nochk:
1817
1828
  bx r1
1818
1829
  `);
1819
1830
  this.write(`
1831
+ ${this.helperObject("stringconv")}
1820
1832
  .section code
1821
1833
  _pxt_stringConv:
1822
1834
  `);
@@ -3131,6 +3143,7 @@ _numops_fromInt:
3131
3143
  // this make sure to set the Z flag correctly
3132
3144
  r += `
3133
3145
  .section code
3146
+ .object _pxt_helper_cmp_${op}
3134
3147
  _cmp_${op}:
3135
3148
  lsls r2, r0, #31
3136
3149
  beq .boxed
@@ -7716,7 +7729,8 @@ var ts;
7716
7729
  lbl = "_ldlit_" + ++seq;
7717
7730
  values[v] = lbl;
7718
7731
  }
7719
- line.update(`ldr ${reg}, ${lbl}`);
7732
+ line.ldlitLabel = line.words[3];
7733
+ line.update(`ldr ${reg}, ${lbl} ; ${line.ldlitLabel}`);
7720
7734
  }
7721
7735
  if (line === nextGoodSpot) {
7722
7736
  nextGoodSpot = null;
@@ -7724,6 +7738,7 @@ var ts;
7724
7738
  let jmplbl = "_jmpwords_" + ++seq;
7725
7739
  if (needsJumpOver)
7726
7740
  txtLines.push("bb " + jmplbl);
7741
+ txtLines.push(`.object PUSH`);
7727
7742
  txtLines.push(".balign 4");
7728
7743
  for (let v of Object.keys(values)) {
7729
7744
  let lbl = values[v];
@@ -7731,6 +7746,7 @@ var ts;
7731
7746
  }
7732
7747
  if (needsJumpOver)
7733
7748
  txtLines.push(jmplbl + ":");
7749
+ txtLines.push(`.object POP`);
7734
7750
  for (let t of txtLines) {
7735
7751
  f.buildLine(t, outlines);
7736
7752
  let ll = outlines[outlines.length - 1];
@@ -9025,7 +9041,7 @@ var ts;
9025
9041
  function inspect(n) {
9026
9042
  console.log(stringKind(n));
9027
9043
  }
9028
- // next free error 9283
9044
+ // next free error 9284
9029
9045
  function userError(code, msg, secondary = false) {
9030
9046
  let e = new Error(msg);
9031
9047
  e.ksEmitterUserError = true;
@@ -15195,7 +15211,8 @@ var ts;
15195
15211
  asmLabels[lbl] = true;
15196
15212
  return "";
15197
15213
  });
15198
- let code = ".section code\n" +
15214
+ let code = ".object inlineasm\n" +
15215
+ ".section code\n" +
15199
15216
  "@stackmark func\n" +
15200
15217
  "@scope user" + asmIdx++ + "\n" +
15201
15218
  src + "\n" +
@@ -15728,6 +15745,7 @@ var ts;
15728
15745
  for (let data of Object.keys(bin.doubles)) {
15729
15746
  let lbl = bin.doubles[data];
15730
15747
  bin.otherLiterals.push(`
15748
+ .object ${lbl}
15731
15749
  .balign 4
15732
15750
  ${lbl}: ${snippets.obj_header("pxt::number_vt")}
15733
15751
  .hex ${data}
@@ -15820,6 +15838,7 @@ ${lbl}: ${snippets.obj_header("pxt::number_vt")}
15820
15838
  // ifaceInfo.mult = 0
15821
15839
  let ptrSz = pxtc.target.shortPointers ? ".short" : ".word";
15822
15840
  let s = `
15841
+ .object ${info.id}_VT
15823
15842
  .balign 4
15824
15843
  ${info.id}_VT:
15825
15844
  .short ${info.allfields.length * 4 + 4} ; size in bytes
@@ -15917,14 +15936,18 @@ ${hexfile.hexPrelude()}
15917
15936
  asmsource += hexfile.asmTotalSource; // user-supplied asm
15918
15937
  asmsource += "_code_end:\n\n";
15919
15938
  pxtc.U.iterMap(bin.codeHelpers, (code, lbl) => {
15920
- asmsource += ` .section code\n${lbl}:\n${code}\n`;
15939
+ asmsource +=
15940
+ ` .section code\n` +
15941
+ ` .object _code_helper_${lbl}\n` +
15942
+ `${lbl}:\n` +
15943
+ `${code}\n`;
15921
15944
  });
15922
15945
  asmsource += snippets.arithmetic();
15923
15946
  asmsource += "_helpers_end:\n\n";
15924
15947
  bin.usedClassInfos.forEach(info => {
15925
15948
  asmsource += vtableToAsm(info, opts, bin);
15926
15949
  });
15927
- asmsource += `\n.balign 4\n_pxt_iface_member_names:\n`;
15950
+ asmsource += `\n.balign 4\n.object _pxt_iface_member_names\n_pxt_iface_member_names:\n`;
15928
15951
  asmsource += ` .word ${bin.ifaceMembers.length}\n`;
15929
15952
  let idx = 0;
15930
15953
  for (let d of bin.ifaceMembers) {
@@ -15933,7 +15956,7 @@ ${hexfile.hexPrelude()}
15933
15956
  }
15934
15957
  asmsource += ` .word 0\n`;
15935
15958
  asmsource += "_vtables_end:\n\n";
15936
- asmsource += `\n.balign 4\n_pxt_config_data:\n`;
15959
+ asmsource += `\n.balign 4\n.object _pxt_config_data\n_pxt_config_data:\n`;
15937
15960
  const cfg = bin.res.configData || [];
15938
15961
  // asmsource += ` .word ${cfg.length}, 0 ; num. entries`
15939
15962
  for (let d of cfg) {
@@ -15942,7 +15965,7 @@ ${hexfile.hexPrelude()}
15942
15965
  asmsource += ` .word 0\n\n`;
15943
15966
  emitStrings(snippets, bin);
15944
15967
  asmsource += bin.otherLiterals.join("");
15945
- asmsource += `\n.balign 4\n.section code\n_pxt_perf_counters:\n`;
15968
+ asmsource += `\n.balign 4\n.section code\n.object _perf_counters\n_pxt_perf_counters:\n`;
15946
15969
  asmsource += ` .word ${perfCounters.length}\n`;
15947
15970
  let strs = "";
15948
15971
  for (let i = 0; i < perfCounters.length; ++i) {
@@ -15975,6 +15998,8 @@ ${hexfile.hexPrelude()}
15975
15998
  b.ei.testAssembler(); // just in case
15976
15999
  if (target.switches.noPeepHole)
15977
16000
  b.disablePeepHole = true;
16001
+ if (target.switches.size)
16002
+ b.codeSizeStats = true;
15978
16003
  b.lookupExternalLabel = hexfile.lookupFunctionAddr;
15979
16004
  b.normalizeExternalLabel = s => {
15980
16005
  let inf = hexfile.lookupFunc(s);
@@ -16035,6 +16060,7 @@ ${hexfile.hexPrelude()}
16035
16060
  }
16036
16061
  return `
16037
16062
  .balign 16
16063
+ .object _stored_program
16038
16064
  _stored_program: .hex ${res}
16039
16065
  `;
16040
16066
  }
@@ -18582,7 +18608,7 @@ var ts;
18582
18608
  }
18583
18609
  const type = checker === null || checker === void 0 ? void 0 : checker.getTypeAtLocation(param);
18584
18610
  const typeSymbol = service.getPxtSymbolFromTsSymbol(type === null || type === void 0 ? void 0 : type.symbol, apis, checker);
18585
- if ((typeSymbol === null || typeSymbol === void 0 ? void 0 : typeSymbol.attributes.fixedInstances) && python) {
18611
+ if (((typeSymbol === null || typeSymbol === void 0 ? void 0 : typeSymbol.attributes.fixedInstances) || (typeSymbol === null || typeSymbol === void 0 ? void 0 : typeSymbol.attributes.emitAsConstant)) && python) {
18586
18612
  return pxt.Util.snakify(paramDefl);
18587
18613
  }
18588
18614
  if (python) {
@@ -377,6 +377,7 @@ declare namespace pxt.editor {
377
377
  renderUsbPairDialog?: (firmwareUrl?: string, failedOnce?: boolean) => any;
378
378
  renderIncompatibleHardwareDialog?: (unsupportedParts: string[]) => any;
379
379
  showUploadInstructionsAsync?: (fn: string, url: string, confirmAsync: (options: any) => Promise<number>) => Promise<void>;
380
+ showProgramTooLargeErrorAsync?: (variants: string[], confirmAsync: (options: any) => Promise<number>) => Promise<pxt.commands.RecompileOptions>;
380
381
  toolboxOptions?: IToolboxOptions;
381
382
  blocklyPatch?: (pkgTargetVersion: string, dom: Element) => void;
382
383
  webUsbPairDialogAsync?: (pairAsync: () => Promise<boolean>, confirmAsync: (options: any) => Promise<number>) => Promise<number>;
@@ -1055,7 +1055,8 @@ var pxt;
1055
1055
  onClose: () => this.fv.hide(),
1056
1056
  onSoundChange: (newValue) => this.value = newValue,
1057
1057
  initialSound: this.value,
1058
- useFlex: true
1058
+ useFlex: true,
1059
+ useMixerSynthesizer: pxt.appTarget.id !== "microbit" // FIXME
1059
1060
  };
1060
1061
  }
1061
1062
  }
package/built/pxtlib.d.ts CHANGED
@@ -878,6 +878,10 @@ declare namespace pxt.cloud {
878
878
  };
879
879
  }
880
880
  declare namespace pxt.commands {
881
+ interface RecompileOptions {
882
+ recompile: boolean;
883
+ useVariants: string[];
884
+ }
881
885
  interface DeployOptions {
882
886
  reportError: (e: string) => void;
883
887
  showNotification: (msg: string) => void;
@@ -899,6 +903,7 @@ declare namespace pxt.commands {
899
903
  helpUrl: string;
900
904
  };
901
905
  let showUploadInstructionsAsync: (fn: string, url: string, confirmAsync: (options: any) => Promise<number>, saveonly?: boolean) => Promise<void>;
906
+ let showProgramTooLargeErrorAsync: (variants: string[], confirmAsync: (options: any) => Promise<number>) => Promise<RecompileOptions>;
902
907
  let saveProjectAsync: (project: pxt.cpp.HexFile) => Promise<void>;
903
908
  let electronDeployAsync: (r: ts.pxtc.CompileResult) => Promise<void>;
904
909
  let webUsbPairDialogAsync: (pairAsync: () => Promise<boolean>, confirmAsync: (options: any) => Promise<number>) => Promise<number>;
@@ -2333,6 +2338,7 @@ declare namespace pxt.assets {
2333
2338
  const MAX_VOLUME = 255;
2334
2339
  function renderSoundPath(sound: pxt.assets.Sound, width: number, height: number): string;
2335
2340
  function renderWaveSnapshot(frequency: number, volume: number, wave: SoundWaveForm, width: number, height: number, timeBase: number): string;
2341
+ function soundToInstructionBuffer(sound: Sound, fxSteps: number, fxRange: number): Uint8Array;
2336
2342
  }
2337
2343
  declare namespace pxt.streams {
2338
2344
  interface JsonStreamField {
@@ -3399,6 +3405,7 @@ declare namespace ts.pxtc.assembler {
3399
3405
  opcode: number;
3400
3406
  stack: number;
3401
3407
  isLong: boolean;
3408
+ ldlitLabel: string;
3402
3409
  constructor(bin: File, text: string);
3403
3410
  getOpExt(): string;
3404
3411
  getOp(): string;
@@ -3436,10 +3443,17 @@ declare namespace ts.pxtc.assembler {
3436
3443
  disablePeepHole: boolean;
3437
3444
  stackAtLabel: pxt.Map<number>;
3438
3445
  private prevLabel;
3446
+ codeSizeStats: boolean;
3447
+ private labelToObject;
3448
+ private idToObject;
3449
+ private objSuspendStart;
3450
+ private currObject;
3451
+ private labelsToObjectDone;
3439
3452
  protected emitShort(op: number): void;
3440
3453
  protected emitOpCode(op: number): void;
3441
3454
  location(): number;
3442
3455
  pc(): number;
3456
+ useLabel(name: string): void;
3443
3457
  parseOneInt(s: string): number;
3444
3458
  private looksLikeLabel;
3445
3459
  private scopedName;
@@ -3460,6 +3474,7 @@ declare namespace ts.pxtc.assembler {
3460
3474
  private prepLines;
3461
3475
  private iterLines;
3462
3476
  getSourceMap(): pxt.Map<number[]>;
3477
+ getCodeSizeStats(): string;
3463
3478
  getSource(clean: boolean, numStmts?: number, flashSize?: number): string;
3464
3479
  private peepHole;
3465
3480
  private clearLabels;