APWTCL Arnulf's Preferred Web Tcl

Check-in [64926c5351]
Login

Check-in [64926c5351]

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

Overview
Comment:fixes
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 64926c535160a98b13fc151681cb6851e38b2624
User & Date: arnulf 2012-04-20 12:34:40.432
Context
2012-04-20
21:25
fixes and add separate namespace for every type instance as selfns check-in: de8a7b84ad user: arnulf tags: trunk
12:34
fixes check-in: 64926c5351 user: arnulf tags: trunk
2012-04-19
13:02
initial version check-in: 45969a1e49 user: arnulf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/org/apwtcl/lang/Command.java.
270
271
272
273
274
275
276

277
278
279
280
281
282
283
        }
      }
    }
if (cmd_instance == null) {
print("=++Command.call!"+name+"!args!"+args.get(0)+"!"+args.size()+"!");
print("cmd!"+toDebugString()+"!");
}

    Object r = null;
    try {
//print("CCC!"+cmd_instance+"!");
      r = cmd_method.invoke(cmd_instance, interp, args);
//print("++call!"+r+"!");
    } catch(Exception e) {
print("call exception!"+e.getMessage()+"!");







>







270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
        }
      }
    }
if (cmd_instance == null) {
print("=++Command.call!"+name+"!args!"+args.get(0)+"!"+args.size()+"!");
print("cmd!"+toDebugString()+"!");
}
//print("=++Command.call!"+name+"!args!"+args.get(0)+"!"+args.size()+"!");
    Object r = null;
    try {
//print("CCC!"+cmd_instance+"!");
      r = cmd_method.invoke(cmd_instance, interp, args);
//print("++call!"+r+"!");
    } catch(Exception e) {
print("call exception!"+e.getMessage()+"!");
Changes to src/org/apwtcl/lang/CoreCommandPackages.java.
217
218
219
220
221
222
223
224
225




226
227
228
229
230
231
232
    cmds.put("array", sub_cmds);
    
    sub_cmds = new ArrayList<ApwtclObj>();
    sub_cmds.add(interp.string_obj_type.newStringObj("SplitCommand ::split", -1, "CORE_COMMAND_PACKAGES_47"));
    cmds.put("split", sub_cmds);
    
    sub_cmds = new ArrayList<ApwtclObj>();
    sub_cmds.add(interp.string_obj_type.newStringObj("ForCommand ::for", -1, "CORE_COMMAND_PACKAGES_47"));
    cmds.put("for", sub_cmds);




    
//print("core!"+cmds.keySet()+"!");    
    packages.put("core", cmds);
  }

  /* ==================== mySelf ================================== */
  public String mySelf() {







|

>
>
>
>







217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
    cmds.put("array", sub_cmds);
    
    sub_cmds = new ArrayList<ApwtclObj>();
    sub_cmds.add(interp.string_obj_type.newStringObj("SplitCommand ::split", -1, "CORE_COMMAND_PACKAGES_47"));
    cmds.put("split", sub_cmds);
    
    sub_cmds = new ArrayList<ApwtclObj>();
    sub_cmds.add(interp.string_obj_type.newStringObj("ForCommand ::for", -1, "CORE_COMMAND_PACKAGES_48"));
    cmds.put("for", sub_cmds);
    
    sub_cmds = new ArrayList<ApwtclObj>();
    sub_cmds.add(interp.string_obj_type.newStringObj("LinsertCommand ::linsert", -1, "CORE_COMMAND_PACKAGES_49"));
    cmds.put("linsert", sub_cmds);
    
//print("core!"+cmds.keySet()+"!");    
    packages.put("core", cmds);
  }

  /* ==================== mySelf ================================== */
  public String mySelf() {
Changes to src/org/apwtcl/lang/EvalStatement.java.
163
164
165
166
167
168
169




170




171
172
173
174
175
176
177
      }
      break;
    case TOKEN_CMD:
      if (interp.frame_ptr.type == CALL_TYPE_MACROEXPAND) {
        had_macro_cmd = true;
        macro_cmd_level = eval_level;
      }




      int my_ret = evalObj(token.obj_ptr);




      switch (my_ret) {
      case OK:
      case RETURN:
if (my_ret == RETURN) {
print("+++substonetoken RETURN!");
}
        obj_ptr = interp.result;







>
>
>
>

>
>
>
>







163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
      }
      break;
    case TOKEN_CMD:
      if (interp.frame_ptr.type == CALL_TYPE_MACROEXPAND) {
        had_macro_cmd = true;
        macro_cmd_level = eval_level;
      }
if (eval_subst_debug == 1) {
print(">>CMD!"+token.obj_ptr+"!");
eval_stmt_debug = 2;
}
      int my_ret = evalObj(token.obj_ptr);
if (eval_subst_debug == 1) {
print(">>CMD end!"+token.obj_ptr+"!");
eval_stmt_debug = -1;
}
      switch (my_ret) {
      case OK:
      case RETURN:
if (my_ret == RETURN) {
print("+++substonetoken RETURN!");
}
        obj_ptr = interp.result;
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
      if (script.script_object.tokens.get(i + idx).token == TOKEN_COMMENT) {
        continue;
      }
      result_ptr = new ArrayList<ApwtclObj>();
      retcode = substOneToken(script, idx + i, result_ptr);
      intv2.add(result_ptr.get(0));
if (eval_ipol_debug > 1) {
print("RES!"+result_ptr.get(0)+"!"+intv2.toString()+"!"+retcode+"!");
print("interpolateTokens dump 2!");
script.dumpToken(i+idx);
}
      if (intv2.get(j) != null) {
        intv2.get(j).incrRefCount("I_EVAL_STATEMENT_2");
      }
      switch(retcode) {







|







248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
      if (script.script_object.tokens.get(i + idx).token == TOKEN_COMMENT) {
        continue;
      }
      result_ptr = new ArrayList<ApwtclObj>();
      retcode = substOneToken(script, idx + i, result_ptr);
      intv2.add(result_ptr.get(0));
if (eval_ipol_debug > 1) {
print("RES ipol!"+result_ptr.get(0)+"!"+intv2.toString()+"!"+retcode+"!");
print("interpolateTokens dump 2!");
script.dumpToken(i+idx);
}
      if (intv2.get(j) != null) {
        intv2.get(j).incrRefCount("I_EVAL_STATEMENT_2");
      }
      switch(retcode) {
389
390
391
392
393
394
395
396
397
398
399

400
401
402
403
404
405
406
407
408
409
410
411

412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432

433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
        had_macro_cmd = false;
      }
      eval_level--;
      return OK;
    }
//print("EVALOBJ5");
    ArrayList<Variable> var_ptr = new ArrayList<Variable>();
//FIXME!!        && script.script_object.tokens.get(1).obj_ptr.CmdValue_GetCmdPtr().native_fcn.cmd_proc == interp.IncrCoreCommand
    if (script.script_object.len == 3
        && script.script_object.tokens.get(1).obj_ptr.obj_type == OBJ_TYPE_COMMAND
        && script.script_object.tokens.get(1).obj_ptr.cmdValue_GetResolvedCmdNamePtr().cmd_ptr.is_proc == false

        && script.script_object.tokens.get(2).obj_ptr.obj_type == OBJ_TYPE_VARIABLE) {

      ApwtclObj obj_ptr = interp.variable_obj_type.getVariable(script.script_object.tokens.get(2).obj_ptr, TOKEN_NONE, var_ptr);

      if (obj_ptr != null && !obj_ptr.isShared() && obj_ptr.obj_type == OBJ_TYPE_INT) {
//FIXME!!        JimWideValue(obj_ptr)++;
        obj_ptr.invalidateStringRep();
        script_obj_ptr.decrRefCount("D_EVAL_STATEMENT_5");
        interp.setResult(obj_ptr);
        if (macro_cmd_level == eval_level) {
          had_macro_cmd = false;
        }

        eval_level--;
        return OK;
      }
    }
//print("EVALOBJ6");
    /* Now we have to make sure the internal repr will not be
     * freed on shimmering.
     *
     * 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.
     */
//print("EVALOBJ7");

    for (i = 0; i < script.script_object.len && retcode == OK; ) {
      int argc;
      ArrayList<ApwtclObj> argv = new ArrayList<ApwtclObj>();
      int j;
      Command cmd;
      int num_comments = 0;

      /* First token of the line is always TOKEN_LINE */
      argc = token.get(i).obj_ptr.scriptLineValue_GetArgc();
//print("I!"+i+"!"+argc+"!"+getTokenString(token.get(i).token)+"!"+token.get(i).obj_ptr.ToDebugString()+"!");
      line_no = token.get(i).obj_ptr.scriptLineValue_GetLine();
      /* Skip the TOKEN_LINE token */
      i++;
      /* Populate the arguments objects.
       * If an error occurs, retcode will be set and
       * 'j' will be set to the number of args expanded
       */
      had_comment = false;
for (j = 0; j < argc; j++) {
if (eval_stmt_debug > 0) {
print("all J!"+j+"!"+getTokenString(token.get(j+i).token)+"!"+token.get(j+i).obj_ptr+"!");
}              
}
      for (j = 0; j < argc; j++) {
//print("J!"+j+"!"+argc+"!"+argv+"!");
        int word_tokens = 1;
        boolean expand = false;







<


|
>


|









>
|
|



















>



















|







397
398
399
400
401
402
403

404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
        had_macro_cmd = false;
      }
      eval_level--;
      return OK;
    }
//print("EVALOBJ5");
    ArrayList<Variable> var_ptr = new ArrayList<Variable>();

    if (script.script_object.len == 3
        && script.script_object.tokens.get(1).obj_ptr.obj_type == OBJ_TYPE_COMMAND
	    && script.script_object.tokens.get(1).obj_ptr.cmdValue_GetResolvedCmdNamePtr().cmd_ptr.is_proc == false
        && script.script_object.tokens.get(1).obj_ptr.cmdValue_GetResolvedCmdNamePtr().cmd_ptr.name.equals("incr")
        && script.script_object.tokens.get(2).obj_ptr.obj_type == OBJ_TYPE_VARIABLE) {

      ApwtclObj obj_ptr = interp.variable_obj_type.getVariable(script.script_object.tokens.get(2).obj_ptr, FUNCTION_FLAGS_NONE, var_ptr);

      if (obj_ptr != null && !obj_ptr.isShared() && obj_ptr.obj_type == OBJ_TYPE_INT) {
//FIXME!!        JimWideValue(obj_ptr)++;
        obj_ptr.invalidateStringRep();
        script_obj_ptr.decrRefCount("D_EVAL_STATEMENT_5");
        interp.setResult(obj_ptr);
        if (macro_cmd_level == eval_level) {
          had_macro_cmd = false;
        }
        /* can only uncomment, if JimWideValue above is fixed!! */
//        eval_level--;
//        return OK;
      }
    }
//print("EVALOBJ6");
    /* Now we have to make sure the internal repr will not be
     * freed on shimmering.
     *
     * 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.
     */
//print("EVALOBJ7");

    for (i = 0; i < script.script_object.len && retcode == OK; ) {
      int argc;
      ArrayList<ApwtclObj> argv = new ArrayList<ApwtclObj>();
      int j;
      Command cmd;
      int num_comments = 0;

      /* First token of the line is always TOKEN_LINE */
      argc = token.get(i).obj_ptr.scriptLineValue_GetArgc();
//print("I!"+i+"!"+argc+"!"+getTokenString(token.get(i).token)+"!"+token.get(i).obj_ptr.ToDebugString()+"!");
      line_no = token.get(i).obj_ptr.scriptLineValue_GetLine();
      /* Skip the TOKEN_LINE token */
      i++;
      /* Populate the arguments objects.
       * If an error occurs, retcode will be set and
       * 'j' will be set to the number of args expanded
       */
      had_comment = false;
for (j = 0; j < argc; j++) {
if (eval_stmt_debug > -2) {
print("all J!"+j+"!"+getTokenString(token.get(j+i).token)+"!"+token.get(j+i).obj_ptr+"!");
}              
}
      for (j = 0; j < argc; j++) {
//print("J!"+j+"!"+argc+"!"+argv+"!");
        int word_tokens = 1;
        boolean expand = false;
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
          case TOKEN_VAR_ARRAY_NAME:
//print("stmt var_array_name");
            word_obj_ptr = interp.array_obj_type.expandArray(token.get(i).obj_ptr);
            break;
          case TOKEN_VAR:
//print("evalObj! VAR!"+token.get(i).obj_ptr+"!"+token.get(i).obj_ptr.getString()+"!"+interp.frame_ptr.ns_ptr.toDebugString()+"!");
            ArrayList<Variable> result_var_ptr = new ArrayList<Variable>();
//            result_var_ptr.add(null);
if (token.get(i).obj_ptr.getString().equals("type")) {
//interp.variable_obj_type.dbg = 1;
}
            word_obj_ptr = interp.variable_obj_type.getVariable(token.get(i).obj_ptr, FUNCTION_FLAGS_LEAVE_ERR_MSG, result_var_ptr);
            Variable result_var = result_var_ptr.get(0);
            /* special case for ::itcl::type type variable !! */
if (token.get(i).obj_ptr.getString().equals("type")) {
//print("result_var_ptr!"+result_var_ptr+"!");
//print("SPECTYPE0!"+token.get(i).obj_ptr+"!"+interp.frame_ptr.ns_ptr.toDebugString()+"!");
//print("SPECTYPE!"+word_obj_ptr+"!"+result_var+"!"+token.get(i).obj_ptr.getString().equals("type")+"!");
}
            if (word_obj_ptr == null && result_var != null && token.get(i).obj_ptr.getString().equals("type")) {
              word_obj_ptr = interp.string_obj_type.newStringObj(result_var.namespace.full_name, -1, "EVAL_STATEMENT_7");
              word_obj_ptr.incrRefCount("I_EVAL_STATEMENT_5");
            }
            break;
          case TOKEN_EXPRSUGAR:
            word_obj_ptr = interp.expr_obj_type.expandExprSugar(token.get(i).obj_ptr);







<
<
<
<



<
<
<
<
<







510
511
512
513
514
515
516




517
518
519





520
521
522
523
524
525
526
          case TOKEN_VAR_ARRAY_NAME:
//print("stmt var_array_name");
            word_obj_ptr = interp.array_obj_type.expandArray(token.get(i).obj_ptr);
            break;
          case TOKEN_VAR:
//print("evalObj! VAR!"+token.get(i).obj_ptr+"!"+token.get(i).obj_ptr.getString()+"!"+interp.frame_ptr.ns_ptr.toDebugString()+"!");
            ArrayList<Variable> result_var_ptr = new ArrayList<Variable>();




            word_obj_ptr = interp.variable_obj_type.getVariable(token.get(i).obj_ptr, FUNCTION_FLAGS_LEAVE_ERR_MSG, result_var_ptr);
            Variable result_var = result_var_ptr.get(0);
            /* special case for ::itcl::type type variable !! */





            if (word_obj_ptr == null && result_var != null && token.get(i).obj_ptr.getString().equals("type")) {
              word_obj_ptr = interp.string_obj_type.newStringObj(result_var.namespace.full_name, -1, "EVAL_STATEMENT_7");
              word_obj_ptr.incrRefCount("I_EVAL_STATEMENT_5");
            }
            break;
          case TOKEN_EXPRSUGAR:
            word_obj_ptr = interp.expr_obj_type.expandExprSugar(token.get(i).obj_ptr);
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
          default:
            panic(true, "default token type reached in evalObj(): "+getTokenString(token.get(i).token));
          }
        } else {
          /* For interpolation we call a helper
           * function to do the work for us. 
           */
//print("interpolate!");
//script.DumpToken(i);
          word_obj_ptr = interpolateTokens(script, i, word_tokens, TOKEN_NONE);
//print("interpolate!"+word_obj_ptr.ToDebugString()+"!");
          if (word_obj_ptr != null && word_obj_ptr.len == 0) {
            /* we had only comment tokens, nothing to do */
            had_comment = true;
          }
        }







<
<







554
555
556
557
558
559
560


561
562
563
564
565
566
567
          default:
            panic(true, "default token type reached in evalObj(): "+getTokenString(token.get(i).token));
          }
        } else {
          /* For interpolation we call a helper
           * function to do the work for us. 
           */


          word_obj_ptr = interpolateTokens(script, i, word_tokens, TOKEN_NONE);
//print("interpolate!"+word_obj_ptr.ToDebugString()+"!");
          if (word_obj_ptr != null && word_obj_ptr.len == 0) {
            /* we had only comment tokens, nothing to do */
            had_comment = true;
          }
        }
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
          } else {
            /* we do not call unknown, if we had only the empty string as command and no arguments */
          }
        }
      }
//      /* Finished with the command, so decrement ref counts of each argument */
      for (j = 0; j < argv.size(); j++) {
        argv.get(j).decrRefCount("D_EVAL_STATEMENT_7");
      }
      argv = new ArrayList<ApwtclObj>();
    }

    /* Possibly add to the error stack trace */
    addErrorToStack(retcode, script.script_object.file_name_obj, line_no);








|







705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
          } else {
            /* we do not call unknown, if we had only the empty string as command and no arguments */
          }
        }
      }
//      /* Finished with the command, so decrement ref counts of each argument */
      for (j = 0; j < argv.size(); j++) {
        argv.get(j).decrRefCount("D_EVAL_STATEMENT_7!"+argv.get(j).obj_type+"!"+(argv.get(j).bytes == null ? "null" : argv.get(j).bytes.toString())+"!");
      }
      argv = new ArrayList<ApwtclObj>();
    }

    /* Possibly add to the error stack trace */
    addErrorToStack(retcode, script.script_object.file_name_obj, line_no);

Changes to src/org/apwtcl/lang/Expr.java.
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
        wC = true;
      } else {
        wC = false;
      }
      break;
    case TOKEN_EXPROP_STRNI:
      wD = interp.list_obj_type.searchList(B, A);
      if (wD >= 0) {
        wC = true;
      } else {
        wC = false;	  
      }
      break;
    default:
      print("abort()");







|







608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
        wC = true;
      } else {
        wC = false;
      }
      break;
    case TOKEN_EXPROP_STRNI:
      wD = interp.list_obj_type.searchList(B, A);
      if (wD == 0) {
        wC = true;
      } else {
        wC = false;	  
      }
      break;
    default:
      print("abort()");
Changes to src/org/apwtcl/lang/cmd/ItclCommand.java.
262
263
264
265
266
267
268

269
270
271
272
273
274
275
          }
        }
      } else {
        if (args.size() <= i + 1) {
          my_args = new ArrayList<ApwtclObj>();
          for (i = 1; i < args.size(); i++) {
            my_args.add(args.get(i));

          }
          interp.setResultString("expandmacro not enough arguments!"+my_args);
          return ERROR;
        }
        value_ptr = args.get(1 + i);        
        var_name_ptr = interp.string_obj_type.newStringObj(param_name_ptr.getString(), -1, "PKG_ITCLCMD_3");
        var_name_ptr.incrRefCount("I_PKG_ITCLCMD_4");







>







262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
          }
        }
      } else {
        if (args.size() <= i + 1) {
          my_args = new ArrayList<ApwtclObj>();
          for (i = 1; i < args.size(); i++) {
            my_args.add(args.get(i));
            args.get(i).incrRefCount("ITCL_COMMAND_9");
          }
          interp.setResultString("expandmacro not enough arguments!"+my_args);
          return ERROR;
        }
        value_ptr = args.get(1 + i);        
        var_name_ptr = interp.string_obj_type.newStringObj(param_name_ptr.getString(), -1, "PKG_ITCLCMD_3");
        var_name_ptr.incrRefCount("I_PKG_ITCLCMD_4");
371
372
373
374
375
376
377

378
379
380
381
382
383
384
        protection_val = PROTECTION_PUBLIC;
      }
      break;
    }
    ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
    for (int i = 2; i < args.size(); i++) {
      my_args.add(args.get(i));

    }
//print("my_args!"+protection_val+"!"+kind+"!"+my_args+"!");
    ret_code = interp.itcl_obj_type.mkMember(protection_val, kind, my_args);
    return ret_code;
  } catch(Exception e) {
    e.printStackTrace();
    return ERROR;







>







372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
        protection_val = PROTECTION_PUBLIC;
      }
      break;
    }
    ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
    for (int i = 2; i < args.size(); i++) {
      my_args.add(args.get(i));
      args.get(i).incrRefCount("ITCL_COMMAND_8");
    }
//print("my_args!"+protection_val+"!"+kind+"!"+my_args+"!");
    ret_code = interp.itcl_obj_type.mkMember(protection_val, kind, my_args);
    return ret_code;
  } catch(Exception e) {
    e.printStackTrace();
    return ERROR;
692
693
694
695
696
697
698

699

700

701
702
703
704
705
706
707
print("configure_method_var not yet implemented");
                /* get the method from the var */
// FIXME !!! need code here
              }
            } else {
              my_args = new ArrayList<ApwtclObj>();
              my_args.add(configure_method);

              my_args.add(option_name);

              my_args.add(option_val);

              interp.frame_ptr.ns_ptr = save_ns_ptr;
//print("my_args!"+my_args+"!");
//print("call evalObjVector xxx");
              ret_code = interp.eval_statement.evalObjVector(my_args.size(), my_args);
//print("evalObjVector done xxx");
//              ret_code = interp.eval_statement.evalObjFromArray(my_args);
            }







>

>

>







694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
print("configure_method_var not yet implemented");
                /* get the method from the var */
// FIXME !!! need code here
              }
            } else {
              my_args = new ArrayList<ApwtclObj>();
              my_args.add(configure_method);
              configure_method.incrRefCount("ITCL_COMMAND_7");
              my_args.add(option_name);
              option_name.incrRefCount("ITCL_COMMAND_6");
              my_args.add(option_val);
              option_val.incrRefCount("ITCL_COMMAND_5");
              interp.frame_ptr.ns_ptr = save_ns_ptr;
//print("my_args!"+my_args+"!");
//print("call evalObjVector xxx");
              ret_code = interp.eval_statement.evalObjVector(my_args.size(), my_args);
//print("evalObjVector done xxx");
//              ret_code = interp.eval_statement.evalObjFromArray(my_args);
            }
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752


753
754
755
756
757
758
759
760
761
762
763

764

765

766
767
768
769
770
771
772
773
  }

  /* ==================== itclInternalClassconfigurelistCmd =========================== */
  public int classconfigurelistCmd(Interp interp, ArrayList<ApwtclObj> args) {
//print("itcl internal classconfigurelist called!"+args+"!");
    int lgth;
    int i;
    ArrayList<ApwtclObj> option_name_ptr = new ArrayList<ApwtclObj>();
    ApwtclObj opt_name;
    ArrayList<ApwtclObj> option_val_ptr = new ArrayList<ApwtclObj>();
    ApwtclObj opt_val;
    ApwtclObj lst_ptr;
    int ret_code = OK;

//print("::itcl::internal::classconfigurelist!"+args+"!"+args.size()+"!ns!"+interp.frame_ptr.ns_ptr+"!");
    if (args.size() != 2) {
      interp.wrongNumArgs(1, args, "optionList");
      return ERROR;
    }
    lst_ptr = args.get(1);
    lgth = interp.list_obj_type.listLength(lst_ptr);
    if (lgth % 2 != 0) {
      interp.setResultString("must be an even number of elements in list");
      return ERROR;
    }
    ApwtclObj name_ptr = interp.string_obj_type.newStringObj("configure", -1, "PKG_ITCLCMD_11");
    name_ptr.incrRefCount("I_PKG_ITCLCMD_6");
    ArrayList<ArrayList<ApwtclObj>> extra_args_ptr = new ArrayList<ArrayList<ApwtclObj>>();
    Command cmd_obj = interp.getCommand(name_ptr, FUNCTION_FLAGS_NONE, extra_args_ptr);
    if (cmd_obj == null) {
      interp.setResultString("no such command: \"::itcl::internal::classconfigure\"");
      return ERROR;
    }
    for (i = 0; i < lgth; i++) {


      if (interp.list_obj_type.listIndex(lst_ptr, i, option_name_ptr, FUNCTION_FLAGS_NONE) != OK) {
      return ERROR;
      }
      opt_name = option_name_ptr.get(0);
      i++;
      if (interp.list_obj_type.listIndex(lst_ptr, i, option_val_ptr, FUNCTION_FLAGS_NONE) != OK) {
        return ERROR;
      }
      opt_val = option_val_ptr.get(0);
      ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
      my_args.add(args.get(0));

      my_args.add(opt_name);

      my_args.add(opt_val);

//print("configurelist!"+i+"!"+lgth+"!"+my_args+"!");
      ret_code = (Integer)cmd_obj.call(interp, my_args, false);
//print("configurelist after call!"+i+"!"+lgth+"!"+my_args+"!");
    }
//print("configurelist after for");
    name_ptr.decrRefCount("D_PKG_ITCLCMD_4");
//print("configurelist return!"+ret_code+"!");
    return ret_code;







|

|




|



















>
>











>

>

>
|







724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
  }

  /* ==================== itclInternalClassconfigurelistCmd =========================== */
  public int classconfigurelistCmd(Interp interp, ArrayList<ApwtclObj> args) {
//print("itcl internal classconfigurelist called!"+args+"!");
    int lgth;
    int i;
    ArrayList<ApwtclObj> option_name_ptr = null;
    ApwtclObj opt_name;
    ArrayList<ApwtclObj> option_val_ptr = null;
    ApwtclObj opt_val;
    ApwtclObj lst_ptr;
    int ret_code = OK;

print("::itcl::internal::classconfigurelist!"+args+"!"+args.size()+"!ns!"+interp.frame_ptr.ns_ptr+"!");
    if (args.size() != 2) {
      interp.wrongNumArgs(1, args, "optionList");
      return ERROR;
    }
    lst_ptr = args.get(1);
    lgth = interp.list_obj_type.listLength(lst_ptr);
    if (lgth % 2 != 0) {
      interp.setResultString("must be an even number of elements in list");
      return ERROR;
    }
    ApwtclObj name_ptr = interp.string_obj_type.newStringObj("configure", -1, "PKG_ITCLCMD_11");
    name_ptr.incrRefCount("I_PKG_ITCLCMD_6");
    ArrayList<ArrayList<ApwtclObj>> extra_args_ptr = new ArrayList<ArrayList<ApwtclObj>>();
    Command cmd_obj = interp.getCommand(name_ptr, FUNCTION_FLAGS_NONE, extra_args_ptr);
    if (cmd_obj == null) {
      interp.setResultString("no such command: \"::itcl::internal::classconfigure\"");
      return ERROR;
    }
    for (i = 0; i < lgth; i++) {
      option_name_ptr = new ArrayList<ApwtclObj>();
      option_val_ptr = new ArrayList<ApwtclObj>();
      if (interp.list_obj_type.listIndex(lst_ptr, i, option_name_ptr, FUNCTION_FLAGS_NONE) != OK) {
      return ERROR;
      }
      opt_name = option_name_ptr.get(0);
      i++;
      if (interp.list_obj_type.listIndex(lst_ptr, i, option_val_ptr, FUNCTION_FLAGS_NONE) != OK) {
        return ERROR;
      }
      opt_val = option_val_ptr.get(0);
      ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
      my_args.add(args.get(0));
      my_args.get(0).incrRefCount("ITCL_COMMAND_10");
      my_args.add(opt_name);
      opt_name.incrRefCount("ITCL_COMMAND_11");
      my_args.add(opt_val);
      opt_val.incrRefCount("ITCL_COMMAND_12");
print("configurelist!"+i+"!"+lgth+"!"+my_args+"!");
      ret_code = (Integer)cmd_obj.call(interp, my_args, false);
//print("configurelist after call!"+i+"!"+lgth+"!"+my_args+"!");
    }
//print("configurelist after for");
    name_ptr.decrRefCount("D_PKG_ITCLCMD_4");
//print("configurelist return!"+ret_code+"!");
    return ret_code;
830
831
832
833
834
835
836

837
838
839
840
841
842
843
    }
    type_ptr = interp.string_obj_type.newStringObj(type_name, -1, "PKG_ITCLCMD_12");
    my_args = new ArrayList<ApwtclObj>();
    my_args.add(type_ptr);
    my_args.add(object_name);
    for (i = 5; i < args.size(); i++) {
      my_args.add(args.get(i));

    }
    ret_code = interp.itcl_obj_type.classCommand(my_args);
    if (ret_code == OK) {
      /* set the component to the object */
      ArrayList<Variable> var_ptr_ptr = new ArrayList<Variable>();
      ret_code = interp.variable_obj_type.setVariable(component_ptr, object_name, var_ptr_ptr);
    }







>







840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
    }
    type_ptr = interp.string_obj_type.newStringObj(type_name, -1, "PKG_ITCLCMD_12");
    my_args = new ArrayList<ApwtclObj>();
    my_args.add(type_ptr);
    my_args.add(object_name);
    for (i = 5; i < args.size(); i++) {
      my_args.add(args.get(i));
      args.get(i).incrRefCount("ITCL_COMMAND_12");
    }
    ret_code = interp.itcl_obj_type.classCommand(my_args);
    if (ret_code == OK) {
      /* set the component to the object */
      ArrayList<Variable> var_ptr_ptr = new ArrayList<Variable>();
      ret_code = interp.variable_obj_type.setVariable(component_ptr, object_name, var_ptr_ptr);
    }
Changes to src/org/apwtcl/lang/cmd/JavadebugCommand.java.
31
32
33
34
35
36
37






38

39
40
41
42
43
44
45

  /* ==================== javadebugCmd ================================== */
  public int javadebugCmd(Interp interp, ArrayList<ApwtclObj> args) {
print("javadebug called!"+args+"!");
    int val = 1;
    String type = args.get(1).toString();
    if (args.size() > 1) {






      val = Integer.parseInt(args.get(2).getString());

    }
    if (type.equals("eval_subst_debug")) {
print("ev_subst!"+interp.eval_statement.eval_subst_debug+"!"+val+"!");
      interp.eval_statement.eval_subst_debug = val;
    }
    if (type.equals("eval_ipol_debug")) {
print("ev_ipol!"+interp.eval_statement.eval_ipol_debug+"!"+val+"!");







>
>
>
>
>
>
|
>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

  /* ==================== javadebugCmd ================================== */
  public int javadebugCmd(Interp interp, ArrayList<ApwtclObj> args) {
print("javadebug called!"+args+"!");
    int val = 1;
    String type = args.get(1).toString();
    if (args.size() > 1) {
      String str = args.get(2).getString();
      int sign = 1;
      if (str.charAt(0) == '-') {
        sign = -1;
        str = str.substring(1);
      }
      val = Integer.parseInt(str);
      val *= sign;
    }
    if (type.equals("eval_subst_debug")) {
print("ev_subst!"+interp.eval_statement.eval_subst_debug+"!"+val+"!");
      interp.eval_statement.eval_subst_debug = val;
    }
    if (type.equals("eval_ipol_debug")) {
print("ev_ipol!"+interp.eval_statement.eval_ipol_debug+"!"+val+"!");
Changes to src/org/apwtcl/lang/cmd/LinsertCommand.java.
27
28
29
30
31
32
33

34
35
36
37
38
39
40
41
42
43
44
45
46
47

48
49
50
51
52

53
54
55
56
57
58
59
60

61
62

63
64

65



66

67
68
69
70
71
72




73
74
75

  /* ==================== LinsertCommand ================================== */
  public LinsertCommand() {
  }

  /* ==================== linsertCmd ================================== */
  public int linsertCmd(Interp interp, ArrayList<ApwtclObj> args) {

print("linsert called!"+args+"!");
    ArrayList<Integer> idx_ptr = new ArrayList<Integer>();
    int idx;
    int len;
    boolean err = false;
    ApwtclObj list_ptr;

    if (args.size() < 4) {
        interp.wrongNumArgs(1, args, "list index element ?element ...?");
        return ERROR;
    }
    list_ptr = args.get(1);
    if (list_ptr.isShared())
        list_ptr = list_ptr.duplicateObj();

    if (interp.index_obj_type.getIndex(args.get(2), idx_ptr) != OK) {
      err = true;
    }
    if (!err) {
      idx = idx_ptr.get(0);

      len = interp.list_obj_type.listLength(list_ptr);
      if (idx >= len) {
          idx = len;
      } else {
        if (idx < 0) {
          idx = len + idx + 1;
        }
      }

      ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
      for (int i = 3; i < args.size(); i++) {

        my_args.add(args.get(i));
      }

      interp.list_obj_type.listInsertElements(list_ptr, idx, my_args.size(), my_args);



      interp.setResult(list_ptr);

      return OK;
    }
    if (list_ptr != args.get(1)) {
        list_ptr.freeNewObj("LINSERT_COMMAND_");
    }
    return ERROR;




  }

}







>












|
|
>





>








>


>


>

>
>
>

>



|


>
>
>
>



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

  /* ==================== LinsertCommand ================================== */
  public LinsertCommand() {
  }

  /* ==================== linsertCmd ================================== */
  public int linsertCmd(Interp interp, ArrayList<ApwtclObj> args) {
  try {
print("linsert called!"+args+"!");
    ArrayList<Integer> idx_ptr = new ArrayList<Integer>();
    int idx;
    int len;
    boolean err = false;
    ApwtclObj list_ptr;

    if (args.size() < 4) {
        interp.wrongNumArgs(1, args, "list index element ?element ...?");
        return ERROR;
    }
    list_ptr = args.get(1);
    if (list_ptr.isShared()) {
      list_ptr = list_ptr.duplicateObj();
    }
    if (interp.index_obj_type.getIndex(args.get(2), idx_ptr) != OK) {
      err = true;
    }
    if (!err) {
      idx = idx_ptr.get(0);
print("idx1!"+idx+"!");
      len = interp.list_obj_type.listLength(list_ptr);
      if (idx >= len) {
          idx = len;
      } else {
        if (idx < 0) {
          idx = len + idx + 1;
        }
      }
print("idx2!"+idx+"!");
      ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
      for (int i = 3; i < args.size(); i++) {
        args.get(i).incrRefCount("LINSERT_COMMAND_1");
        my_args.add(args.get(i));
      }
print("my_args!"+my_args+"!"+list_ptr+"!");
      interp.list_obj_type.listInsertElements(list_ptr, idx, my_args.size(), my_args);
      for (int i = 3; i < args.size(); i++) {
//        args.get(i).decrRefCount("LINSERT_COMMAND_2");
      }
      interp.setResult(list_ptr);
print("linsert end!"+list_ptr+"!");
      return OK;
    }
    if (list_ptr != args.get(1)) {
//        list_ptr.freeNewObj("LINSERT_COMMAND_3");
    }
    return ERROR;
  } catch(Exception e) {
    e.printStackTrace();
    return ERROR;
  }
  }

}
Changes to src/org/apwtcl/lang/cmd/LreplaceCommand.java.
24
25
26
27
28
29
30

31
32
33
34
35
36
37

  /* ==================== LreplaceCommand ================================== */
  public LreplaceCommand() {
  }

  /* ==================== lreplaceCmd ================================== */
  public int lreplaceCmd(Interp interp, ArrayList<ApwtclObj> args) {

//print("lreplace called!"+args+"!");
    ArrayList<Integer> first_index_ptr = new ArrayList<Integer>();
    ArrayList<Integer> last_index_ptr = new ArrayList<Integer>();
    int len;
    ArrayList<Integer> range_len_ptr = new ArrayList<Integer>();
    int range_len;
    int first;







>







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

  /* ==================== LreplaceCommand ================================== */
  public LreplaceCommand() {
  }

  /* ==================== lreplaceCmd ================================== */
  public int lreplaceCmd(Interp interp, ArrayList<ApwtclObj> args) {
  try {
//print("lreplace called!"+args+"!");
    ArrayList<Integer> first_index_ptr = new ArrayList<Integer>();
    ArrayList<Integer> last_index_ptr = new ArrayList<Integer>();
    int len;
    ArrayList<Integer> range_len_ptr = new ArrayList<Integer>();
    int range_len;
    int first;
71
72
73
74
75
76
77
78
79
80
81

82



83
84
85
86
87
88
89
90
91
92
93
94




95
96
97
        return ERROR;
      }
    }
    /* Add the first set of elements */
    new_list_obj = interp.list_obj_type.newListObj(list_obj.listValue_GetElem(), first);
    new_list_obj.incrRefCount("I_PKG_LISTCMD_5");
    /* Add supplied elements */
    args.remove(0);
    args.remove(0);
    args.remove(0);
    args.remove(0);

    interp.list_obj_type._listInsertElements(new_list_obj, -1, args.size(), args);



    /* Add the remaining elements */
    if (len - first - range_len > 0) {
      ArrayList<ApwtclObj> ll = new ArrayList<ApwtclObj>();
      ArrayList<ApwtclObj> llfrom = list_obj.listValue_GetElem();
      for (int i = first; i < first + range_len; i++) {
    	ll.add(llfrom.get(i));  
      }
      interp.list_obj_type._listInsertElements(new_list_obj, -1, len - first - range_len, ll);
    }
    interp.setResult(new_list_obj);
    new_list_obj.decrRefCount("D_PKG_LISTCMD_7");
    return OK;




  }

}







|
|
|
|
>
|
>
>
>












>
>
>
>



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
        return ERROR;
      }
    }
    /* Add the first set of elements */
    new_list_obj = interp.list_obj_type.newListObj(list_obj.listValue_GetElem(), first);
    new_list_obj.incrRefCount("I_PKG_LISTCMD_5");
    /* Add supplied elements */
    ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
    for (int i = 4; i < args.size(); i++) {
       args.get(i).incrRefCount("LREPLACE_COMMAND_1");
       my_args.add(args.get(i));
    }
    interp.list_obj_type._listInsertElements(new_list_obj, -1, my_args.size(), my_args);
    for (int i = 4; i < args.size(); i++) {
        args.get(i).decrRefCount("LREPLACE_COMMAND_2");
    }
    /* Add the remaining elements */
    if (len - first - range_len > 0) {
      ArrayList<ApwtclObj> ll = new ArrayList<ApwtclObj>();
      ArrayList<ApwtclObj> llfrom = list_obj.listValue_GetElem();
      for (int i = first; i < first + range_len; i++) {
    	ll.add(llfrom.get(i));  
      }
      interp.list_obj_type._listInsertElements(new_list_obj, -1, len - first - range_len, ll);
    }
    interp.setResult(new_list_obj);
    new_list_obj.decrRefCount("D_PKG_LISTCMD_7");
    return OK;
  } catch(Exception e) {
    e.printStackTrace();
    return ERROR;
  }
  }

}
Changes to src/org/apwtcl/lang/cmd/StringCommand.java.
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
      return ERROR;
    }
    if (args.size() == 4) {
      opt_case = 0;
      idx++;
    }
    interp.setResultInt(args.get(idx).stringCompareObj(args.get(idx + 1), (opt_case == 0 ? 1 : 0)));
print("RES compare!"+interp.getResult().getString()+"!");
    return OK;
  }

  /* ==================== stringEqualCmd ================================== */
  public int stringEqualCmd(Interp interp, ArrayList<ApwtclObj> args) {
//print("string equal called");
    int opt_case = 1;







|







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
      return ERROR;
    }
    if (args.size() == 4) {
      opt_case = 0;
      idx++;
    }
    interp.setResultInt(args.get(idx).stringCompareObj(args.get(idx + 1), (opt_case == 0 ? 1 : 0)));
//print("RES compare!"+interp.getResult().getString()+"!");
    return OK;
  }

  /* ==================== stringEqualCmd ================================== */
  public int stringEqualCmd(Interp interp, ArrayList<ApwtclObj> args) {
//print("string equal called");
    int opt_case = 1;
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
      idx++;
    }
    if (opt_case == 0) {
      interp.setResultInt(args.get(idx).stringCompareObj(args.get(idx + 1), (opt_case == 0 ? 1 : 0)));
    } else {
      interp.setResultBool(args.get(idx).stringEqObj(args.get(idx + 1)));
    }
print("RES equal!"+interp.getResult().getString()+"!");
    return OK;
  }

  /* ==================== stringFirstCmd ===================================== */
  public int stringFirstCmd(Interp interp, ArrayList<ApwtclObj> args) {
//print("string first called");
    int idx = 0;







|







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
      idx++;
    }
    if (opt_case == 0) {
      interp.setResultInt(args.get(idx).stringCompareObj(args.get(idx + 1), (opt_case == 0 ? 1 : 0)));
    } else {
      interp.setResultBool(args.get(idx).stringEqObj(args.get(idx + 1)));
    }
//print("RES equal!"+interp.getResult().getString()+"!");
    return OK;
  }

  /* ==================== stringFirstCmd ===================================== */
  public int stringFirstCmd(Interp interp, ArrayList<ApwtclObj> args) {
//print("string first called");
    int idx = 0;
Changes to src/org/apwtcl/lang/cmd/TraceCommand.java.
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
    interp.setResult(result_ptr);
print("sub cmds for !trace info!: "+result_ptr+"!");
    return OK;
  }

  /* ==================== traceAddCommandCmd ===================================== */
  public int traceAddCommandCmd(Interp interp, ArrayList<ApwtclObj> args) {
print("trace add  command called");
    if (args.size() != 3) {
      interp.wrongNumArgs(1, args, "add command");
      return ERROR;
    }
    ApwtclObj cmd_name = args.get(1);
    ApwtclObj ops = args.get(2);
    ApwtclObj command_prefix = args.get(3);







|







113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
    interp.setResult(result_ptr);
print("sub cmds for !trace info!: "+result_ptr+"!");
    return OK;
  }

  /* ==================== traceAddCommandCmd ===================================== */
  public int traceAddCommandCmd(Interp interp, ArrayList<ApwtclObj> args) {
//print("trace add  command called");
    if (args.size() != 3) {
      interp.wrongNumArgs(1, args, "add command");
      return ERROR;
    }
    ApwtclObj cmd_name = args.get(1);
    ApwtclObj ops = args.get(2);
    ApwtclObj command_prefix = args.get(3);
Changes to src/org/apwtcl/lang/objtype/ListObjType.java.
93
94
95
96
97
98
99



100
101
102
103
104
105
106
    obj_ptr.obj_type = OBJ_TYPE_LIST;
    obj_ptr.len= 0;
    obj_ptr.bytes = null;
    obj_ptr.listValue_SetLen(0);
    obj_ptr.listValue_SetMaxLen(0);
    ArrayList<ApwtclObj> elems = new ArrayList<ApwtclObj>();
    obj_ptr.listValue_SetElem(elems);




    /* Convert into a list */
    script.scriptTokenListInit();
//print("listsFA2!"+str+"!"+str_len+"!");
    parser.parserInit(str, str_len, linenr);
    while (!parser.parse_info.eof) {
      ApwtclObj element_ptr;







>
>
>







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
    obj_ptr.obj_type = OBJ_TYPE_LIST;
    obj_ptr.len= 0;
    obj_ptr.bytes = null;
    obj_ptr.listValue_SetLen(0);
    obj_ptr.listValue_SetMaxLen(0);
    ArrayList<ApwtclObj> elems = new ArrayList<ApwtclObj>();
    obj_ptr.listValue_SetElem(elems);
if (obj_ptr.value2 == null) {
print("list sFA!"+obj_ptr.toDebugString()+"!");
}

    /* Convert into a list */
    script.scriptTokenListInit();
//print("listsFA2!"+str+"!"+str_len+"!");
    parser.parserInit(str, str_len, linenr);
    while (!parser.parse_info.eof) {
      ApwtclObj element_ptr;
138
139
140
141
142
143
144



145
146
147
148
149
150
151
152
153
154
155
156
157
158



159
160
161
162
163
164
165
    for (i = 0; i < src_ptr.listValue_GetLen(); i++) {
       dup_ptr.listValue_GetElem().add(src_ptr.listValue_GetElem().get(i));
    }
    for (i = 0; i < dup_ptr.listValue_GetLen(); i++) {
      dup_ptr.listValue_GetElem().get(i).incrRefCount("LIST_OBJ_TYPE_0");
    }
    dup_ptr.obj_type = OBJ_TYPE_LIST;



  }

  /* ==================== updateString ===================================== */
  public void updateString(ApwtclObj obj_ptr) {
	int i;
    int buf_len;
    int real_length;
    String str_rep;
    StringBuffer p;
    ArrayList<ApwtclObj> elem = obj_ptr.listValue_GetElem();

    /* (Over) Estimate the space needed. */
    ArrayList<Integer> quoting_type = new ArrayList<Integer>();
    buf_len = 0;



    for (i = 0; i < obj_ptr.listValue_GetLen(); i++) {
      int len;

      str_rep = elem.get(i).getString();
      len = elem.get(i).getStringLength();
      quoting_type.add(listElementQuotingType(str_rep, len));
      switch (quoting_type.get(i)) {







>
>
>














>
>
>







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
    for (i = 0; i < src_ptr.listValue_GetLen(); i++) {
       dup_ptr.listValue_GetElem().add(src_ptr.listValue_GetElem().get(i));
    }
    for (i = 0; i < dup_ptr.listValue_GetLen(); i++) {
      dup_ptr.listValue_GetElem().get(i).incrRefCount("LIST_OBJ_TYPE_0");
    }
    dup_ptr.obj_type = OBJ_TYPE_LIST;
if (dup_ptr.value2 == null || src_ptr.value2 == null) {
print("newListObj!"+dup_ptr+"!"+src_ptr+"!");
}
  }

  /* ==================== updateString ===================================== */
  public void updateString(ApwtclObj obj_ptr) {
	int i;
    int buf_len;
    int real_length;
    String str_rep;
    StringBuffer p;
    ArrayList<ApwtclObj> elem = obj_ptr.listValue_GetElem();

    /* (Over) Estimate the space needed. */
    ArrayList<Integer> quoting_type = new ArrayList<Integer>();
    buf_len = 0;
if (obj_ptr.value2 == null) {
print(">>>list updateString!"+obj_ptr.toDebugString()+"!");
}
    for (i = 0; i < obj_ptr.listValue_GetLen(); i++) {
      int len;

      str_rep = elem.get(i).getString();
      len = elem.get(i).getStringLength();
      quoting_type.add(listElementQuotingType(str_rep, len));
      switch (quoting_type.get(i)) {
414
415
416
417
418
419
420



421
422
423
424
425
426
427
    obj_ptr = new ApwtclObj(interp);
    obj_ptr.obj_type = OBJ_TYPE_LIST;
    obj_ptr.bytes = null;
    obj_ptr.ref_count = 0;
    obj_ptr.listValue_SetElem(null);
    obj_ptr.listValue_SetLen(0);
    obj_ptr.listValue_SetMaxLen(0);



    if (len != 0) {
      _listInsertElements(obj_ptr, 0, len, elements);
    }
    return obj_ptr;
  }

  /* ==================== listGetElements ===================================== */







>
>
>







423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
    obj_ptr = new ApwtclObj(interp);
    obj_ptr.obj_type = OBJ_TYPE_LIST;
    obj_ptr.bytes = null;
    obj_ptr.ref_count = 0;
    obj_ptr.listValue_SetElem(null);
    obj_ptr.listValue_SetLen(0);
    obj_ptr.listValue_SetMaxLen(0);
if (obj_ptr.value2 == null) {
print("newListObj!"+obj_ptr+"!");
}
    if (len != 0) {
      _listInsertElements(obj_ptr, 0, len, elements);
    }
    return obj_ptr;
  }

  /* ==================== listGetElements ===================================== */
465
466
467
468
469
470
471






472
473
474
475
476
477
478
    point = list_ptr.listValue_GetElem();
    if (point == null) {
        list_ptr.listValue_SetElem(new ArrayList<ApwtclObj>());
        point = list_ptr.listValue_GetElem();
    }
//    Panic(!(elem_vec instanceof Array), "_listInsertElements! elem_vec is not instance of Array!");
    for (i = 0; i < elemc; ++i) {






        point.add(elem_vec.get(i));
        point.get(i + j).incrRefCount("LIST_OBJ_TYPE_1");
    }
    len = list_ptr.listValue_GetLen();
    list_ptr.listValue_SetLen(len + elemc);
    list_ptr.bytes = null;
    list_ptr.len = 0;







>
>
>
>
>
>







477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
    point = list_ptr.listValue_GetElem();
    if (point == null) {
        list_ptr.listValue_SetElem(new ArrayList<ApwtclObj>());
        point = list_ptr.listValue_GetElem();
    }
//    Panic(!(elem_vec instanceof Array), "_listInsertElements! elem_vec is not instance of Array!");
    for (i = 0; i < elemc; ++i) {
if (elem_vec.size() < i){
print("SIZE!"+elem_vec.size()+"!"+i+"!"+elem_vec+"!");	
}
if (point.size() < i + j){
print("SIZE2!"+point.size()+"!"+i+"!"+j+"!"+point+"!");	
}
        point.add(elem_vec.get(i));
        point.get(i + j).incrRefCount("LIST_OBJ_TYPE_1");
    }
    len = list_ptr.listValue_GetLen();
    list_ptr.listValue_SetLen(len + elemc);
    list_ptr.bytes = null;
    list_ptr.len = 0;
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813

    listlen = listLength(list_obj_ptr);
    for (i = 0; i < listlen; i++) {
      ArrayList<ApwtclObj> obj_ptr_ptr = new ArrayList<ApwtclObj>();

      listIndex(list_obj_ptr, i, obj_ptr_ptr, FUNCTION_FLAGS_NONE);
      if (obj_ptr_ptr.get(0).stringEqObj(val_obj)) {
        return 1;
      }
    }
    return 0;
  }

  /* ==================== listCopy ================================== */
  /*







|







817
818
819
820
821
822
823
824
825
826
827
828
829
830
831

    listlen = listLength(list_obj_ptr);
    for (i = 0; i < listlen; i++) {
      ArrayList<ApwtclObj> obj_ptr_ptr = new ArrayList<ApwtclObj>();

      listIndex(list_obj_ptr, i, obj_ptr_ptr, FUNCTION_FLAGS_NONE);
      if (obj_ptr_ptr.get(0).stringEqObj(val_obj)) {
    	  return 1;
      }
    }
    return 0;
  }

  /* ==================== listCopy ================================== */
  /*
Changes to src/org/apwtcl/lang/objtype/StringObjType.java.
173
174
175
176
177
178
179
180

181
182
183
184
185
186
187
  public int appendString(ApwtclObj obj_ptr, String str, int len) {
    panic(obj_ptr.isShared(), "appendString called with shared object");
    if (obj_ptr.obj_type != OBJ_TYPE_STRING) {
      setFromAny(obj_ptr);
    }
if (obj_ptr.value2 == null) {
print("appendString value2 == null!");
//print("VAL2 NULL!"+obj_ptr.toDebugString()+"!");

}
    _appendString(obj_ptr, str, len);
    return OK;
  }
  /* ==================== stringMap ================================== */
  /* does the [string map] operation. On error null is returned,
   * otherwise a new string object with the result, having refcount = 0,







|
>







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  public int appendString(ApwtclObj obj_ptr, String str, int len) {
    panic(obj_ptr.isShared(), "appendString called with shared object");
    if (obj_ptr.obj_type != OBJ_TYPE_STRING) {
      setFromAny(obj_ptr);
    }
if (obj_ptr.value2 == null) {
print("appendString value2 == null!");
print("VAL2 NULL!"+obj_ptr.toDebugString()+"!");
obj_ptr.strValue_SetCharLength(obj_ptr.len);
}
    _appendString(obj_ptr, str, len);
    return OK;
  }
  /* ==================== stringMap ================================== */
  /* does the [string map] operation. On error null is returned,
   * otherwise a new string object with the result, having refcount = 0,