RAPL

Check-in [c31adfa6e2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixes found in porting to java version
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c31adfa6e2894993db5980f390dc26649e3c6973
User & Date: arnulf 2012-03-27 15:05:34
Context
2012-03-31
22:48
fixes check-in: 143896aeaa user: arnulf tags: trunk
2012-03-27
15:05
fixes found in porting to java version check-in: c31adfa6e2 user: arnulf tags: trunk
2012-03-16
20:25
removed duplicate or unused code check-in: 3b95b2396a user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to rapl_array_obj_type.js.

158
159
160
161
162
163
164

165
166
167
168
169
170
171
172
173
174
175
  arrayGet: function(obj_ptr, flags, result_var_ptr) {
    var array_obj = this;
    var subst_key_obj_ptr = new Array();
    var retcode;
    var create_part1 = 0;
    var err_msg_ptr = new Array();
    var index_ptr = new Array();


    array_obj.setFromAny(obj_ptr);
    if (array_obj.interp.script_obj_type.substObj(obj_ptr.arrayValue.indexObjPtr(), subst_key_obj_ptr, array_obj.FUNCTION_FLAGS_NONE) != array_obj.OK) {
      return null;
    }
    subst_key_obj_ptr = subst_key_obj_ptr[0]
    subst_key_obj_ptr.incrRefCount("I_ARRAY_OBJ_TYPE_5");
    var_ptr = array_obj.interp.variable_obj_type.lookupSimpleVar(obj_ptr.arrayValue.varNameObjPtr(), 0, create_part1, err_msg_ptr, index_ptr);
    if (var_ptr != null) {
      array_obj.interp.variable_obj_type.handleVariableTrace(obj_ptr.arrayValue.varNameObjPtr(), subst_key_obj_ptr, array_obj.TRACE_OP_READ, "read", var_ptr);
    }







>



|







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
  arrayGet: function(obj_ptr, flags, result_var_ptr) {
    var array_obj = this;
    var subst_key_obj_ptr = new Array();
    var retcode;
    var create_part1 = 0;
    var err_msg_ptr = new Array();
    var index_ptr = new Array();
    var var_ptr;

    array_obj.setFromAny(obj_ptr);
    if (array_obj.interp.script_obj_type.substObj(obj_ptr.arrayValue.indexObjPtr(), subst_key_obj_ptr, array_obj.FUNCTION_FLAGS_NONE) != array_obj.OK) {
      return array_obj.ERROR;
    }
    subst_key_obj_ptr = subst_key_obj_ptr[0]
    subst_key_obj_ptr.incrRefCount("I_ARRAY_OBJ_TYPE_5");
    var_ptr = array_obj.interp.variable_obj_type.lookupSimpleVar(obj_ptr.arrayValue.varNameObjPtr(), 0, create_part1, err_msg_ptr, index_ptr);
    if (var_ptr != null) {
      array_obj.interp.variable_obj_type.handleVariableTrace(obj_ptr.arrayValue.varNameObjPtr(), subst_key_obj_ptr, array_obj.TRACE_OP_READ, "read", var_ptr);
    }

Changes to rapl_base.js.

1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
        if (read_fcn != null) {
//print("source rhino2!"+url+"!"+interp.current_namespace.full_name+"!");
          result = "";
          responseText = read_fcn(url);
//print("source!"+url+"!"+responseText+"!");
//print("responseText!"+responseText+"!");
          script = interp.string_obj_type.newStringObj("::set dir "+interp.current_dir+"\n"+responseText, -1, "BASE_2");
//print("SOURCE!"+script.len+"!"+url+"!"+script.toDebugString()+"!");
          try {
            result = interp.eval_statement.evalObj(script);
          } catch(e) {
print("SOURCE1!e!"+e+"!"+script.getString()+"!");
          }
//print("SOURCE END1!"+result+"!");
          return result;







|







1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
        if (read_fcn != null) {
//print("source rhino2!"+url+"!"+interp.current_namespace.full_name+"!");
          result = "";
          responseText = read_fcn(url);
//print("source!"+url+"!"+responseText+"!");
//print("responseText!"+responseText+"!");
          script = interp.string_obj_type.newStringObj("::set dir "+interp.current_dir+"\n"+responseText, -1, "BASE_2");
//print("SOURCE!"+script.script_object.len+"!"+url+"!"+script.toDebugString()+"!");
          try {
            result = interp.eval_statement.evalObj(script);
          } catch(e) {
print("SOURCE1!e!"+e+"!"+script.getString()+"!");
          }
//print("SOURCE END1!"+result+"!");
          return result;

Changes to rapl_callframe.js.

106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
    var call_frame = this;
//print("newCallFrame!"+call_frame.toDebugString()+"!");
    var my_call_frame;
    /* -- Check if there are call_frames in the free list -- */
    if (call_frame.interp.free_call_frame_list != null) {
      /* -- Unlink the call_frame from the free list -- */
      my_call_frame = call_frame.interp.free_call_frame_list;
      call_frame.interp.free_call_frame_list = my_call_frame.next_ptr;
    } else {
      /* -- No ready to use objects: allocate a new one -- */
      my_call_frame = new R.CallFrame(call_frame.interp, type);
    }
    /* call_frame is returned with ref_count of 0. Every
     * kind of GC implemented should take care to don't try
     * to scan call_frames with ref_count == 0. */
................................................................................
    if (type == call_frame.CALL_TYPE_PROC) {
      my_call_frame.is_proc_call_frame = true;
    }
    my_call_frame.ns_ptr = null;
    my_call_frame.variables = new Object();
    my_call_frame.command_resolver = null;
    my_call_frame.variable_resolver = null;
    my_call_frame.ns_ptr = call_frame.interp.frame_ptr;
    my_call_frame.static_vars = null;
    my_call_frame.file_name_obj = null;
    my_call_frame.line = -1;
    my_call_frame.proc_args_obj_ptr = null;
    my_call_frame.proc_body_obj_ptr = null;
    if (call_frame.interp.frame_ptr != null) {
      my_call_frame.class_object = call_frame.interp.frame_ptr.class_object;
................................................................................
    my_call_frame.top_command_oid = R.Base.command_oid;
    my_call_frame.top_itcl_command_oid = R.Base.itcl_command_oid;
    my_call_frame.top_class_function_oid = R.Base.class_function_oid;

    /* -- Put the object into the live list -- */
    my_call_frame.prev_call_frame_ptr = null;
    my_call_frame.next_call_frame_ptr = call_frame.interp.live_call_frame_list;
    if (call_frame.interp.live_call_frame_ptr != null) {
      call_frame.interp.live_call_frame_list.prev_call_frame_ptr = my_call_frame;
    }
    call_frame.interp.live_call_frame_list = my_call_frame;
    return my_call_frame
  },

  /* ==================== freeCallFrame ===================================== */







|







 







|







 







|







106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
    var call_frame = this;
//print("newCallFrame!"+call_frame.toDebugString()+"!");
    var my_call_frame;
    /* -- Check if there are call_frames in the free list -- */
    if (call_frame.interp.free_call_frame_list != null) {
      /* -- Unlink the call_frame from the free list -- */
      my_call_frame = call_frame.interp.free_call_frame_list;
      call_frame.interp.free_call_frame_list = my_call_frame.next_call_frame_ptr;
    } else {
      /* -- No ready to use objects: allocate a new one -- */
      my_call_frame = new R.CallFrame(call_frame.interp, type);
    }
    /* call_frame is returned with ref_count of 0. Every
     * kind of GC implemented should take care to don't try
     * to scan call_frames with ref_count == 0. */
................................................................................
    if (type == call_frame.CALL_TYPE_PROC) {
      my_call_frame.is_proc_call_frame = true;
    }
    my_call_frame.ns_ptr = null;
    my_call_frame.variables = new Object();
    my_call_frame.command_resolver = null;
    my_call_frame.variable_resolver = null;
    my_call_frame.ns_ptr = call_frame.interp.frame_ptr_ns_ptr;
    my_call_frame.static_vars = null;
    my_call_frame.file_name_obj = null;
    my_call_frame.line = -1;
    my_call_frame.proc_args_obj_ptr = null;
    my_call_frame.proc_body_obj_ptr = null;
    if (call_frame.interp.frame_ptr != null) {
      my_call_frame.class_object = call_frame.interp.frame_ptr.class_object;
................................................................................
    my_call_frame.top_command_oid = R.Base.command_oid;
    my_call_frame.top_itcl_command_oid = R.Base.itcl_command_oid;
    my_call_frame.top_class_function_oid = R.Base.class_function_oid;

    /* -- Put the object into the live list -- */
    my_call_frame.prev_call_frame_ptr = null;
    my_call_frame.next_call_frame_ptr = call_frame.interp.live_call_frame_list;
    if (call_frame.interp.live_call_frame_list != null) {
      call_frame.interp.live_call_frame_list.prev_call_frame_ptr = my_call_frame;
    }
    call_frame.interp.live_call_frame_list = my_call_frame;
    return my_call_frame
  },

  /* ==================== freeCallFrame ===================================== */

Changes to rapl_command.js.

197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
        }
      }
    }
//print("CMD4!");
    return r;
  },

  /* ==================== requireExactArgc ===================================== */
  old_requireExactArgc: function (args, argc, name, msg) {
    if (args.length != argc) {
      throw "wrong # of args: "+name+" "+argc+" arguments expected, got "+args.length+" "+args+"!";
    }
  },

  /* ==================== requireMinArgc ===================================== */
  old_requireMinArgc: function (args, argc, name, msg) {
    if (args.length < argc) {
      throw "wrong # of args: "+name+" "+argc+" arguments expected at least, got "+args.length+" "+args+"!";
    }
  },

  /* ==================== requireArgcRange ===================================== */
  old_requireArgcRange: function (args, min, max, name, msg) {
    if (args.length < min || args.length > max) {
      throw "wrong # of args: "+name+" "+min+" to "+max+" arguments expected, got "+args.length+" "+args+"!";
    }
  },

  /* ==================== addCommandTrace ===================================== */
  addCommandTrace: function(trace_obj) {
    if (trace_obj != null) {
      this.command_traces.push(trace_obj);
    }
  },








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







197
198
199
200
201
202
203





















204
205
206
207
208
209
210
        }
      }
    }
//print("CMD4!");
    return r;
  },






















  /* ==================== addCommandTrace ===================================== */
  addCommandTrace: function(trace_obj) {
    if (trace_obj != null) {
      this.command_traces.push(trace_obj);
    }
  },

Changes to rapl_eval_statement.js.

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
...
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
...
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
...
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
...
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
...
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
	}
      } else {
        if (stmt.had_macro_cmd) {
          obj_ptr = stmt.interp.string_obj_type.newStringObj("$"+token.obj_ptr.getString(), -1, "EVAL_STATEMENT_4");
	}
      }
      break;
    case stmt.TOKEN_ARRAY_NAME_VAR:
      obj_ptr = JimExpandDictSugar(stmt.interp, token.obj_ptr);
      break;
    case stmt.TOKEN_EXPRSUGAR:
      obj_ptr = stmt.interp.expr_obj_type.expandExprSugar(token.obj_ptr);
      break;
    case stmt.TOKEN_BRACE:
      if (!stmt.in_quotes) {
        obj_ptr = token.obj_ptr;
      } else {
................................................................................
        intv2[j].incrRefCount("I_EVAL_STATEMENT_2");
      }
      switch(retcode) {
      case stmt.OK:
      case stmt.RETURN:
        break;
      case stmt.BREAK:
        if (flags & stmt.SUBST_FLAG) {
          /* Stop here */
          tokens = i;
          continue;
        }
        /* XXX: Should probably set an error about break outside loop */
        /* fall through to error */
      case stmt.CONTINUE:
        if (flags & stmt.SUBST_FLAG) {
          intv2[i] = null;
................................................................................
      obj_ptr.obj_type = obj_ptr.interpolatedObjType;
      obj_ptr.twoPtrValue.ptr1(token);
      obj_ptr.twoPtrValue.ptr2(intv2[idx + 2]);
      intv2[idx + 2].incrRefCount("I_EVAL_STATEMENT_3");
    }

    obj_ptr.bytes = "";
    obj_ptr.length = total_len;
    for (i = 0; i < j; i++) {
      if (intv2[i]) {
        obj_ptr.bytes += intv2[i].toString();
        intv2[i].decrRefCount("D_EVAL_STATEMENT_3");
      }
    }
//    obj_ptr.bytes[total_len] = '\0';
................................................................................
    script_obj_ptr.interp.setEmptyResult();

    /* Check for one of the following common scripts used by for, while
     *
     *   {}
     *   incr a
     */
    if (script.len == 0) {
      script_obj_ptr.decrRefCount("D_EVAL_STATEMENT_4");
      if (stmt.macro_cmd_level == stmt.eval_level) {
        stmt.had_macro_cmd = false;
      }
      stmt.eval_level--;
      return stmt.OK;
    }
    if (script.len == 3
        && script.script_object.tokens[1].obj_ptr.obj_type.type_name == "command"
        && script.script_object.tokens[1].obj_ptr.cmdValue.cmdPtr().is_proc == false
        && script.script_object.tokens[1].obj_ptr.cmdValue.cmdPtr().u.native_fcn.cmd_proc == script.interp.incrCoreCommand
        && script.script_object.tokens[2].obj_ptr.obj_typ.type_name == "variable") {

      var obj_ptr = stmt.interp.getVariable(script.script_object.tokens[2].obj_ptr, stmt.TOKENNONE);

      if (obj_ptr && !obj_ptr.isShared() && obj_ptrobj_type.name == "int") {
//        JimWideValue(obj_ptr)++;
        obj_ptr.invalidateStringRep();
        script_obj_ptr.decrRefCount("D_EVAL_STATEMENT_5");
        stmt.interp.setResult(obj_ptr);
        if (stmt.macro_cmd_level == stmt.eval_level) {
................................................................................
     * Think for example to this:
     *
     * set x {llength $x; ... some more code ...}; eval $x
     *
     * In order to preserve the internal rep, we increment the
     * inUse field of the script internal rep structure. 
     */
    script.ref_count++;
    token = script.script_object.tokens;
    /* Execute every command sequentially until the end of the script
     * or an error occurs.
     */
    for (i = 0; i < script.len && retcode == stmt.OK; ) {
      var argc;
      var argv = new Array();
      var j;
      var cmd;
      var num_comments = 0;

      /* First token of the line is always TOKEN_LINE */
................................................................................
            /* special case for ::itcl::type type variable !! */
            if (word_obj_ptr == null && result_var_ptr != null && token[i].obj_ptr.getString() == "type") {
              word_obj_ptr = stmt.interp.string_obj_type.newStringObj(result_var_ptr.namespace.full_name, -1, "EVAL_STATEMENT_7");
              word_obj_ptr.incrRefCount("I_EVAL_STATEMENT_5");
            }
            break;
          case stmt.TOKEN_EXPRSUGAR:
            word_obj_ptr = stmt.expandExprSugar(token[i].obj_ptr);
            break;
          case stmt.TOKEN_ARRAY_NAME_VAR:
            word_obj_ptr = stmt.expandDictSugar(token[i].obj_ptr);
            break;
          case stmt.TOKEN_BRACE:
            if (!stmt.in_quotes) {
              word_obj_ptr = token[i].obj_ptr;
	    } else {
              var result_ptr = new Array();
              retcode = stmt.interp.script_obj_type.substObj(token[i].obj_ptr, result_ptr, stmt.FUNCTION_FLAGS_LEAVE_ERR_MSG);
................................................................................
        stmt.interp.add_stack_trace++;
    }

    /* Now if this is an "interesting" level, add it to the stack trace */
    if (rc == stmt.ERROR && stmt.interp.add_stack_trace > 0) {
        /* Add the stack info for the current level */

        stmt.appendStackTrace(file_name_obj.getString(stmt.interp.error_proc), file_name_obj, line);

        /* Note: if we didn't have a filename for this level,
         * don't clear the addStackTrace flag
         * so we can pick it up at the next level
         */
        if (file_name_obj.getStringLength()) {
          stmt.interp.add_stack_trace = 0;







<
<
<







 







|

|







 







|







 







|







|





|







 







|




|







 







|
<
<
<







 







|







109
110
111
112
113
114
115



116
117
118
119
120
121
122
...
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
...
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
...
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
...
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
...
454
455
456
457
458
459
460
461



462
463
464
465
466
467
468
...
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
	}
      } else {
        if (stmt.had_macro_cmd) {
          obj_ptr = stmt.interp.string_obj_type.newStringObj("$"+token.obj_ptr.getString(), -1, "EVAL_STATEMENT_4");
	}
      }
      break;



    case stmt.TOKEN_EXPRSUGAR:
      obj_ptr = stmt.interp.expr_obj_type.expandExprSugar(token.obj_ptr);
      break;
    case stmt.TOKEN_BRACE:
      if (!stmt.in_quotes) {
        obj_ptr = token.obj_ptr;
      } else {
................................................................................
        intv2[j].incrRefCount("I_EVAL_STATEMENT_2");
      }
      switch(retcode) {
      case stmt.OK:
      case stmt.RETURN:
        break;
      case stmt.BREAK:
        if (flags & stmt.FUNCTION_FLAGS_SUBST_FLAG) {
          /* Stop here */
          word_tokens = i;
          continue;
        }
        /* XXX: Should probably set an error about break outside loop */
        /* fall through to error */
      case stmt.CONTINUE:
        if (flags & stmt.SUBST_FLAG) {
          intv2[i] = null;
................................................................................
      obj_ptr.obj_type = obj_ptr.interpolatedObjType;
      obj_ptr.twoPtrValue.ptr1(token);
      obj_ptr.twoPtrValue.ptr2(intv2[idx + 2]);
      intv2[idx + 2].incrRefCount("I_EVAL_STATEMENT_3");
    }

    obj_ptr.bytes = "";
    obj_ptr.len = total_len;
    for (i = 0; i < j; i++) {
      if (intv2[i]) {
        obj_ptr.bytes += intv2[i].toString();
        intv2[i].decrRefCount("D_EVAL_STATEMENT_3");
      }
    }
//    obj_ptr.bytes[total_len] = '\0';
................................................................................
    script_obj_ptr.interp.setEmptyResult();

    /* Check for one of the following common scripts used by for, while
     *
     *   {}
     *   incr a
     */
    if (script.script_object.len == 0) {
      script_obj_ptr.decrRefCount("D_EVAL_STATEMENT_4");
      if (stmt.macro_cmd_level == stmt.eval_level) {
        stmt.had_macro_cmd = false;
      }
      stmt.eval_level--;
      return stmt.OK;
    }
    if (script.script_object.len == 3
        && script.script_object.tokens[1].obj_ptr.obj_type.type_name == "command"
        && script.script_object.tokens[1].obj_ptr.cmdValue.cmdPtr().is_proc == false
        && script.script_object.tokens[1].obj_ptr.cmdValue.cmdPtr().u.native_fcn.cmd_proc == script.interp.incrCoreCommand
        && script.script_object.tokens[2].obj_ptr.obj_typ.type_name == "variable") {

      var obj_ptr = stmt.interp.getVariable(script.script_object.tokens[2].obj_ptr, stmt.TOKEN_NONE);

      if (obj_ptr && !obj_ptr.isShared() && obj_ptrobj_type.name == "int") {
//        JimWideValue(obj_ptr)++;
        obj_ptr.invalidateStringRep();
        script_obj_ptr.decrRefCount("D_EVAL_STATEMENT_5");
        stmt.interp.setResult(obj_ptr);
        if (stmt.macro_cmd_level == stmt.eval_level) {
................................................................................
     * Think for example to this:
     *
     * set x {llength $x; ... some more code ...}; eval $x
     *
     * In order to preserve the internal rep, we increment the
     * inUse field of the script internal rep structure. 
     */
    script.script_object.ref_count++;
    token = script.script_object.tokens;
    /* Execute every command sequentially until the end of the script
     * or an error occurs.
     */
    for (i = 0; i < script.script_object.len && retcode == stmt.OK; ) {
      var argc;
      var argv = new Array();
      var j;
      var cmd;
      var num_comments = 0;

      /* First token of the line is always TOKEN_LINE */
................................................................................
            /* special case for ::itcl::type type variable !! */
            if (word_obj_ptr == null && result_var_ptr != null && token[i].obj_ptr.getString() == "type") {
              word_obj_ptr = stmt.interp.string_obj_type.newStringObj(result_var_ptr.namespace.full_name, -1, "EVAL_STATEMENT_7");
              word_obj_ptr.incrRefCount("I_EVAL_STATEMENT_5");
            }
            break;
          case stmt.TOKEN_EXPRSUGAR:
            word_obj_ptr = stmt.interp.expandExprSugar(token[i].obj_ptr);



            break;
          case stmt.TOKEN_BRACE:
            if (!stmt.in_quotes) {
              word_obj_ptr = token[i].obj_ptr;
	    } else {
              var result_ptr = new Array();
              retcode = stmt.interp.script_obj_type.substObj(token[i].obj_ptr, result_ptr, stmt.FUNCTION_FLAGS_LEAVE_ERR_MSG);
................................................................................
        stmt.interp.add_stack_trace++;
    }

    /* Now if this is an "interesting" level, add it to the stack trace */
    if (rc == stmt.ERROR && stmt.interp.add_stack_trace > 0) {
        /* Add the stack info for the current level */

        stmt.appendStackTrace(stmt.interp.error_proc.getString(), file_name_obj, line);

        /* Note: if we didn't have a filename for this level,
         * don't clear the addStackTrace flag
         * so we can pick it up at the next level
         */
        if (file_name_obj.getStringLength()) {
          stmt.interp.add_stack_trace = 0;

Changes to rapl_int_obj_type.js.

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
  /* ==================== wideValue ================================== */
  wideValue: function(obj_ptr) {
    var int_obj = this;

    return obj_ptr.wideValue();
  },

  /* ==================== getLong ===================================== */
  getLong: function (long_ptr) {
    var int_obj = this;
    var wide_value = new Array();
    var retval;

    retval = int_obj.getWide(wide_value);
    if (retval == int_obj.OK) {
      long_ptr[0] = wide_value;
      return int_obj.OK;
    }
    return int_obj.ERROR;
  },

  /* ==================== getWide ================================== */
  getWide: function(obj_ptr, wide_ptr) {
    var int_obj = this;

    if (obj_ptr.obj_type != int_obj.int_obj_type && int_obj.setFromAny(obj_ptr, int_obj.FUNCTION_FLAGS_LEAVE__ERR_MSG) == int_obj.ERROR) {
      return int_obj.ERROR;
    }
    wide_ptr[0] = int_obj.wideValue(obj_ptr);
    return int_obj.OK;
  },

  /* ==================== getWideNoErr ================================== */







<
<
<
<
<
<
<
<
<
<
<
<
<
<




|







109
110
111
112
113
114
115














116
117
118
119
120
121
122
123
124
125
126
127
  /* ==================== wideValue ================================== */
  wideValue: function(obj_ptr) {
    var int_obj = this;

    return obj_ptr.wideValue();
  },















  /* ==================== getWide ================================== */
  getWide: function(obj_ptr, wide_ptr) {
    var int_obj = this;

    if (obj_ptr.obj_type != int_obj.int_obj_type && int_obj.setFromAny(obj_ptr, int_obj.FUNCTION_FLAGS_LEAVE_ERR_MSG) == int_obj.ERROR) {
      return int_obj.ERROR;
    }
    wide_ptr[0] = int_obj.wideValue(obj_ptr);
    return int_obj.OK;
  },

  /* ==================== getWideNoErr ================================== */

Changes to rapl_interp.js.

860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
    }
    intp.setResultFormatted("bad level \"%s\"", str);
    return null;
  },

  /* ==================== nameIsArrayName ===================================== */
  nameIsArrayName: function(str, len) {
    if (len && str.charAt([len - 1]) == ')' && str.match('.*[(].*')) {
      return true;
    }
    return false;
  },

  /* ==================== getArrayNameParts ===================================== */
  getArrayNameParts: function(str, len) {







|







860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
    }
    intp.setResultFormatted("bad level \"%s\"", str);
    return null;
  },

  /* ==================== nameIsArrayName ===================================== */
  nameIsArrayName: function(str, len) {
    if (len && str.charAt(len - 1) == ')' && str.match('.*[(].*')) {
      return true;
    }
    return false;
  },

  /* ==================== getArrayNameParts ===================================== */
  getArrayNameParts: function(str, len) {

Changes to rapl_namespace.js.

35
36
37
38
39
40
41

42
43
44
45
46
47
48
...
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
...
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
...
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
...
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
...
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
  namesp.variable_debug = 0;
  namesp.interp = interp;
  namesp.name = ns_name;
  namesp.full_name = "";
  namesp.flags = 0;
  namesp.activation_count = 0;
  namesp.command_path_length = 0;

  namesp.ref_count = 0;
  namesp.class_command = null;
  namesp.class_type = namesp.NAMESPACE;
  namesp.parent_namespace = null;  // null means :: global namespace
  namesp.privdata = privdata;
  namesp.children = new Array();
  namesp.class_functions = new Object();
................................................................................
	  }
        }
      }
      /*
       * Next, check along the path.
       */
      for (i = 0 ; i < cxt_ns_ptr.command_path_length && cmd_ptr == null; i++) {
        path_ns_ptr = cxt_ns_ptr.command_path_array[i].ns_ptr;
        if (path_ns_ptr == null) {
	  continue;
        }
        path_ns_ptr = new Array();
        real_ns_ptr = new Array();
        dummy_ns_ptr1 = new Array();
        dummy_ns_ptr2 = new Array();
................................................................................
        commands = namesp.getCommandsFromType(ns_ptr1);
        if (typeof commands[simple_name] != "undefined") {
          cmd_ptr = commands[simple_name];
        } else {
          switch (ns_ptr1.class_type) {
          case namesp.ITCL_TYPE_CLASS:
          case namesp.ITCL_EXTENDED_CLASS:
          case namesp.ITCL_WIDGET:
          case namesp.ITCL_WIDGETADAPTOR:
            /* that is for components installed within a class namespace */
            /* FIXME maybe this should only be a class method instead of a cmd_proc!! */
            if (typeof ns_ptr1.cmd_procs[simple_name] != "undefined") {
              cmd_ptr = ns_ptr1.cmd_procs[simple_name];
	    } else {
              /* that is itcl::type lookup in parent namespace too up to but not including root namespace */
              if (ns_ptr1.parent_namespace != null) {
................................................................................
      part1 = parts[0];
      part2 = parts[1];
    } else {
      part1 = my_name;
    }
    if (part1 == "this") {
      if ((namesp.class_type == namesp.ITCL_CLASS) || (namesp.class_type == namesp.ITCL_EXTENDED_CLASS)) {
        var class_obj_name = interp.eval_statement.getCallframeClassObject();
	var class_ptr = new Array();
	if (interp.getClassObject(class_obj_name, class_ptr) != interp.OK) {
          return NULL;
	}
        var var_obj = class_ptr[0].getThisVariable();
	return var_obj;
      }
................................................................................
    }
    if (part1 == "self") {
      switch (namesp.class_type) {
      case namesp.ITCL_TYPE_CLASS:
      case namesp.ITCL_EXTENDED_CLASS:
      case namesp.ITCL_WIDGET_CLASS:
      case namesp.ITCL_WIDGETADAPTOR_CLASS:
        var class_obj_name = interp.eval_statement.getCallframeClassObject();
	var class_ptr = new Array();
	if (interp.getClassObject(class_obj_name, class_ptr) != interp.OK) {
          return NULL;
	}
        var var_obj = class_ptr[0].getSelfVariable();
	return var_obj;
      }
    }
    if (part1 == "win") {
      switch (namesp.class_type) {
      case namesp.ITCL_CLASS:
      case namesp.ITCL_EXTENDED_CLASS:
        var class_obj_name = interp.eval_statement.getCallframeClassObject();
	var class_ptr = new Array();
	if (interp.getClassObject(class_obj_name, class_ptr) != interp.OK) {
          return NULL;
	}
        var var_obj = class_ptr[0].getThisVariable();
	return var_obj;
      }
................................................................................
    } else {
      if (namesp.index > -3) {
        /* A cacheable namespace or global variable. */
      } else {
      }
    }
    while (my_var_obj.link != null) {
      my_var_obj = var_obj.link;
    }
    if (part2 != null) {
      /* Array element sought: look it up. */
      /* not necessary getValue does the job */
    }
if (namesp.variable_debug) {
print("lookupVariableEx END!"+name+"!flags!"+flags+"!msg!"+msg+"!crp1!"+create_part1+"!crp2!"+create_part2+"!var_obj!"+my_var_obj+"!");







>







 







|







 







|
|







 







|







 







|












|







 







|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
...
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
...
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
...
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
...
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
  namesp.variable_debug = 0;
  namesp.interp = interp;
  namesp.name = ns_name;
  namesp.full_name = "";
  namesp.flags = 0;
  namesp.activation_count = 0;
  namesp.command_path_length = 0;
  namesp.command_path_array = new Array();
  namesp.ref_count = 0;
  namesp.class_command = null;
  namesp.class_type = namesp.NAMESPACE;
  namesp.parent_namespace = null;  // null means :: global namespace
  namesp.privdata = privdata;
  namesp.children = new Array();
  namesp.class_functions = new Object();
................................................................................
	  }
        }
      }
      /*
       * Next, check along the path.
       */
      for (i = 0 ; i < cxt_ns_ptr.command_path_length && cmd_ptr == null; i++) {
        path_ns_ptr = cxt_ns_ptr.command_path_array[i];
        if (path_ns_ptr == null) {
	  continue;
        }
        path_ns_ptr = new Array();
        real_ns_ptr = new Array();
        dummy_ns_ptr1 = new Array();
        dummy_ns_ptr2 = new Array();
................................................................................
        commands = namesp.getCommandsFromType(ns_ptr1);
        if (typeof commands[simple_name] != "undefined") {
          cmd_ptr = commands[simple_name];
        } else {
          switch (ns_ptr1.class_type) {
          case namesp.ITCL_TYPE_CLASS:
          case namesp.ITCL_EXTENDED_CLASS:
          case namesp.ITCL_WIDGET_CLASS:
          case namesp.ITCL_WIDGETADAPTOR_CLASS:
            /* that is for components installed within a class namespace */
            /* FIXME maybe this should only be a class method instead of a cmd_proc!! */
            if (typeof ns_ptr1.cmd_procs[simple_name] != "undefined") {
              cmd_ptr = ns_ptr1.cmd_procs[simple_name];
	    } else {
              /* that is itcl::type lookup in parent namespace too up to but not including root namespace */
              if (ns_ptr1.parent_namespace != null) {
................................................................................
      part1 = parts[0];
      part2 = parts[1];
    } else {
      part1 = my_name;
    }
    if (part1 == "this") {
      if ((namesp.class_type == namesp.ITCL_CLASS) || (namesp.class_type == namesp.ITCL_EXTENDED_CLASS)) {
        var class_obj_name = interp.frame_ptr.getClassObject();
	var class_ptr = new Array();
	if (interp.getClassObject(class_obj_name, class_ptr) != interp.OK) {
          return NULL;
	}
        var var_obj = class_ptr[0].getThisVariable();
	return var_obj;
      }
................................................................................
    }
    if (part1 == "self") {
      switch (namesp.class_type) {
      case namesp.ITCL_TYPE_CLASS:
      case namesp.ITCL_EXTENDED_CLASS:
      case namesp.ITCL_WIDGET_CLASS:
      case namesp.ITCL_WIDGETADAPTOR_CLASS:
        var class_obj_name = interp.frame_ptr.getClassObject();
	var class_ptr = new Array();
	if (interp.getClassObject(class_obj_name, class_ptr) != interp.OK) {
          return NULL;
	}
        var var_obj = class_ptr[0].getSelfVariable();
	return var_obj;
      }
    }
    if (part1 == "win") {
      switch (namesp.class_type) {
      case namesp.ITCL_CLASS:
      case namesp.ITCL_EXTENDED_CLASS:
        var class_obj_name = interp.frame_ptr.getClassObject();
	var class_ptr = new Array();
	if (interp.getClassObject(class_obj_name, class_ptr) != interp.OK) {
          return NULL;
	}
        var var_obj = class_ptr[0].getThisVariable();
	return var_obj;
      }
................................................................................
    } else {
      if (namesp.index > -3) {
        /* A cacheable namespace or global variable. */
      } else {
      }
    }
    while (my_var_obj.link != null) {
      my_var_obj = my_var_obj.link;
    }
    if (part2 != null) {
      /* Array element sought: look it up. */
      /* not necessary getValue does the job */
    }
if (namesp.variable_debug) {
print("lookupVariableEx END!"+name+"!flags!"+flags+"!msg!"+msg+"!crp1!"+create_part1+"!crp2!"+create_part2+"!var_obj!"+my_var_obj+"!");

Changes to rapl_obj.js.

614
615
616
617
618
619
620

621
622
623
624
625
626
627
628
...
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
  /* ==================== xdigitval ===================================== */
  xdigitval: function (ch) {
    if (ch >= '0' && ch <= '9') {
      return ch - '0';
    }
    if (ch >= 'a' && ch <= 'f') {
      return ch - 'a' + 10;

    if (ch >= 'A' && ch <= 'F')
      return ch - 'A' + 10;
    }
    return -1;
  },

  /* ==================== odigitval ===================================== */
  odigitval: function (ch) {
................................................................................
  },

  /* ==================== toString ===================================== */
  toString: function () {
    return this.getString();
  },

  /* ==================== old_raplEscape ===================================== */
  old_raplEscape: function (dest, str, slen) {
    var obj = this;
    var p = dest;
    var i;
    var len;

    if (slen == -1) {
      slen = str.length;
    }
    for (i = 0; i < slen; i++) {
      switch (str.charAt(i)) {
      case '\\':
        switch (str.charAt(i + 1)) {
        case 'a':
          p += 0x7;
          i++;
          break;
        case 'b':
          p += 0x8;
          i++;
          break;
        case 'f':
          p += 0xc;
          i++;
          break;
        case 'n':
          p += 0xa;
          i++;
          break;
        case 'r':
          p += 0xd;
          i++;
          break;
        case 't':
          p += 0x9;
          i++;
          break;
        case 'u':
        case 'x':
          /* A unicode or hex sequence.
            * \u Expect 1-4 hex chars and convert to utf-8.
            * \x Expect 1-2 hex chars and convert to hex.
            * An invalid sequence means simply the escaped char.
            */
          {
            var val = 0;
            var k;

            i++;
            for (k = 0; k < (str.charAt(i) == 'u' ? 4 : 2); k++) {
              var c = obj.xdigitval(str.charAt(i + k + 1));
              if (c == -1) {
                  break;
              }
              val = (val << 4) | c;
            }
            if (k) {
              /* Got a valid sequence, so convert */
              if (s[i] == 'u') {
                p += obj.utf8_fromunicode(p, val);
              } else {
                p += val;
              }
              i += k;
              break;
            }
            /* Not a valid codepoint, just an escaped char */
            p += sstr.charAt(i);
          }
          break;
        case 'v':
            p += 0xb;
            i++;
            break;
        case '\0':
            p += '\\';
            i++;
            break;
        case '\n':
            /* Replace all spaces and tabs after backslash newline with a single space*/
            p += ' ';
            do {
              i++;
            } while (str.charAt(i + 1) == ' ' || str.charAt(i + 1) == '\t');
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
          /* octal escape */
          {
            var val = 0;
            var c = obj.odigitval(str.charAt(i + 1));

            val = c;
            c = obj.odigitval(str.charAt(i + 2));
            if (c == -1) {
              p += val;
              i++;
              break;
            }
            val = (val * 8) + c;
            c = obj.odigitval(str.charAt(i + 3));
            if (c == -1) {
              p += val;
              i += 2;
              break;
            }
            val = (val * 8) + c;
            p += val;
            i += 3;
          }
          break;
        default:
          p += str.charAt(i + 1);
          i++;
          break;
        }
        break;
      default:
        p += str.charAt(i);
        break;
      }
    }
    len = i;
    p += '\0';
    return len + 1;
  },

  /* ==================== findHashEntry ===================================== */
  findHashEntry: function (hash_table, key) {
    var obj = this;

    if (typeof hash_table[key] != "undefined") {
      return hash_table[key];
    } else {







>
|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
...
892
893
894
895
896
897
898






































































































































899
900
901
902
903
904
905
  /* ==================== xdigitval ===================================== */
  xdigitval: function (ch) {
    if (ch >= '0' && ch <= '9') {
      return ch - '0';
    }
    if (ch >= 'a' && ch <= 'f') {
      return ch - 'a' + 10;
    }
    if (ch >= 'A' && ch <= 'F') {
      return ch - 'A' + 10;
    }
    return -1;
  },

  /* ==================== odigitval ===================================== */
  odigitval: function (ch) {
................................................................................
  },

  /* ==================== toString ===================================== */
  toString: function () {
    return this.getString();
  },







































































































































  /* ==================== findHashEntry ===================================== */
  findHashEntry: function (hash_table, key) {
    var obj = this;

    if (typeof hash_table[key] != "undefined") {
      return hash_table[key];
    } else {

Changes to rapl_parse.js.

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
...
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
....
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034

1035
1036
1037
1038
1039
1040
1041
....
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
  parse.parse_result = {
    missing:    " ",                    /* At end of parse, ' ' if complete, '{' if braces */
                                        /* incomplete, '"' if quotes incomplete */
    missing_line: null                  /* Line number starting the missing token */
  };

  parse.debug       = 0;
  parse.expr_operator_chars = "+->=<!*/%&|()eniNI";
  parse.interp      = null;
  parse.no_expr_parsing = false;

  R.log('constructor end', '2.life', 'Parser', true);
}

R.extend(Parser, R.Token, {
................................................................................
        parse.parse_info.cur == '\r' || parse.parse_info.cur == '\n') {
      if (parse.parse_info.cur == '\n') {
        parse.parse_info.line_no++;
      }
      parse.feedchar();
    }
    parse.parse_info.end = parse.parse_info.index - 1;
    parse.parse_info.token = parse.TOKEN_SEP;
    return parse.OK;
  },

  /* ==================== parseListQuote ===================================== */
  parseListQuote: function() {
    var parse = this;
    parse.feedchar();
................................................................................
        }
    }
    parse.parse_info.end = parse.parse_info.index - 1;
    return parse.OK;
  },

  /* ==================== parseExprIrrational ================================== */
  parseExprIrrational: function(exp) {
    var parse = this;
    var tokens = ["NaN", "nan", "NAN", "Inf", "inf", "INF"];
    var token;


    for (var i = 0; i < tokens.length; i++) {
      len = tokens[i].length;
      if (parse.parse_info.text.substring(parse.parse_info.index, parse.parse_info.index + len) == tokens[i]){
            parse.parse_info.start = parse.parse_info.index;
            parse.parse_info.end = parse.parse_info.index + len - 1;
            parse.parse_info.index += len;
................................................................................

    /* Validate paretheses around function arguments */
    if (best_idx >= parse.TOKEN_EXPROP_FUNC_FIRST) {
      var idx = parse.parse_info.index + best_len;
      var p = parse.parse_info.text.charAt(idx);
      var len = parse.parse_info.len - best_len;

      while (len && parse.hasSpace.test(UCHAR(parse.parse_info.textcharAt(idx)))) {
        len--;
        idx++;
      }
      if (parse.parse_info.textcharAt(idx) != '(') {
        return parse.ERROR;
      }
    }
    parse.parse_info.start = parse.parse_info.index;
    parse.parse_info.end = parse.parse_info.index + best_len - 1;
    parse.parse_info.index += best_len;
    parse.parse_info.len -= best_len;







<







 







|







 







|



>







 







|



|







43
44
45
46
47
48
49

50
51
52
53
54
55
56
...
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
....
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
....
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
  parse.parse_result = {
    missing:    " ",                    /* At end of parse, ' ' if complete, '{' if braces */
                                        /* incomplete, '"' if quotes incomplete */
    missing_line: null                  /* Line number starting the missing token */
  };

  parse.debug       = 0;

  parse.interp      = null;
  parse.no_expr_parsing = false;

  R.log('constructor end', '2.life', 'Parser', true);
}

R.extend(Parser, R.Token, {
................................................................................
        parse.parse_info.cur == '\r' || parse.parse_info.cur == '\n') {
      if (parse.parse_info.cur == '\n') {
        parse.parse_info.line_no++;
      }
      parse.feedchar();
    }
    parse.parse_info.end = parse.parse_info.index - 1;
    parse.parse_info.token = parse.TOKEN_WORD_SEP;
    return parse.OK;
  },

  /* ==================== parseListQuote ===================================== */
  parseListQuote: function() {
    var parse = this;
    parse.feedchar();
................................................................................
        }
    }
    parse.parse_info.end = parse.parse_info.index - 1;
    return parse.OK;
  },

  /* ==================== parseExprIrrational ================================== */
  parseExprIrrational: function() {
    var parse = this;
    var tokens = ["NaN", "nan", "NAN", "Inf", "inf", "INF"];
    var token;
    var len;

    for (var i = 0; i < tokens.length; i++) {
      len = tokens[i].length;
      if (parse.parse_info.text.substring(parse.parse_info.index, parse.parse_info.index + len) == tokens[i]){
            parse.parse_info.start = parse.parse_info.index;
            parse.parse_info.end = parse.parse_info.index + len - 1;
            parse.parse_info.index += len;
................................................................................

    /* Validate paretheses around function arguments */
    if (best_idx >= parse.TOKEN_EXPROP_FUNC_FIRST) {
      var idx = parse.parse_info.index + best_len;
      var p = parse.parse_info.text.charAt(idx);
      var len = parse.parse_info.len - best_len;

      while (len && parse.hasSpace.test(UCHAR(parse.parse_info.text.charAt(idx)))) {
        len--;
        idx++;
      }
      if (parse.parse_info.text.charAt(idx) != '(') {
        return parse.ERROR;
      }
    }
    parse.parse_info.start = parse.parse_info.index;
    parse.parse_info.end = parse.parse_info.index + best_len - 1;
    parse.parse_info.index += best_len;
    parse.parse_info.len -= best_len;

Changes to rapl_script.js.

290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
...
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
...
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
      }
    }

    if (line_args == 0) {
      script.token_idx--;
    }

    script.len = script.token_idx;

    if (debug_script_tokens) {
      var fname = script.interp.string_obj_type.getString(script.script_object.file_name_obj);
      print("======== Script ("+fname+") ======");
      for (var i = 0; i < script.token_idx; i++) {
        var token_info = script.script_object.tokens[i];
	if (debug_script_tokens > 1) {
................................................................................
	}else {
          print("["+i+"]@!"+token_info.toString());
	}
//        print("["+i+"]@"+script.getTokenString(token_info.token)+"!"+script.interp.string_obj_type.getString(token_info.obj_ptr)+"!");
      }
      print("======== Script END ======");
    }
    script.panic(script.len > count, "scriptObjAddTokens: script.len > count: "+script.len+"!"+count);
  },

  /* ==================== getText ================================== */
  getText: function(start_idx, len) {
    var script = this;

    return script.text.substring(start_idx, start_idx + len);
................................................................................
      token_list_idx++;
      token_info = script.script_object.tokens[script.token_idx];
      token_info.token = parse_token_info.token;
      token_info.obj_ptr = script.interp.script_obj_type.makeScriptObj(script.interp, parse_token_info, script.text);
      token_info.obj_ptr.incrRefCount("I_SCRIPT_4");
      script.token_idx++;
    }
    script.len = script.token_idx;
    if (debug_script_tokens) {
print("substObjAddTokens!"+script.script_object.file_name_obj+"!");
      var fname = script.interp.string_obj_type.getString(script.script_object.file_name_obj);
      print("======== subst script ("+fname+") ======");
      for (var i = 0; i < script.token_idx; i++) {
        var token_info = script.script_object.tokens[i];
	if (debug_script_tokens > 1) {







|







 







|







 







|







290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
...
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
...
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
      }
    }

    if (line_args == 0) {
      script.token_idx--;
    }

    script.script_object.len = script.token_idx;

    if (debug_script_tokens) {
      var fname = script.interp.string_obj_type.getString(script.script_object.file_name_obj);
      print("======== Script ("+fname+") ======");
      for (var i = 0; i < script.token_idx; i++) {
        var token_info = script.script_object.tokens[i];
	if (debug_script_tokens > 1) {
................................................................................
	}else {
          print("["+i+"]@!"+token_info.toString());
	}
//        print("["+i+"]@"+script.getTokenString(token_info.token)+"!"+script.interp.string_obj_type.getString(token_info.obj_ptr)+"!");
      }
      print("======== Script END ======");
    }
    script.panic(script.script_object.len > count, "scriptObjAddTokens: script.script_object.len > count: "+script.script_object.len+"!"+count);
  },

  /* ==================== getText ================================== */
  getText: function(start_idx, len) {
    var script = this;

    return script.text.substring(start_idx, start_idx + len);
................................................................................
      token_list_idx++;
      token_info = script.script_object.tokens[script.token_idx];
      token_info.token = parse_token_info.token;
      token_info.obj_ptr = script.interp.script_obj_type.makeScriptObj(script.interp, parse_token_info, script.text);
      token_info.obj_ptr.incrRefCount("I_SCRIPT_4");
      script.token_idx++;
    }
    script.script_object.len = script.token_idx;
    if (debug_script_tokens) {
print("substObjAddTokens!"+script.script_object.file_name_obj+"!");
      var fname = script.interp.string_obj_type.getString(script.script_object.file_name_obj);
      print("======== subst script ("+fname+") ======");
      for (var i = 0; i < script.token_idx; i++) {
        var token_info = script.script_object.tokens[i];
	if (debug_script_tokens > 1) {

Changes to rapl_script_line_obj_type.js.

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    var debug_script = 1;
    var obj_ptr;

    if (debug_script) {
      var str = "line="+line+", argc="+argc;
      obj_ptr = obj.interp.string_obj_type.newStringObj(str, -1, "SCRIPT_LINE_OBJ_TYPE_1");
    } else {
      obj_ptr = obj.interp.string_obj_type.newEmtyStringObj();
    }
    obj_ptr.obj_type = obj;
    obj_ptr.scriptLineValue.argc(argc);
    obj_ptr.scriptLineValue.line(line);

    return obj_ptr;
  },







|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    var debug_script = 1;
    var obj_ptr;

    if (debug_script) {
      var str = "line="+line+", argc="+argc;
      obj_ptr = obj.interp.string_obj_type.newStringObj(str, -1, "SCRIPT_LINE_OBJ_TYPE_1");
    } else {
      obj_ptr = obj.interp.string_obj_type.newEmptyStringObj();
    }
    obj_ptr.obj_type = obj;
    obj_ptr.scriptLineValue.argc(argc);
    obj_ptr.scriptLineValue.line(line);

    return obj_ptr;
  },

Changes to rapl_script_obj_type.js.

205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
    var script = subst_obj.getSubst(subst_obj_ptr, flags);

    subst_obj_ptr.incrRefCount("I_SCRIPT_OBJ_TYPE_3");      /* Make sure it's shared. */
    /* In order to preserve the internal rep, we increment the
     * ref_count field of the script internal rep structure. 
     */
    script.ref_count++;
    res_obj_ptr_ptr[0] = subst_obj.interp.eval_statement.interpolateTokens(script, 0, script.len, flags);
    script.ref_count--;
    subst_obj_ptr.decrRefCount("D_SCRIPT_OBJ_TYPE_1");
    if (res_obj_ptr_ptr[0] == null) {
      return subst_obj.ERROR;
    }
    return subst_obj.OK;
  },







|







205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
    var script = subst_obj.getSubst(subst_obj_ptr, flags);

    subst_obj_ptr.incrRefCount("I_SCRIPT_OBJ_TYPE_3");      /* Make sure it's shared. */
    /* In order to preserve the internal rep, we increment the
     * ref_count field of the script internal rep structure. 
     */
    script.ref_count++;
    res_obj_ptr_ptr[0] = subst_obj.interp.eval_statement.interpolateTokens(script, 0, script.script_object.len, flags);
    script.ref_count--;
    subst_obj_ptr.decrRefCount("D_SCRIPT_OBJ_TYPE_1");
    if (res_obj_ptr_ptr[0] == null) {
      return subst_obj.ERROR;
    }
    return subst_obj.OK;
  },

Changes to rapl_variable_obj_type.js.

38
39
40
41
42
43
44

45
46
47
48
49
50
51
....
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
....
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
  need_array: "variable isn't array",
  no_such_element: "no such element in array",
  dangling_element: "upvar refers to element in deleted array",
  dangling_var: "upvar refers to variable in deleted namespace",
  bad_namespace: "parent namespace doesn't exist",
  missing_name: "missing variable name",
  is_array_element: "name refers to an element in an array",

  LOOKUP_MSG_NO_SUCH_VAR: 1,
  LOOKUP_MSG_IS_ARRAY: 2,
  LOOKUP_MSG_NEED_ARRAY: 4,
  LOOKUP_MSG_NO_SUCH_ELEMENT: 8,
  LOOKUP_MSG_DANGLING_ELEMENT: 16,
  LOOKUP_MSG_DANGLING_VAR: 32,
  LOOKUP_MSG_BAD_NAMESPACE: 64,
................................................................................
    var dummy1_ptr = new Array();
    var dummy2_ptr = new Array();
    var i;
    var result;
    var var_len;
    var var_name = var_name_ptr.getString();

    varbl.err_msg = varbl.LOOKUP_NONE;
    var_ptr = null;
    var_ns_ptr[0] = null;
    index_ptr[0] = -3;
    err_msg_ptr[0] = null;

    if (flags & varbl.NAMESPACE_LOOKUP_GLOBAL_ONLY) {
      ctx_ns_ptr = varbl.interp.global_ns_ptr;
................................................................................
        }
      }
      if (create) {
        var_ptr = var_frame_ptr.getVariable(var_name, create);
      }
      if (var_ptr == null) {
        err_msg_ptr[0] = varbl.no_such_var+": "+"\""+var_name+"\"";
        varbl.err_msg = varbl.LOOKUP_MSG_SO_SUCH_VAR;
      }
    }
if (varbl.variable_debug) {
print("lookupSimpleVar end!"+var_name+"!"+var_ptr+"!"+(var_ptr == null ? "null" : var_ptr.toDebugString())+"!");
print("err_msg_ptr!"+err_msg_ptr[0]+"!"+index_ptr[0]+"!");
}
    return var_ptr;







>







 







|







 







|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
....
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
....
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
  need_array: "variable isn't array",
  no_such_element: "no such element in array",
  dangling_element: "upvar refers to element in deleted array",
  dangling_var: "upvar refers to variable in deleted namespace",
  bad_namespace: "parent namespace doesn't exist",
  missing_name: "missing variable name",
  is_array_element: "name refers to an element in an array",
  LOOKUP_MSG_NONE: 0,
  LOOKUP_MSG_NO_SUCH_VAR: 1,
  LOOKUP_MSG_IS_ARRAY: 2,
  LOOKUP_MSG_NEED_ARRAY: 4,
  LOOKUP_MSG_NO_SUCH_ELEMENT: 8,
  LOOKUP_MSG_DANGLING_ELEMENT: 16,
  LOOKUP_MSG_DANGLING_VAR: 32,
  LOOKUP_MSG_BAD_NAMESPACE: 64,
................................................................................
    var dummy1_ptr = new Array();
    var dummy2_ptr = new Array();
    var i;
    var result;
    var var_len;
    var var_name = var_name_ptr.getString();

    varbl.err_msg = varbl.LOOKUP_MSG_NONE;
    var_ptr = null;
    var_ns_ptr[0] = null;
    index_ptr[0] = -3;
    err_msg_ptr[0] = null;

    if (flags & varbl.NAMESPACE_LOOKUP_GLOBAL_ONLY) {
      ctx_ns_ptr = varbl.interp.global_ns_ptr;
................................................................................
        }
      }
      if (create) {
        var_ptr = var_frame_ptr.getVariable(var_name, create);
      }
      if (var_ptr == null) {
        err_msg_ptr[0] = varbl.no_such_var+": "+"\""+var_name+"\"";
        varbl.err_msg = varbl.LOOKUP_MSG_NO_SUCH_VAR;
      }
    }
if (varbl.variable_debug) {
print("lookupSimpleVar end!"+var_name+"!"+var_ptr+"!"+(var_ptr == null ? "null" : var_ptr.toDebugString())+"!");
print("err_msg_ptr!"+err_msg_ptr[0]+"!"+index_ptr[0]+"!");
}
    return var_ptr;