瀏覽代碼

Finalize Language Defined Functions refactor.

Lucas de Souza 6 年之前
父節點
當前提交
8bfe38eddf
共有 3 個文件被更改,包括 4 次插入11 次删除
  1. 2 2
      js/ast/commands/sysCall.js
  2. 0 4
      js/ast/ivprogParser.js
  3. 2 5
      js/processor/ivprogProcessor.js

+ 2 - 2
js/ast/commands/sysCall.js

@@ -6,7 +6,7 @@
  */
 export class SysCall {
 
-  constructor (id) {
-    this.id = id;
+  constructor (langFunc) {
+    this.langFunc = langFunc;
   }
 }

+ 0 - 4
js/ast/ivprogParser.js

@@ -982,10 +982,6 @@ export class IVProgParser {
 
   getFunctionName (id) {
     const name = LanguageDefinedFunction.getInternalName(id);
-    console.log('###');
-    console.log(id);
-    console.log(name);
-    console.log('###');
     if (name === null) {
       return id;
     } else {

+ 2 - 5
js/processor/ivprogProcessor.js

@@ -232,11 +232,8 @@ export class IVProgProcessor {
   }
 
   executeSysCall (store, cmd) {
-    if (typeof cmd.id === 'function') {
-      return cmd.id.bind(this)(store, cmd);
-    } else {
-      throw new Error("invalid internal function impl.");
-    }
+    const func = cmd.langFunc.bind(this);
+    return func(store, cmd);
   }
 
   executeFunctionCall (store, cmd) {