Setting values in Arrays works now

This commit is contained in:
Daniel Xie
2017-06-11 01:52:52 -05:00
parent f7bf83e4d9
commit f983d5521b
3 changed files with 82 additions and 19 deletions
-3
View File
@@ -40,18 +40,15 @@ function evaluate(exp, workerScript) {
}
try {
var res = env.get(exp.value);
console.log(res);
if (exp.index) {
//If theres an index field, then this variable is supposed to be an array
//and the user needs to be indexing it
if (res.constructor === Array || res instanceof Array) {
//Do array stuff here
var iPromise = evaluate(exp.index.value, workerScript);
iPromise.then(function(i) {
if (i >= res.length || i < 0) {
return reject(makeRuntimeRejectMsg(workerScript, "Out of bounds: Invalid index in [] operator"));
} else {
//Evaluate here
return evaluate(res[i], workerScript);
}
}).then(function(res) {