chore: merge develop into rc/v11

This commit is contained in:
Maribeth Bottorff
2024-04-01 14:57:19 -07:00
committed by GitHub
34 changed files with 375 additions and 426 deletions

View File

@@ -35,8 +35,17 @@ export function procedures_defreturn(block: Block, generator: DartGenerator) {
generator.INDENT,
);
}
const branch = generator.statementToCode(block, 'STACK');
let returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
let branch = '';
if (block.getInput('STACK')) {
// The 'procedures_defreturn' block might not have a STACK input.
branch = generator.statementToCode(block, 'STACK');
}
let returnValue = '';
if (block.getInput('RETURN')) {
// The 'procedures_defnoreturn' block (which shares this code)
// does not have a RETURN input.
returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
}
let xfix2 = '';
if (branch && returnValue) {
// After executing the function body, revisit this block for the return.

View File

@@ -118,10 +118,12 @@ export function text_charAt(
return [code, Order.UNARY_POSTFIX];
}
case 'LAST':
at = 1;
// Fall through.
case 'FROM_END': {
at = generator.getAdjusted(block, 'AT', 1);
if (where === 'LAST') {
at = 1;
} else {
at = generator.getAdjusted(block, 'AT', 1);
}
const functionName = generator.provideFunction_(
'text_get_from_end',
`
@@ -130,7 +132,7 @@ String ${generator.FUNCTION_NAME_PLACEHOLDER_}(String text, num x) {
}
`,
);
const code = functionName + '(' + text + ', ' + at + ')';
const code = `${functionName}(${text}, ${at})`;
return [code, Order.UNARY_POSTFIX];
}
case 'RANDOM': {

View File

@@ -318,7 +318,7 @@ function ${generator.FUNCTION_NAME_PLACEHOLDER_}(values) {
}
for (var j = 0; j < counts.length; j++) {
if (counts[j][1] === maxCount) {
modes.push(counts[j][0]);
modes.push(counts[j][0]);
}
}
return modes;
@@ -341,7 +341,7 @@ function ${generator.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
for (var j = 0; j < n; j++) {
variance += Math.pow(numbers[j] - mean, 2);
}
variance = variance / n;
variance /= n;
return Math.sqrt(variance);
}
`,

View File

@@ -38,8 +38,17 @@ export function procedures_defreturn(
generator.INDENT,
);
}
const branch = generator.statementToCode(block, 'STACK');
let returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
let branch = '';
if (block.getInput('STACK')) {
// The 'procedures_defreturn' block might not have a STACK input.
branch = generator.statementToCode(block, 'STACK');
}
let returnValue = '';
if (block.getInput('RETURN')) {
// The 'procedures_defnoreturn' block (which shares this code)
// does not have a RETURN input.
returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
}
let xfix2 = '';
if (branch && returnValue) {
// After executing the function body, revisit this block for the return.

View File

@@ -38,8 +38,17 @@ export function procedures_defreturn(
generator.INDENT,
);
}
let branch = generator.statementToCode(block, 'STACK');
let returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
let branch = '';
if (block.getInput('STACK')) {
// The 'procedures_defreturn' block might not have a STACK input.
branch = generator.statementToCode(block, 'STACK');
}
let returnValue = '';
if (block.getInput('RETURN')) {
// The 'procedures_defnoreturn' block (which shares this code)
// does not have a RETURN input.
returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
}
let xfix2 = '';
if (branch && returnValue) {
// After executing the function body, revisit this block for the return.

View File

@@ -122,8 +122,6 @@ export function text_charAt(
// Get letter at index.
// Note: Until January 2013 this block did not have the WHERE input.
const where = block.getFieldValue('WHERE') || 'FROM_START';
const atOrder = where === 'FROM_END' ? Order.UNARY : Order.NONE;
const at = generator.valueToCode(block, 'AT', atOrder) || '1';
const text = generator.valueToCode(block, 'VALUE', Order.NONE) || "''";
let code;
if (where === 'RANDOM') {
@@ -144,6 +142,8 @@ end
} else if (where === 'LAST') {
start = '-1';
} else {
const atOrder = where === 'FROM_END' ? Order.UNARY : Order.NONE;
const at = generator.valueToCode(block, 'AT', atOrder) || '1';
if (where === 'FROM_START') {
start = at;
} else if (where === 'FROM_END') {

View File

@@ -60,8 +60,17 @@ export function procedures_defreturn(block: Block, generator: PhpGenerator) {
generator.INDENT,
);
}
const branch = generator.statementToCode(block, 'STACK');
let returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
let branch = '';
if (block.getInput('STACK')) {
// The 'procedures_defreturn' block might not have a STACK input.
branch = generator.statementToCode(block, 'STACK');
}
let returnValue = '';
if (block.getInput('RETURN')) {
// The 'procedures_defnoreturn' block (which shares this code)
// does not have a RETURN input.
returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
}
let xfix2 = '';
if (branch && returnValue) {
// After executing the function body, revisit this block for the return.

View File

@@ -60,8 +60,17 @@ export function procedures_defreturn(block: Block, generator: PythonGenerator) {
generator.INDENT,
);
}
let branch = generator.statementToCode(block, 'STACK');
let returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
let branch = '';
if (block.getInput('STACK')) {
// The 'procedures_defreturn' block might not have a STACK input.
branch = generator.statementToCode(block, 'STACK');
}
let returnValue = '';
if (block.getInput('RETURN')) {
// The 'procedures_defnoreturn' block (which shares this code)
// does not have a RETURN input.
returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
}
let xfix2 = '';
if (branch && returnValue) {
// After executing the function body, revisit this block for the return.