Changeset 27630

Show
Ignore:
Timestamp:
12/30/08 22:57:49 (4 years ago)
Author:
fujidig
Message:

mainLoop の生成で eval を使わず Function コンストラクタを使うように

Location:
lang/javascript/hsp-on-js/trunk/src
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/hsp-on-js/trunk/src/evaluator.js

    r27520 r27630  
    5252Evaluator.prototype = { 
    5353        evaluate: function evaluate() { 
    54                 this.mainLoop = eval('Object(function mainLoop(stack, literals, variables, userDefFuncs) {\n' + 
    55                                 this.createMainLoop(this.literals, this.userDefFuncs) + '\n})'); 
     54                this.mainLoop = this.createMainLoop(); 
    5655                try { 
    5756                        this.mainLoop(this.stack, this.literals, this.variables, this.userDefFuncs); 
     
    130129        onStop: function onStop() { 
    131130        }, 
    132         createMainLoop: function createMainLoop(literals, userDefFuncs) { 
     131        createMainLoop: function createMainLoop() { 
     132                var src = ''; 
     133                for(var prop in HSPonJS) { 
     134                        src += 'var '+prop+' = HSPonJS.'+prop+';\n'; 
     135                } 
     136                src += 'return function mainLoop(stack, literals, variables, userDefFuncs) {\n'; 
     137                src += this.createMainLoopSrc(this.literals, this.userDefFuncs) + '\n};'; 
     138                return Function(src)(); 
     139        }, 
     140        createMainLoopSrc: function createMainLoopSrc(literals, userDefFuncs) { 
    133141                function push(line) { 
    134142                        lines.push(Utils.strTimes('\t', indent) + line); 
  • lang/javascript/hsp-on-js/trunk/src/run-in-shell

    r27513 r27630  
    4040else 
    4141  filenames = %w[ 
     42    head-for-run-in-shell.js 
    4243    binary-parser.js 
    4344    cp932.js