APWTCL Arnulf's Preferred Web Tcl

Check-in [b55c80e855]
Login

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

Overview
Comment:fixes and debug stuff
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b55c80e855dd41943b46c088eba99d5781390577
User & Date: arnulf 2012-04-17 20:26:02
Context
2012-04-18
16:50
initial version check-in: 7e61f47e50 user: arnulf tags: trunk
2012-04-17
20:26
fixes and debug stuff check-in: b55c80e855 user: arnulf tags: trunk
09:11
fixes check-in: fdc2de0ac4 user: arnulf tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/org/apwtcl/lang/CallFrame.java.

    89     89     public String mySelf() {
    90     90       String str = "CallFrame!"+id+"!";
    91     91       return str;
    92     92     } 
    93     93         
    94     94     /* ==================== toString ===================================== */
    95     95     public String toString() {
    96         -    return mySelf()+"!"+(ns_ptr == null ? "null" : ns_ptr.full_name)+"!type!"+getCallTypeString(type)+"!";
           96  +    return mySelf()+(ns_ptr == null ? "null" : ns_ptr.full_name)+"!type!"+getCallTypeString(type)+"!";
    97     97     }
    98     98   
    99     99     /* ==================== toDebugString ===================================== */
   100    100     public String toDebugString() {
   101    101       StringBuffer str = new StringBuffer(mySelf()+"\n");
   102    102       str.append("  ref_count: "+ref_count+"\n");
   103    103       str.append("  type: "+getCallTypeString(type)+"\n");
................................................................................
   177    177       /* -- Put the object into the live list -- */
   178    178       my_call_frame.prev_call_frame_ptr = null;
   179    179       my_call_frame.next_call_frame_ptr = live_call_frame_list;
   180    180       if (live_call_frame_list != null) {
   181    181         live_call_frame_list.prev_call_frame_ptr = my_call_frame;
   182    182       }
   183    183       live_call_frame_list = my_call_frame;
          184  +//print("newCallFrame!"+my_call_frame.mySelf()+getCallTypeString(my_call_frame.type)+"!");
   184    185       return my_call_frame;
   185    186     }
   186    187   
   187    188     /* ==================== freeCallFrame ===================================== */
   188    189     /* Free an CallFrame. Actually call_frames are never freed, but
   189    190      * just moved to the free call_frames list, where they will be
   190    191      * reused by newCallFrame(). */
................................................................................
   218    219       CallFrame frame_ptr;
   219    220       String escaped_name;
   220    221   
   221    222   //print("CFA!"+toDebugString()+"!");
   222    223   //print("CF GetVariable!"+name+"!"+create+"!"+variables.get(name)+"!"+toDebugString()+"!");
   223    224   //print("GEVFR!"+name+"!"+create+"!"+interp.var_frame_ptr.toDebugString()+"!");
   224    225       escaped_name = escapeKey(name);
   225         -//print("callframe getvariable type!"+getCallTypeString(type)+"!");
          226  +if (interp.variable_obj_type.dbg != 0) {
          227  +print("callframe getvariable type!"+getCallTypeString(type)+"!");
          228  +}
   226    229       switch (type) {
   227    230       case CALL_TYPE_MACROEXPAND: 
   228    231         var_ns_ptr = interp.var_frame_ptr.ns_ptr;
   229    232         if (interp.var_frame_ptr.variables.get(escaped_name) == null) {
   230    233           if (var_ns_ptr.variables.get(escaped_name) == null) {
   231    234             if (create) {
   232    235               var_ns_ptr.variables.put(escaped_name, new Variable(interp, name, "VAR_NAMESPACE_VAR VAR_UNDEFINED", this, null));
................................................................................
   329    332     /* ==================== setClassObject =============================================== */
   330    333     public void setClassObject(ItclObject class_object) {
   331    334       this.class_object = class_object;
   332    335     }
   333    336   
   334    337     /* ==================== hasLocalVars =============================================== */
   335    338     public boolean hasLocalVars() {
          339  +if (interp.variable_obj_type.dbg != 0) {
          340  +print("call_type!"+getCallTypeString(CALL_TYPE_PROC));
          341  +}
   336    342       if (type == CALL_TYPE_PROC) {
   337    343         return true;
   338    344       }
   339    345       return false;
   340    346     }
   341    347   }
   342    348   

Changes to src/org/apwtcl/lang/ItclComponent.java.

    80     80   
    81     81     /* ==================== storeComponentInfo ================================== */
    82     82     public int storeComponentInfo(ArrayList<ApwtclObj> args) {
    83     83   //print("storeComponentInfo!"+args+"!");
    84     84       int processed_args;
    85     85       int option_flags;
    86     86       ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
    87         -
           87  +    ArrayList<Boolean> bool_ptr = new ArrayList<Boolean>();
           88  +    
    88     89       for (int i = 1; i < args.size(); i++) {
    89     90         my_args.add(args.get(i));
    90     91       }
    91     92   //print("args!"+args+"!"+my_args+"!");
    92     93       command_option_list.resetOptionValues();
    93     94       if (command_option_list.parseOptions(my_args, 0, "itclComponent") != OK) {
    94     95   //print("ERR!"+command_option_list.getErrorMsg()+"!");
................................................................................
    99    100       processed_args = command_option_list.getNumProcessedArgs();
   100    101   
   101    102       if (args.size() - processed_args > 0) {
   102    103         interp.setResultString("usage: component -public <typemethod>? ?-inherit ?<flag>?");
   103    104         return ERROR;
   104    105       }
   105    106       if ((option_flags & COMPONENT_OPTION_INHERIT) != 0) {
   106         -//      if (options.get("-inherit") != null) {
   107         -//        if (interp.int_obj_type.getBool(options.get("-inherit"), val) != OK) {
   108         -//          return ERROR;
   109         -//        }
   110         -//      } else {
   111         -//        if (interp.int_obj_type.getBool(interp.string_obj_type.newStringObj("1", -1, "ITCL_COMPONENT_1"), val) != OK) {
   112         -//          return ERROR;
   113         -//        }
   114         -//      }
   115         -        /* FIXME may have value here !! */
   116         -//        flag_inherit = val.get(0);
   117         -        flag_inherit = true;
          107  +      int option_has_value = command_option_list.optionHasValue("-inherit");
          108  +      if (option_has_value != OPTION_HAS_NO_VALUE) {
          109  +        if (interp.int_obj_type.getBool(command_option_list.getOptionValue(COMPONENT_OPTION_INHERIT).get(0), bool_ptr) != OK) {
          110  +          return ERROR;
          111  +        }
          112  +      } else {
          113  +        if (interp.int_obj_type.getBool(interp.string_obj_type.newStringObj("1", -1, "ITCL_COMPONENT_1"), bool_ptr) != OK) {
          114  +          return ERROR;
          115  +        }
          116  +      }
          117  +      flag_inherit = bool_ptr.get(0);
   118    118       }
   119    119       if ((option_flags & COMPONENT_OPTION_PUBLIC) != 0) {
   120         -      /* FIXME ned to get value here !! */
   121         -      // flag_public = options.get("-public");
   122         -      flag_public = true;
          120  +      if (interp.int_obj_type.getBool(command_option_list.getOptionValue(COMPONENT_OPTION_PUBLIC).get(0), bool_ptr) != OK) {
          121  +        return ERROR;
          122  +      }
          123  +      flag_public = bool_ptr.get(0);
   123    124       }
   124    125       return OK;
   125    126     }
   126    127   }

Changes to src/org/apwtcl/lang/ItclObject.java.

   129    129   
   130    130   //print("initItclObject!"+toDebugString()+"!");
   131    131       /* add to class instances */
   132    132       my_obj_ptr = interp.string_obj_type.newStringObj(object_name, -1, "ITCL_OBJECT_1");
   133    133       my_obj_ptr.incrRefCount("I_ITCL_OBJECT_1");
   134    134       class_info.instances.add(my_obj_ptr);
   135    135       /* Create a new call frame */
          136  +print("initItclObject PUSF");
   136    137       ret_code = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, class_info.ns_ptr, CALL_TYPE_PROC);
   137    138       if (ret_code != OK) {
   138    139         return ERROR;
   139    140       }
   140    141       interp.frame_ptr.class_object = this;
   141    142       this_variable = new Variable(interp, "this", "VAR_THIS_VAR", null, class_info.ns_ptr);
   142    143       this_variable.setProtection(PROTECTION_PROTECTED);

Changes to src/org/apwtcl/lang/ItclOption.java.

   152    152       int processed_args;
   153    153       int option_flags;
   154    154       ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
   155    155   
   156    156       for (int i = 1; i < args.size(); i++) {
   157    157         my_args.add(args.get(i));
   158    158       }
   159         -//print("args!"+args+"!"+my_args+"!");
          159  +print("args!"+args+"!"+my_args+"!");
   160    160       command_option_list.resetOptionValues();
   161    161       if (command_option_list.parseOptions(my_args, 0, "itclOption") != OK) {
   162         -//print("ERR!"+command_option_list.getErrorMsg()+"!");
          162  +print("ERR!"+command_option_list.getErrorMsg()+"!");
   163    163         interp.setResultString(command_option_list.getErrorMsg());
   164    164         return ERROR;
   165    165       }
   166    166       option_flags = command_option_list.getOptionFlags();
   167    167       processed_args = command_option_list.getNumProcessedArgs();
   168         -//print("storOption2!"+args.size()+"!"+processed_args);
          168  +print("storeOption2!"+args.size()+"!"+processed_args);
   169    169       if (args.size() - 1 != processed_args) {
   170    170         interp.setResultString("usage: option ?option value ...? ?result?");
          171  +print("storeopt err2");
   171    172         return ERROR;
   172    173       }
   173    174       /* take care of command as args[0] */
   174    175       processed_args++;
   175    176       if ((option_flags & ITCL_OPTION_READONLY) != 0) {
   176    177         if (interp.int_obj_type.getBool(command_option_list.getOptionValue(ITCL_OPTION_READONLY).get(0), bool_ptr) != OK) {
   177         -        return ERROR;
          178  +print("storeopt err3");
          179  +    	 return ERROR;
   178    180         }
   179    181         read_only = bool_ptr.get(0);
   180    182       }
   181    183       if ((option_flags & ITCL_OPTION_DEFAULT) != 0) {
   182    184         default_value = command_option_list.getOptionValue(ITCL_OPTION_DEFAULT).get(0);
   183    185       }
   184    186       if ((option_flags & ITCL_OPTION_CGET_METHOD) != 0) {

Changes to src/org/apwtcl/lang/Namespace.java.

   111    111     public String mySelf() {
   112    112       String str = "Namespace!"+id+"!";
   113    113       return str;
   114    114     } 
   115    115         
   116    116     /* ==================== toString ===================================== */
   117    117     public String toString() {
   118         -    return mySelf()+"!"+full_name+"!class_type!"+getItclClassTypeString(class_type)+"!";
          118  +    return mySelf()+full_name+"!class_type!"+getItclClassTypeString(class_type);
   119    119     }
   120    120   
   121    121     /* ==================== toDebugString ===================================== */
   122    122     public String toDebugString() {
   123    123       StringBuffer str = new StringBuffer(mySelf()+"\n");
   124    124       str.append("  name: "+name+"\n");
   125    125       str.append("  full_name: "+full_name+"\n");
   126    126       str.append("  class_type: "+getItclClassTypeString(class_type)+"\n");
   127    127       str.append("  command_resolver: "+command_resolver+"\n");
   128    128       str.append("  variable_resolver: "+variable_resolver+"\n");
   129    129       str.append("  macro_resolver: "+macro_resolver+"\n");
          130  +
   130    131       ArrayList<String> a1 = new ArrayList<String>();
   131    132       for (String z: variables.keySet()) {
   132    133         a1.add(z);
   133    134       }
          135  +    Collections.sort(a1);
   134    136       str.append("  variables: "+a1.toString()+"\n");
          137  +
   135    138       ArrayList<String> a2 = new ArrayList<String>();
   136    139       for (String z: cmd_procs.keySet()) {
   137    140         a2.add(z);
   138    141       }
          142  +    Collections.sort(a2);
   139    143       str.append("  cmd_procs: "+a2+"\n");
          144  +
   140    145       ArrayList<String> a3 = new ArrayList<String>();
   141    146       for (String z: resolve_variables.keySet()) {
   142    147         a3.add(z);
   143    148       }
          149  +    Collections.sort(a3);
   144    150       str.append("  resolve_variables: "+a3+"\n");
          151  +
   145    152       ArrayList<String> a4 = new ArrayList<String>();
   146    153       for (String z: resolve_commands.keySet()) {
   147    154         a4.add(z);
   148    155       }
          156  +    Collections.sort(a4);
   149    157       str.append("  resolve_commands: "+a4.toString()+"\n");
          158  +    
   150    159       str.append("  children: "+children.keySet()+"\n");
   151    160       return str.toString();
   152    161     }
   153    162   
   154    163     /* ==================== getName ===================================== */
   155    164     public String getName() {
   156    165       return name;

Changes to src/org/apwtcl/lang/TclTest.java.

   351    351   //print("BDY!"+test_obj.mySelf()+"!"+body+"!");
   352    352   //print("BDY!"+test_obj.mySelf()+"!"+test_name+"!");
   353    353   
   354    354       /* Create a new call frame */
   355    355       ArrayList<CallFrame> frame_ptr_ptr = new ArrayList<CallFrame>();
   356    356       ApwtclObj result;
   357    357       try {
          358  +print("tcltest runTest PUSF");
   358    359         ret_code = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, interp.global_ns_ptr, CALL_TYPE_NAMESPACE);
   359    360       } catch(Exception e) {
   360    361   print("TERR!"+e+"!");
   361    362       }
   362    363       if (ret_code != OK) {
   363    364         return ERROR;
   364    365       }

Changes to src/org/apwtcl/lang/cmd/ItclCommand.java.

    34     34   
    35     35     /* ==================== initSubCmds ================================== */
    36     36     public int initSubCmds(Interp interp) {
    37     37   //print("itcl initSubCmds called"+interp+"!");
    38     38       interp.command_obj_type.registerNativeSubCommand("::itcl", "body", "ItclCommand");
    39     39       interp.command_obj_type.registerNativeSubCommand("::itcl", "class", "ItclCommand");
    40     40       interp.command_obj_type.registerNativeSubCommand("::itcl", "delete", "ItclCommand");
    41         -//    interp.command_obj_type.registerNativeSubCommand("::itcl", "expandmacro", "ItclCommand");
    42     41       interp.command_obj_type.registerNativeSubCommand("::itcl", "extendedclass", "ItclCommand");
    43     42       interp.command_obj_type.registerNativeSubCommand("::itcl", "macro", "ItclCommand");
    44     43       interp.command_obj_type.registerNativeSubCommand("::itcl", "mkmember", "ItclCommand");
    45     44       interp.command_obj_type.registerNativeSubCommand("::itcl", "type", "ItclCommand");
    46     45       interp.command_obj_type.registerNativeSubCommand("::itcl", "widget", "ItclCommand");
    47     46       interp.command_obj_type.registerNativeSubCommand("::itcl", "widgetadaptor", "ItclCommand");
    48     47       interp.command_obj_type.registerNativeSubCommand("::itcl internal", "set", "ItclCommand");
    49         -//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classinfo", "ItclCommand");
    50         -//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classcget", "ItclCommand");
    51         -//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classconfigure", "ItclCommand");
    52         -//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classconfigurelist", "ItclCommand");
    53         -//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classdestroy", "ItclCommand");
    54         -//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classinstall", "ItclCommand");
    55         -//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classinstallhull", "ItclCommand");
    56         -//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classisa", "ItclCommand");
    57     48   
    58     49       interp.command_obj_type.registerNativeCommand("::itcl::expandmacro", "ItclCommand", true);
    59     50       interp.command_obj_type.registerNativeCommand("::itcl::internal::classinfo", "ItclCommand", true);
    60     51       interp.command_obj_type.registerNativeCommand("::itcl::internal::classcget", "ItclCommand", true);
    61     52       interp.command_obj_type.registerNativeCommand("::itcl::internal::classconfigure", "ItclCommand", true);
    62     53       interp.command_obj_type.registerNativeCommand("::itcl::internal::classconfigurelist", "ItclCommand", true);
    63     54       interp.command_obj_type.registerNativeCommand("::itcl::internal::classdestroy", "ItclCommand", true);

Changes to src/org/apwtcl/lang/cmd/NamespaceCommand.java.

   538    538         namespace_ptr = namespace_ptr_ptr.get(0);
   539    539       }
   540    540       /*
   541    541        * Make the specified namespace the current namespace and evaluate the
   542    542        * command(s).
   543    543        */
   544    544       frame_ptr_ptr = new ArrayList<CallFrame>();
          545  +//print("namespace eval PUSF!");
   545    546       result = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, namespace_ptr, /*isProcCallFrame*/ 0);
   546    547       if (result != OK) {
   547    548         return ERROR;
   548    549       }
   549    550   if (false) {
   550    551   //    if (namesp.interp.ensembleRewrite.source_objs == null) {
   551    552   //      frame_ptr.objc = args.length;

Changes to src/org/apwtcl/lang/cmd/PackageCommand.java.

    86     86       }
    87     87       ApwtclObj package_name = args.get(1);
    88     88       ApwtclObj package_version = args.get(2);
    89     89       ApwtclObj script = null;
    90     90       if (args.size() > 3) {
    91     91         script = args.get(3);
    92     92       }
    93         -    return interp.package_obj_type.setPackageScript(package_name, package_version, script, FUNCTION_FLAGS_LEAVE_ERR_MSG);
           93  +    int ret = interp.package_obj_type.setPackageScript(package_name, package_version, script, FUNCTION_FLAGS_LEAVE_ERR_MSG);
           94  +//print("package ifneeded end");
           95  +    return ret;
    94     96     }
    95     97   
    96     98     /* ==================== packageNamesCmd ===================================== */
    97     99     public int packageNamesCmd(Interp interp, ArrayList<ApwtclObj> args) {
    98    100   print("package names called");
    99    101       if (args.size() != 2 && args.size() != 3) {
   100    102         interp.wrongNumArgs(1, args, "package ?version?");

Changes to src/org/apwtcl/lang/objtype/CommandObjType.java.

   445    445   //print("FR!"+intp.frame_ptr.toDebugString()+"!"+intp.max_nesting_depth+"!");
   446    446       if (interp.frame_ptr.level == interp.max_nesting_depth) {
   447    447         interp.setResultString("Too many nested calls. Infinite recursion?");
   448    448         return ERROR;
   449    449       }
   450    450       /* Create a new call frame */
   451    451       ArrayList<CallFrame> frame_ptr_ptr = new ArrayList<CallFrame>();
          452  +//print("commandObjType callProcedure PUSF!"+cmd_ptr+"!"+interp.frame_ptr+"!"+interp.var_frame_ptr+"!"+argv+"!");
   452    453       int result = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, cmd_ptr.ns_ptr, CALL_TYPE_PROC);
   453    454       if (result != OK) {
   454    455         return ERROR;
   455    456       }
   456    457       call_frame_ptr = frame_ptr_ptr.get(0);
   457    458       call_frame_ptr.argv = argv;
   458    459       call_frame_ptr.argc = argc;
................................................................................
   459    460       call_frame_ptr.proc_args_obj_ptr = cmd_ptr.proc.arg_list_obj_ptr;
   460    461       call_frame_ptr.proc_body_obj_ptr = cmd_ptr.proc.body_obj_ptr;
   461    462       call_frame_ptr.static_vars = cmd_ptr.proc.static_vars;
   462    463       call_frame_ptr.file_name_obj = file_name_obj;
   463    464       call_frame_ptr.line = line_no;
   464    465       cmd_ptr.proc.arg_list_obj_ptr.incrRefCount("I_COMMAND_OBJ_TYPE_5");
   465    466       cmd_ptr.proc.body_obj_ptr.incrRefCount("I_COMMAND_OBJ_TYPE_6");
          467  +//print("commandObjType callProcedure evalObj0!"+interp.frame_ptr+"!"+interp.var_frame_ptr+"!");
   466    468       interp.frame_ptr = call_frame_ptr;
   467    469       /* Install a new stack for local procs */
   468    470       prev_local_procs = interp.local_procs;
   469    471       interp.local_procs = null;
   470    472       /* How many optional args are available */
   471    473       optargs = (argc - 1 - param_info.req_arity);
   472    474       /* Step 'i' along the actual args, and step 'd' along the formal args */
          475  +//print("commandObjType callProcedure evalObj1!"+cmd_ptr+"!"+interp.frame_ptr+"!"+interp.var_frame_ptr+"!");
   473    476       i = 1;
   474    477       for (d = 0; d < param_info.arg_list.size(); d++) {
   475    478         ApwtclObj name_obj_ptr = param_info.arg_list.get(d).name_obj_ptr;
   476    479   
   477    480         if (d == param_info.args_pos) {
   478    481           /* assign $args */
   479    482           ApwtclObj list_obj_ptr = null;
................................................................................
   515    518         if (retcode != OK) {
   516    519           bad_arg_set = true;
   517    520           break;
   518    521         }
   519    522       }
   520    523       if (!bad_arg_set) {
   521    524         /* Eval the body */
          525  +//print("commandObjType callProcedure evalObj!"+cmd_ptr+"!"+interp.frame_ptr+"!"+interp.var_frame_ptr+"!");
   522    526         retcode = interp.eval_statement.evalObj(cmd_ptr.proc.body_obj_ptr);
   523    527       }
   524    528   
   525    529       /* Destroy the call frame */
          530  +//print("commandObjType callProcedure POSF!");
   526    531       interp.namespace_obj_type.popStackFrame();
   527    532   //    if (callFramePtr.vars.size != JIM_HT_INITIAL_SIZE) {
   528    533   //        JimFreeCallFrame(interp, callFramePtr, JIM_FCF_NONE);
   529    534   //    } else {
   530    535   //        JimFreeCallFrame(interp, callFramePtr, JIM_FCF_NOHT);
   531    536   //    }
   532    537       /* Handle the EVAL return code */

Changes to src/org/apwtcl/lang/objtype/ItclObjType.java.

   228    228        * public variables go directly to the class namespace
   229    229        */
   230    230       String var_namespace = "::itcl::internal::variables"+full_class_name;
   231    231       class_info.variable_namespace = interp.namespace_obj_type.createNamespace(var_namespace);
   232    232       Namespace parse_ns_ptr = interp.variable_obj_type.findNamespace("::itcl::classdefs", interp.global_ns_ptr, NAMESPACE_CREATE_IF_UNKNOWN);
   233    233       parse_ns_ptr.setMacroResolver(new Resolve(interp, RESOLVER_TYPE_MACRO));
   234    234       ArrayList<CallFrame> frame_ptr = new ArrayList<CallFrame>();
          235  +//print("itclObjType sFA PUSF");
   235    236       interp.namespace_obj_type.pushStackFrame(frame_ptr, parse_ns_ptr, CALL_TYPE_EVAL);
          237  +//print("EV!"+interp.frame_ptr+"!");
   236    238       ret_code = interp.eval_statement.evalObj(obj_ptr);
   237    239       interp.namespace_obj_type.popStackFrame();
   238    240       if (ret_code == OK) {
   239    241         /*
   240    242          *  At this point, parsing of the class definition has succeeded.
   241    243          *  Add built-in methods such as "configure" and "cget"--as long
   242    244          *  as they don't conflict with those defined in the class.
................................................................................
   350    352         ItclFunction fcn_info = new ItclFunction(interp, protection, kind_val, my_name, class_info);
   351    353         if (fcn_info.storeFunctionInfo(my_args) != OK) {
   352    354           return ERROR;
   353    355         }
   354    356         interp.curr_class_info.functions.put(escapeKey(my_name), fcn_info);
   355    357         break;
   356    358       case ITCL_OPTION:
          359  +print("ITCL_OPTION1!");
   357    360         if (interp.curr_class_info.options.get(escapeKey(my_name)) != null) {
   358    361           interp.setResultString(kind+" "+my_name+" is already defined for "+getItclClassTypeString(class_info.class_type)+" \""+class_info.class_name+"\"");
   359    362           return ERROR;
   360    363         }
          364  +print("ITCL_OPTION2!");
   361    365         ItclOption opt_info = new ItclOption(interp, protection, kind_val, my_name_ptr, class_info);
   362    366         if (opt_info == null) {
   363    367           return ERROR;
   364    368         }
          369  +print("ITCL_OPTION3!");
   365    370         if (opt_info.storeOptionInfo(my_args) != OK) {
   366    371             return ERROR;
   367    372         }
          373  +print("ITCL_OPTION4!");
   368    374         interp.curr_class_info.options.put(escapeKey(opt_info.option_name), opt_info);
          375  +print("ITCL_OPTION5!");
   369    376         break;
   370    377       case ITCL_COMPONENT:
   371    378       case ITCL_TYPECOMPONENT:
   372    379         if (interp.curr_class_info.components.get(escapeKey(my_name)) != null) {
   373    380           interp.setResultString(kind+" "+my_name+" is already defined for "+getItclClassTypeString(class_info.class_type)+" \""+class_info.class_name+"\"");
   374    381           return ERROR;
   375    382         }
................................................................................
   669    676   //print("cmd_obj4!"+cmd_obj.toDebugString()+"!");
   670    677         if (cmd_obj.is_proc) {
   671    678   //        ret_code = (Integer)cmd_obj.call(interp, my_args, /* ensemble_expand */ true);
   672    679           ret_code = interp.command_obj_type.callProcedure(cmd_obj, null, 0, my_args.size(), my_args);
   673    680         } else {
   674    681           /* Create a new call frame */
   675    682           ArrayList<CallFrame>frame_ptr_ptr = new ArrayList<CallFrame>();
          683  +print("itclObjType callClassCommand PUSF");
   676    684           int result = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, ns_ptr, CALL_TYPE_PROC);
   677    685           if (result != OK) {
   678    686             return ERROR;
   679    687           }
   680    688           /* Check if there are too nested calls */
   681    689   //print("FR!"+i_obj.intp.frame_ptr.toDebugString()+"!"+i_obj.interp.max_nesting_depth+"!");
   682    690           interp.cmd_priv_data = cmd_obj.native_fcn.privdata;

Changes to src/org/apwtcl/lang/objtype/NamespaceObjType.java.

   251    251      *      Modifies the interpreter's RAPL call stack.
   252    252      *
   253    253      *----------------------------------------------------------------------
   254    254      */
   255    255     public int pushCallFrame(CallFrame frame_ptr, Namespace namespace_ptr, int call_type) {
   256    256       Namespace ns_ptr;
   257    257   
          258  +//print("PUCF!"+namespace_ptr+"!"+getCallTypeString(call_type)+"!");
          259  +//print("VARCF!"+interp.var_frame_ptr+"!"+interp.frame_ptr+"!");
   258    260       if (namespace_ptr == null) {
   259    261         ns_ptr = getCurrentNamespace();
   260    262       } else {
   261    263         ns_ptr = namespace_ptr;
   262    264           /*
   263    265            * TODO: Examine whether it would be better to guard based on NAMESPACE_DYING
   264    266            * or NAMESPACE_KILLED. It appears that these are not tested because they can
................................................................................
   387    389      *----------------------------------------------------------------------
   388    390      */
   389    391     public int pushStackFrame(ArrayList<CallFrame> frame_ptr, Namespace namespace_ptr, int call_type) {
   390    392   //if (call_type == 0)  {
   391    393   //print("ERROR pushStackFrame calltype 0!"+frame_ptr+"!"+namespace_ptr+"!");
   392    394   //}
   393    395       frame_ptr.add(interp.frame_ptr.newCallFrame(call_type, interp.frame_ptr));
          396  +//print("PUSF!"+frame_ptr.get(0).mySelf()+namespace_ptr+"!"+getCallTypeString(call_type)+"!");
   394    397       return pushCallFrame(frame_ptr.get(0), namespace_ptr, call_type);
   395    398     }
   396    399   
   397    400     /* ==================== popStackFrame ===================================== */
   398    401     public void popStackFrame() {
   399    402   //    var free_ptr = interp.eval_statement.curr_call_frame;
   400    403   

Changes to src/org/apwtcl/lang/objtype/VariableObjType.java.

    51     51     private static final int LOOKUP_MSG_MISSING_NAME = 128;
    52     52     public static final int LOOKUP_MSG_IS_ARRAY_ELEMENT = 256;
    53     53   
    54     54     private int id;
    55     55     private Interp interp;
    56     56     public int variable_debug;
    57     57     public boolean no_trace;
           58  +public int dbg;
    58     59   
    59     60     /* ==================== VariableObjType ================================== */
    60     61     public VariableObjType(Interp interp) {
    61     62       oid++;
    62     63       id = oid;
    63     64   
    64     65       this.interp = interp;
................................................................................
   133    134         return TOKEN_VAR_ARRAY_NAME;
   134    135       }
   135    136   //print("varobjtype sFA 3");
   136    137       ApwtclObj part1_ptr = interp.string_obj_type.newStringObj(var_name, -1, "VARIABLE_OBJ_TYPE_1");
   137    138       part1_ptr.incrRefCount("I_VARIABLE_OBJ_TYPE_1");
   138    139       ArrayList<String> lookup_err_msg_ptr = new ArrayList<String>();
   139    140       ArrayList<Integer> lookup_index_ptr = new ArrayList<Integer>();
          141  +if (dbg != 0) {
          142  +print("sFA call lookupSimpleVar");
          143  +}
   140    144       Variable var_obj_ptr = lookupSimpleVar(part1_ptr, FUNCTION_FLAGS_LEAVE_ERR_MSG, /* create_part1 */ false, lookup_err_msg_ptr, lookup_index_ptr);
          145  +if (dbg != 0) {
          146  +print("sFA after call lookupSimpleVar");
          147  +}
   141    148       part1_ptr.decrRefCount("D_VARIABLE_OBJ_TYPE_1");
   142         -//print("varobjtype sFA 4!"+var_obj_ptr+"!"+frame_ptr.ns_ptr+"!");
          149  +if (dbg != 0) {
          150  +print("varobjtype sFA 4!"+var_obj_ptr+"!"+frame_ptr.ns_ptr.toDebugString()+"!");
          151  +}
   143    152       if (var_obj_ptr == null) {
   144    153         err_msg_ptr_ptr.add(lookup_err_msg_ptr.get(0));
   145    154         return ERROR;
   146    155       }
   147    156       err_msg_ptr_ptr.add(null);
   148    157       /* Free the old internal repr and set the new one. */
   149    158       obj_ptr.freeIntRep();
................................................................................
   173    182   
   174    183     public int setVariable(ApwtclObj name_obj_ptr, ApwtclObj val_obj_ptr, ArrayList<Variable> result_var_ptr) {
   175    184       String name;
   176    185       Variable var_ptr;
   177    186       boolean create = true;
   178    187       int err;
   179    188       ArrayList<String> err_msg_ptr = new ArrayList<String>();
   180         -//print("setVariable1!"+name_obj_ptr+"!");
          189  +if (name_obj_ptr.getString().equals("extrainits")) {
          190  +dbg = 0;
          191  +} else {
          192  +dbg = 0;
          193  +}
          194  +if (dbg != 0) {
          195  +print("setVariable1!"+name_obj_ptr+"!"+val_obj_ptr+"!"+interp.frame_ptr+"!"+interp.var_frame_ptr+"!");
          196  +}
   181    197   
   182    198       if ((err = setFromAny(name_obj_ptr, err_msg_ptr)) != OK) {
          199  +if (dbg != 0) {
          200  +print("setVariable NOT OK");
          201  +}
   183    202   //print("setVariable2 not OK!"+err_msg_ptr+"!");
   184    203         CallFrame frame_ptr = interp.frame_ptr;
   185    204   
   186    205         /* Check for array names like syntax. */
   187    206         if (err == TOKEN_VAR_ARRAY_NAME) {
   188    207   //print("setVariable2a!"+name_obj_ptr+"!"+interp.frame_ptr.ns_ptr+"!");
   189    208           int ret = interp.array_obj_type.arraySet(name_obj_ptr, val_obj_ptr, result_var_ptr);
................................................................................
   196    215         }
   197    216         /* if we did not find the variable it cannot be a namespace variable
   198    217          * as namespace variables are created with VAR_UNDEFINED, if not initialized
   199    218          * if err_msg_ptr is null
   200    219          * only exception global variables starting with :: like ::abc need
   201    220          * special handling here
   202    221          */
   203         -//print("setVariable3!"+name_obj_ptr.getString()+"!"+err_msg_ptr+"!");
          222  +if (dbg != 0) {
          223  +print("setVariable3!"+name_obj_ptr.getString()+"!"+err_msg_ptr+"!");
          224  +}
   204    225         String err_msg = err_msg_ptr.get(0);
   205    226         if (err_msg_ptr != null) {
   206    227           String my_name = name_obj_ptr.getString();
   207    228           if (my_name.indexOf("::") >= 0) {
   208    229             if (my_name.substring(2).indexOf("::") > 0) {
   209    230               interp.setResultString(err_msg);
   210    231               result_var_ptr.add(null);
................................................................................
   216    237         /* New variable to create */
   217    238         // FIXME need to get tail of variable name here !!
   218    239         name = name_obj_ptr.getString();
   219    240         if (name.charAt(0) == ':' && name.charAt(1) == ':') {
   220    241           name = name.substring(2);
   221    242         }
   222    243         var_ptr = frame_ptr.getVariable(name, create);
   223         -//print("setVariable a!"+name+"!"+var_ptr+"!"+create+"!"+interp.frame_ptr.ns_ptr+"!");      
          244  +if (dbg != 0) {
          245  +print("setVariable a!"+name+"!"+var_ptr+"!"+create+"!"+interp.frame_ptr.ns_ptr.toDebugString()+"!"+interp.frame_ptr.toDebugString()+"!");      
          246  +}
   224    247   //print("SEV!"+name+"!"+frame_ptr.variables.get(name)+"!"+interp.var_frame_ptr.variables.get(name)+"!"+frame_ptr.toDebugString()+"!"+interp.var_frame_ptr.toDebugString()+"!");
   225    248         result_var_ptr.add(var_ptr);
   226    249         var_ptr.obj_ptr = val_obj_ptr;
   227    250         val_obj_ptr.incrRefCount("I_VARIABLE_OBJ_TYPE_2");
   228    251         var_ptr.link_frame_ptr = null;
   229    252         /* Make the object int rep a variable */
   230    253         name_obj_ptr.freeIntRep();
................................................................................
   234    257         name_obj_ptr.varValue_SetNamespace(frame_ptr.ns_ptr);
   235    258         name_obj_ptr.varValue_SetVarPtr(var_ptr);
   236    259         if ((var_ptr.type & VAR_UNDEFINED) != 0) {
   237    260           var_ptr.type &= ~VAR_UNDEFINED;
   238    261         }
   239    262         handleVariableTrace(name_obj_ptr, null, TRACE_OP_WRITE, "write", null);
   240    263       } else {
          264  +if (dbg != 0) {
          265  +print("setVariable OK");
          266  +}
   241    267   //print("SEV2!");
   242    268         var_ptr = name_obj_ptr.varValue_GetVarPtr();
   243    269         if ((var_ptr.type & VAR_UNDEFINED) != 0) {
   244    270           var_ptr.type &= ~VAR_UNDEFINED;
   245    271         }
   246    272         if (var_ptr.link_frame_ptr == null) {
   247    273           val_obj_ptr.incrRefCount("I_VARIABLE_OBJ_TYPE_3");
................................................................................
   381    407      *
   382    408      * If FUNCTION_FLAGS_UNSHARED is set and the variable is an array element (dict sugar)
   383    409      * in a dictionary which is shared, the array variable value is duplicated first.
   384    410      * This allows the array element to be updated (e.g. append, lappend) without
   385    411      * affecting other references to the dictionary.
   386    412      */
   387    413     public ApwtclObj getVariable(ApwtclObj name_obj_ptr, int flags, ArrayList<Variable> result_var_ptr) {
   388         -//print("getVariable1!"+name_obj_ptr+"!");
          414  +if (dbg != 0) {
          415  +print("getVariable1!"+name_obj_ptr+"!");
          416  +}
   389    417   //print("GEV!"+name_obj_ptr+"!"+interp.var_frame_ptr.variables.get(name_obj_ptr.getString())+"!"+interp.var_frame_ptr.variables.get(name_obj_ptr.getString())+"!"+interp.frame_ptr.toDebugString()+"!"+interp.var_frame_ptr.toDebugString()+"!");
   390    418   //print("getVariable1!"+name_obj_ptr+"!");
   391    419       ArrayList<String> err_msg_ptr_ptr = new ArrayList<String>();
   392    420       switch (setFromAny(name_obj_ptr, err_msg_ptr_ptr)) {
   393    421       case OK:
   394         -//print("getVariable2!"+name_obj_ptr+"!");
          422  +if (dbg != 0) {
          423  +print("getVariable2!"+name_obj_ptr+"!");
          424  +}
   395    425         Variable var_ptr = name_obj_ptr.varValue_GetVarPtr();
   396    426   
   397    427         result_var_ptr.add(var_ptr);
   398    428         if (!no_trace) {
   399    429           handleVariableTrace(name_obj_ptr, null, TRACE_OP_READ, "read", var_ptr);
   400    430         }
   401    431         if (var_ptr.link_frame_ptr == null) {
   402         -//print("getVariable3!"+"@@@"+var_ptr.obj_ptr+"!");
          432  +if (dbg != 0) {
          433  +print("getVariable3!"+"@@@"+var_ptr.obj_ptr+"!");
          434  +}
   403    435           return var_ptr.obj_ptr;
   404    436         } else {
   405    437   //print("getVariable4!");
   406    438           ApwtclObj obj_ptr;
   407    439   
   408    440           /* The variable is a link? Resolve it. */
   409    441           CallFrame saved_call_frame = interp.frame_ptr;
................................................................................
   420    452         break;
   421    453   
   422    454       case TOKEN_VAR_ARRAY_NAME:
   423    455   //print("+++getVariable2array!"+name_obj_ptr+"!");
   424    456         /* ARRAY. */
   425    457         return interp.array_obj_type.arrayGet(name_obj_ptr, flags, result_var_ptr);
   426    458       }
   427         -//print("getVariable not ok!"+name_obj_ptr+"!");
          459  +if (dbg != 0) {
          460  +print("getVariable not ok!"+name_obj_ptr+"!");
          461  +}
   428    462       if ((flags & FUNCTION_FLAGS_LEAVE_ERR_MSG) != 0) {
   429    463         interp.setResultString("can't read \""+name_obj_ptr.getString()+"\": no such variable");
   430    464       }
   431    465       result_var_ptr.add(null);
   432    466       return null;
   433    467     }
   434    468   
................................................................................
  1191   1225         if (entry != null) {
  1192   1226           ns_ptr = entry;
  1193   1227         } else {
  1194   1228           if ((flags & NAMESPACE_CREATE_IF_UNKNOWN) != 0) {
  1195   1229             CallFrame frame_ptr = interp.frame_ptr.newCallFrame(/* call_type */ CALL_TYPE_NAMESPACE, interp.frame_ptr);
  1196   1230             ArrayList<CallFrame> frame_ptr_ptr = new ArrayList<CallFrame>();
  1197   1231             frame_ptr_ptr.add(frame_ptr);
         1232  +//print("variableObjType getNamespaceForQualName PUSF");
  1198   1233             interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, ns_ptr, /* call_type */ CALL_TYPE_NAMESPACE);
  1199   1234             ns_ptr = interp.namespace_obj_type.createNamespace(ns_name);
  1200   1235             interp.namespace_obj_type.popStackFrame();
  1201   1236             if (ns_ptr == null) {
  1202   1237               panic(true, "could not create namespace '"+ns_name+"'");
  1203   1238             }
  1204   1239           } else {  /* namespace not found and was not created */
................................................................................
  1470   1505      *----------------------------------------------------------------------
  1471   1506      */
  1472   1507     public Variable lookupSimpleVar(ApwtclObj var_name_ptr, int flags, boolean create, ArrayList<String>err_msg_ptr, ArrayList<Integer> index_ptr) {
  1473   1508   if (variable_debug > 0) {
  1474   1509   print("lookupSimpleVar!"+var_name_ptr+"!cfr!"+interp.var_frame_ptr.toDebugString()+"!flags!"+flags+"!crp1!"+create+"!");
  1475   1510   print("FLAGS!"+getVarLookupTypeString(flags)+"!");
  1476   1511   }
         1512  +if (dbg != 0) {
         1513  +print("lookupSimpleVar!"+interp.var_frame_ptr+"!");
         1514  +}
  1477   1515       CallFrame var_frame_ptr = interp.var_frame_ptr;
  1478   1516       ArrayList<Object> var_obj_ptr = new ArrayList<Object>();
  1479   1517       Variable var_obj = null;
  1480   1518       Variable var_ptr = null;
  1481   1519       int result;
  1482   1520       Resolve res_ptr = null;
  1483   1521       ArrayList<Namespace> var_ns_ptr = null;
................................................................................
  1547   1585        *    3) the active frame was pushed to define the namespace context for a
  1548   1586        *       "namespace eval" or "namespace inscope" command,
  1549   1587        *    4) the name has namespace qualifiers ("::"s).
  1550   1588        * Otherwise, if var_name is a local variable, search in the call frame variables
  1551   1589        *
  1552   1590        * If create and the variable isn't found, create the variable
  1553   1591        */
         1592  +if (dbg != 0) {
         1593  +print("LL!"+((flags & (NAMESPACE_LOOKUP_GLOBAL_ONLY | NAMESPACE_LOOKUP_NAMESPACE_ONLY)) != 0)+"!"+!var_frame_ptr.hasLocalVars()+"!"+var_name.matches("::.*")+"!");
         1594  +print("CF!"+var_frame_ptr+"!");
         1595  +}
  1554   1596       if (((flags & (NAMESPACE_LOOKUP_GLOBAL_ONLY | NAMESPACE_LOOKUP_NAMESPACE_ONLY)) != 0)
  1555   1597           || !var_frame_ptr.hasLocalVars()
  1556   1598           || var_name.matches("::.*")) {
  1557   1599         boolean look_global = ((flags & NAMESPACE_LOOKUP_GLOBAL_ONLY) != 0)
  1558   1600           || (ctx_ns_ptr == interp.global_ns_ptr)
  1559   1601           || ((var_name.charAt(0) == ':') && (var_name.charAt(1) == ':'));
  1560         -if (variable_debug > 1) {
         1602  +if (variable_debug > 1 || dbg != 0) {
  1561   1603   print("look_gobal!"+look_global+"!"+var_frame_ptr.hasLocalVars()+"!"+var_frame_ptr.toDebugString()+"!");
  1562   1604   }
  1563   1605         if (look_global) {
  1564   1606           index_ptr.add( -1);
  1565   1607           flags = (flags | NAMESPACE_LOOKUP_GLOBAL_ONLY) & ~NAMESPACE_LOOKUP_NAMESPACE_ONLY;
  1566   1608         } else {
  1567   1609           if ((flags & VAR_LOOKUP_AVOID_RESOLVERS) != 0) {

Changes to src/org/apwtcl/lang/pkgIndex.tcl.

     8      8   interp alias {} ::itcl::type {} ::itcl type
     9      9   interp alias {} ::itcl::macro {} ::itcl macro
    10     10   interp alias {} ::itcl::body {} ::itcl body
    11     11   interp alias {} ::itcl::mkmember {} ::itcl mkmember
    12     12   interp alias {} ::itcl::internal::classcget {} ::itcl internal classcget
    13     13   interp alias {} ::itcl::internal::classconfigure {} ::itcl internal classconfigure
    14     14   interp alias {} ::itcl::internal::classinstall {} ::itcl internal classinstall
           15  +interp alias {} ::itcl::internal::set {} ::itcl internal set
    15     16   package ifneeded itcl 4.0b6 {
    16     17       namespace eval ::itcl { # init
    17     18       }
    18     19       source [file join $dir itclParse.tcl]
    19     20       package provide itcl 4.0b6
    20     21   }
    21     22   
    22     23   package ifneeded tcltest 0.1 {
    23     24       namespace eval ::tcltest { # init
    24     25       }
    25     26       package provide tcltest 0.1
    26     27   }
    27     28