|
@@ -10,6 +10,8 @@ import { LanguageDefinedFunction } from './definedFunctions';
|
|
import { resultTypeAfterInfixOp, resultTypeAfterUnaryOp } from './compatibilityTable';
|
|
import { resultTypeAfterInfixOp, resultTypeAfterUnaryOp } from './compatibilityTable';
|
|
import * as Commands from './../ast/commands/';
|
|
import * as Commands from './../ast/commands/';
|
|
import * as Expressions from './../ast/expressions/';
|
|
import * as Expressions from './../ast/expressions/';
|
|
|
|
+import { StoreObjectArrayAddress } from './store/storeObjectArrayAddress';
|
|
|
|
+import { StoreObjectArrayAddressRef } from './store/storeObjectArrayAddressRef';
|
|
|
|
|
|
export class IVProgProcessor {
|
|
export class IVProgProcessor {
|
|
|
|
|
|
@@ -125,7 +127,7 @@ export class IVProgProcessor {
|
|
}
|
|
}
|
|
|
|
|
|
if(formalParameter.byRef) {
|
|
if(formalParameter.byRef) {
|
|
- const ref = new StoreObjectRef(stoObj.id, callerStore);
|
|
|
|
|
|
+ const ref = new StoreObjectArrayAddressRef(stoObj);
|
|
calleeStore.insertStore(formalParameter.id, ref);
|
|
calleeStore.insertStore(formalParameter.id, ref);
|
|
} else {
|
|
} else {
|
|
calleeStore.insertStore(formalParameter.id, stoObj);
|
|
calleeStore.insertStore(formalParameter.id, stoObj);
|
|
@@ -146,7 +148,7 @@ export class IVProgProcessor {
|
|
}
|
|
}
|
|
|
|
|
|
if(formalParameter.byRef) {
|
|
if(formalParameter.byRef) {
|
|
- const ref = new StoreObjectRef(stoObj.id, callerStore);
|
|
|
|
|
|
+ const ref = new StoreObjectArrayAddressRef(stoObj);
|
|
calleeStore.insertStore(formalParameter.id, ref);
|
|
calleeStore.insertStore(formalParameter.id, ref);
|
|
} else {
|
|
} else {
|
|
calleeStore.insertStore(formalParameter.id, stoObj);
|
|
calleeStore.insertStore(formalParameter.id, stoObj);
|
|
@@ -169,7 +171,12 @@ export class IVProgProcessor {
|
|
} else {
|
|
} else {
|
|
|
|
|
|
if(formalParameter.byRef) {
|
|
if(formalParameter.byRef) {
|
|
- const ref = new StoreObjectRef(stoObj.id, callerStore);
|
|
|
|
|
|
+ let ref = null;
|
|
|
|
+ if (stoObj instanceof StoreObjectArrayAddress) {
|
|
|
|
+ ref = new StoreObjectArrayAddressRef(stoObj);
|
|
|
|
+ } else {
|
|
|
|
+ ref = new StoreObjectRef(stoObj.id, callerStore);
|
|
|
|
+ }
|
|
calleeStore.insertStore(formalParameter.id, ref);
|
|
calleeStore.insertStore(formalParameter.id, ref);
|
|
} else {
|
|
} else {
|
|
calleeStore.insertStore(formalParameter.id, stoObj);
|
|
calleeStore.insertStore(formalParameter.id, stoObj);
|
|
@@ -506,13 +513,12 @@ export class IVProgProcessor {
|
|
reject(new Error("Invalid operation. This must be a vector: line "+cmd.sourceInfo.line));
|
|
reject(new Error("Invalid operation. This must be a vector: line "+cmd.sourceInfo.line));
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ newArray.value[line] = value;
|
|
store.updateStore(cmd.id, newArray);
|
|
store.updateStore(cmd.id, newArray);
|
|
}
|
|
}
|
|
resolve(store);
|
|
resolve(store);
|
|
}).catch(err => reject(err));
|
|
}).catch(err => reject(err));
|
|
});
|
|
});
|
|
- const $value = this.evaluateExpression(store, cmd.expression);
|
|
|
|
- return $value.then( vl => store.updateStore(cmd.id, vl));
|
|
|
|
}
|
|
}
|
|
|
|
|
|
executeDeclaration (store, cmd) {
|
|
executeDeclaration (store, cmd) {
|
|
@@ -694,12 +700,7 @@ export class IVProgProcessor {
|
|
// TODO: better error message
|
|
// TODO: better error message
|
|
return Promise.reject(new Error(`${exp.id}: index out of bounds: ${column}`));
|
|
return Promise.reject(new Error(`${exp.id}: index out of bounds: ${column}`));
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (column !== null) {
|
|
|
|
- return Promise.resolve(mustBeArray.value[line].value[column]);
|
|
|
|
- } else {
|
|
|
|
- return Promise.resolve(mustBeArray.value[line]);
|
|
|
|
- }
|
|
|
|
|
|
+ return Promise.resolve(new StoreObjectArrayAddress(mustBeArray.id, line, column, store));
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|