tweaked behavior for undefined result

This commit is contained in:
Sander Hautvast 2021-03-05 18:39:50 +01:00
parent 4499f5d19c
commit 86d0853693
2 changed files with 5 additions and 7 deletions

View file

@ -20,9 +20,6 @@ export const functions = {
show: (args) => {
return show(args[0]);
},
pi: function () {
return Math.PI;
},
sin: function (a) {
return Math.sin(a);
},
@ -100,7 +97,6 @@ const create_vector = function (x0, y0, x, y) { //rename to create_vector
}
export const multiplication = function (left, right) {
const multiply = function (vector, scalar) {
return create_vector(vector.x0 * scalar, vector.y0 * scalar, vector.x * scalar, vector.y * scalar
);

View file

@ -25,7 +25,9 @@ let command_history_index = 0;
const keywords = {
'true': true,
'false': false
'false': false,
'pi': Math.PI,
'PI': Math.PI
}
export const update_visible_objects = function () {
@ -238,7 +240,7 @@ const visit = function (expr) {
}
return value;
} else {
break;
return undefined;
}
}
}
@ -274,7 +276,7 @@ const function_call = function (function_name, argument_exprs) {
if (Object.prototype.hasOwnProperty.apply(functions, [function_name])) {
return functions[function_name](resolve_arguments(argument_exprs));
} else {
return `unimplemented: ${function_name}(${argument_exprs.map(e => e.value_type).join(',')})`;
return `unknown function: ${function_name}(${argument_exprs.map(e => e.value_type).join(',')})`;
}
}