js+ir: check whether thread status after running addon block

Fixes "breakpoint" block working unreliably
This commit is contained in:
Thomas Weber committed 2021-07-08 17:35:50 -05:00
1 parent 0a4d3a563f
commit c8ed32b8d2
3 files changed
+7 -2

No files matched your search

+1
View File
@@ -1120,6 +1120,7 @@ class ScriptTreeGenerator {
const addonBlock = this.runtime.getAddonBlock(procedureCode);
if (addonBlock) {
this.script.yields = true;
const args = {};
for (let i = 0; i < paramIds.length; i++) {
let value;
+4 -1
View File
@@ -203,7 +203,7 @@ const executeInCompatibilityLayer = function*(inputs, blockFunction, useFlags) {
* @param {string} blockId The ID of the block being run
* @param {object} args The arguments to pass to the block
*/
const callAddonBlock = (procedureCode, blockId, args) => {
const callAddonBlock = function*(procedureCode, blockId, args) {
const addonBlock = thread.target.runtime.getAddonBlock(procedureCode);
if (addonBlock) {
const target = thread.target;
@@ -214,6 +214,9 @@ const callAddonBlock = (procedureCode, blockId, args) => {
},
target
});
if (thread.status === Thread.STATUS_PROMISE_WAIT) {
yield;
}
}
};
+2 -1
View File
@@ -658,7 +658,8 @@ class JSGenerator {
descendStackedBlock (node) {
switch (node.kind) {
case 'addons.call':
this.source += `callAddonBlock("${sanitize(node.code)}","${sanitize(node.blockId)}",{`;
this.source += `yield* callAddonBlock("${sanitize(node.code)}","${sanitize(node.blockId)}",{`;
this.yielded();
for (const argumentName of Object.keys(node.arguments)) {
const argumentValue = node.arguments[argumentName];
this.source += `"${sanitize(argumentName)}":${this.descendInput(argumentValue).asSafe()},`;