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 Unified Diffs Ignore Whitespace Patch

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

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
177
178
179
180
181
182
183

184
185
186
187
188
189
190
...
218
219
220
221
222
223
224

225

226
227
228
229
230
231
232
...
329
330
331
332
333
334
335



336
337
338
339
340
341
342
  public String mySelf() {
    String str = "CallFrame!"+id+"!";
    return str;
  } 
      
  /* ==================== toString ===================================== */
  public String toString() {
    return mySelf()+"!"+(ns_ptr == null ? "null" : ns_ptr.full_name)+"!type!"+getCallTypeString(type)+"!";
  }

  /* ==================== toDebugString ===================================== */
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    str.append("  ref_count: "+ref_count+"\n");
    str.append("  type: "+getCallTypeString(type)+"\n");
................................................................................
    /* -- Put the object into the live list -- */
    my_call_frame.prev_call_frame_ptr = null;
    my_call_frame.next_call_frame_ptr = live_call_frame_list;
    if (live_call_frame_list != null) {
      live_call_frame_list.prev_call_frame_ptr = my_call_frame;
    }
    live_call_frame_list = my_call_frame;

    return my_call_frame;
  }

  /* ==================== freeCallFrame ===================================== */
  /* Free an CallFrame. Actually call_frames are never freed, but
   * just moved to the free call_frames list, where they will be
   * reused by newCallFrame(). */
................................................................................
    CallFrame frame_ptr;
    String escaped_name;

//print("CFA!"+toDebugString()+"!");
//print("CF GetVariable!"+name+"!"+create+"!"+variables.get(name)+"!"+toDebugString()+"!");
//print("GEVFR!"+name+"!"+create+"!"+interp.var_frame_ptr.toDebugString()+"!");
    escaped_name = escapeKey(name);

//print("callframe getvariable type!"+getCallTypeString(type)+"!");

    switch (type) {
    case CALL_TYPE_MACROEXPAND: 
      var_ns_ptr = interp.var_frame_ptr.ns_ptr;
      if (interp.var_frame_ptr.variables.get(escaped_name) == null) {
        if (var_ns_ptr.variables.get(escaped_name) == null) {
          if (create) {
            var_ns_ptr.variables.put(escaped_name, new Variable(interp, name, "VAR_NAMESPACE_VAR VAR_UNDEFINED", this, null));
................................................................................
  /* ==================== setClassObject =============================================== */
  public void setClassObject(ItclObject class_object) {
    this.class_object = class_object;
  }

  /* ==================== hasLocalVars =============================================== */
  public boolean hasLocalVars() {



    if (type == CALL_TYPE_PROC) {
      return true;
    }
    return false;
  }
}








|







 







>







 







>
|
>







 







>
>
>







89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
...
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
...
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
  public String mySelf() {
    String str = "CallFrame!"+id+"!";
    return str;
  } 
      
  /* ==================== toString ===================================== */
  public String toString() {
    return mySelf()+(ns_ptr == null ? "null" : ns_ptr.full_name)+"!type!"+getCallTypeString(type)+"!";
  }

  /* ==================== toDebugString ===================================== */
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    str.append("  ref_count: "+ref_count+"\n");
    str.append("  type: "+getCallTypeString(type)+"\n");
................................................................................
    /* -- Put the object into the live list -- */
    my_call_frame.prev_call_frame_ptr = null;
    my_call_frame.next_call_frame_ptr = live_call_frame_list;
    if (live_call_frame_list != null) {
      live_call_frame_list.prev_call_frame_ptr = my_call_frame;
    }
    live_call_frame_list = my_call_frame;
//print("newCallFrame!"+my_call_frame.mySelf()+getCallTypeString(my_call_frame.type)+"!");
    return my_call_frame;
  }

  /* ==================== freeCallFrame ===================================== */
  /* Free an CallFrame. Actually call_frames are never freed, but
   * just moved to the free call_frames list, where they will be
   * reused by newCallFrame(). */
................................................................................
    CallFrame frame_ptr;
    String escaped_name;

//print("CFA!"+toDebugString()+"!");
//print("CF GetVariable!"+name+"!"+create+"!"+variables.get(name)+"!"+toDebugString()+"!");
//print("GEVFR!"+name+"!"+create+"!"+interp.var_frame_ptr.toDebugString()+"!");
    escaped_name = escapeKey(name);
if (interp.variable_obj_type.dbg != 0) {
print("callframe getvariable type!"+getCallTypeString(type)+"!");
}
    switch (type) {
    case CALL_TYPE_MACROEXPAND: 
      var_ns_ptr = interp.var_frame_ptr.ns_ptr;
      if (interp.var_frame_ptr.variables.get(escaped_name) == null) {
        if (var_ns_ptr.variables.get(escaped_name) == null) {
          if (create) {
            var_ns_ptr.variables.put(escaped_name, new Variable(interp, name, "VAR_NAMESPACE_VAR VAR_UNDEFINED", this, null));
................................................................................
  /* ==================== setClassObject =============================================== */
  public void setClassObject(ItclObject class_object) {
    this.class_object = class_object;
  }

  /* ==================== hasLocalVars =============================================== */
  public boolean hasLocalVars() {
if (interp.variable_obj_type.dbg != 0) {
print("call_type!"+getCallTypeString(CALL_TYPE_PROC));
}
    if (type == CALL_TYPE_PROC) {
      return true;
    }
    return false;
  }
}

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

80
81
82
83
84
85
86

87
88
89
90
91
92
93
94
..
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

  /* ==================== storeComponentInfo ================================== */
  public int storeComponentInfo(ArrayList<ApwtclObj> args) {
//print("storeComponentInfo!"+args+"!");
    int processed_args;
    int option_flags;
    ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();


    for (int i = 1; i < args.size(); i++) {
      my_args.add(args.get(i));
    }
//print("args!"+args+"!"+my_args+"!");
    command_option_list.resetOptionValues();
    if (command_option_list.parseOptions(my_args, 0, "itclComponent") != OK) {
//print("ERR!"+command_option_list.getErrorMsg()+"!");
................................................................................
    processed_args = command_option_list.getNumProcessedArgs();

    if (args.size() - processed_args > 0) {
      interp.setResultString("usage: component -public <typemethod>? ?-inherit ?<flag>?");
      return ERROR;
    }
    if ((option_flags & COMPONENT_OPTION_INHERIT) != 0) {
//      if (options.get("-inherit") != null) {
//        if (interp.int_obj_type.getBool(options.get("-inherit"), val) != OK) {
//          return ERROR;
//        }
//      } else {
//        if (interp.int_obj_type.getBool(interp.string_obj_type.newStringObj("1", -1, "ITCL_COMPONENT_1"), val) != OK) {
//          return ERROR;
//        }
//      }
        /* FIXME may have value here !! */
//        flag_inherit = val.get(0);
        flag_inherit = true;
    }
    if ((option_flags & COMPONENT_OPTION_PUBLIC) != 0) {
      /* FIXME ned to get value here !! */
      // flag_public = options.get("-public");
      flag_public = true;
    }
    return OK;
  }
}







>
|







 







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|




80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

  /* ==================== storeComponentInfo ================================== */
  public int storeComponentInfo(ArrayList<ApwtclObj> args) {
//print("storeComponentInfo!"+args+"!");
    int processed_args;
    int option_flags;
    ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
    ArrayList<Boolean> bool_ptr = new ArrayList<Boolean>();
    
    for (int i = 1; i < args.size(); i++) {
      my_args.add(args.get(i));
    }
//print("args!"+args+"!"+my_args+"!");
    command_option_list.resetOptionValues();
    if (command_option_list.parseOptions(my_args, 0, "itclComponent") != OK) {
//print("ERR!"+command_option_list.getErrorMsg()+"!");
................................................................................
    processed_args = command_option_list.getNumProcessedArgs();

    if (args.size() - processed_args > 0) {
      interp.setResultString("usage: component -public <typemethod>? ?-inherit ?<flag>?");
      return ERROR;
    }
    if ((option_flags & COMPONENT_OPTION_INHERIT) != 0) {
      int option_has_value = command_option_list.optionHasValue("-inherit");
      if (option_has_value != OPTION_HAS_NO_VALUE) {
        if (interp.int_obj_type.getBool(command_option_list.getOptionValue(COMPONENT_OPTION_INHERIT).get(0), bool_ptr) != OK) {
          return ERROR;
        }
      } else {
        if (interp.int_obj_type.getBool(interp.string_obj_type.newStringObj("1", -1, "ITCL_COMPONENT_1"), bool_ptr) != OK) {
          return ERROR;
        }
      }
      flag_inherit = bool_ptr.get(0);
    }
    if ((option_flags & COMPONENT_OPTION_PUBLIC) != 0) {
      if (interp.int_obj_type.getBool(command_option_list.getOptionValue(COMPONENT_OPTION_PUBLIC).get(0), bool_ptr) != OK) {
        return ERROR;
      }
      flag_public = bool_ptr.get(0);
    }
    return OK;
  }
}

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

129
130
131
132
133
134
135

136
137
138
139
140
141
142

//print("initItclObject!"+toDebugString()+"!");
    /* add to class instances */
    my_obj_ptr = interp.string_obj_type.newStringObj(object_name, -1, "ITCL_OBJECT_1");
    my_obj_ptr.incrRefCount("I_ITCL_OBJECT_1");
    class_info.instances.add(my_obj_ptr);
    /* Create a new call frame */

    ret_code = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, class_info.ns_ptr, CALL_TYPE_PROC);
    if (ret_code != OK) {
      return ERROR;
    }
    interp.frame_ptr.class_object = this;
    this_variable = new Variable(interp, "this", "VAR_THIS_VAR", null, class_info.ns_ptr);
    this_variable.setProtection(PROTECTION_PROTECTED);







>







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143

//print("initItclObject!"+toDebugString()+"!");
    /* add to class instances */
    my_obj_ptr = interp.string_obj_type.newStringObj(object_name, -1, "ITCL_OBJECT_1");
    my_obj_ptr.incrRefCount("I_ITCL_OBJECT_1");
    class_info.instances.add(my_obj_ptr);
    /* Create a new call frame */
print("initItclObject PUSF");
    ret_code = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, class_info.ns_ptr, CALL_TYPE_PROC);
    if (ret_code != OK) {
      return ERROR;
    }
    interp.frame_ptr.class_object = this;
    this_variable = new Variable(interp, "this", "VAR_THIS_VAR", null, class_info.ns_ptr);
    this_variable.setProtection(PROTECTION_PROTECTED);

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

152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170

171
172
173
174
175
176

177
178
179
180
181
182
183
184
    int processed_args;
    int option_flags;
    ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();

    for (int i = 1; i < args.size(); i++) {
      my_args.add(args.get(i));
    }
//print("args!"+args+"!"+my_args+"!");
    command_option_list.resetOptionValues();
    if (command_option_list.parseOptions(my_args, 0, "itclOption") != OK) {
//print("ERR!"+command_option_list.getErrorMsg()+"!");
      interp.setResultString(command_option_list.getErrorMsg());
      return ERROR;
    }
    option_flags = command_option_list.getOptionFlags();
    processed_args = command_option_list.getNumProcessedArgs();
//print("storOption2!"+args.size()+"!"+processed_args);
    if (args.size() - 1 != processed_args) {
      interp.setResultString("usage: option ?option value ...? ?result?");

      return ERROR;
    }
    /* take care of command as args[0] */
    processed_args++;
    if ((option_flags & ITCL_OPTION_READONLY) != 0) {
      if (interp.int_obj_type.getBool(command_option_list.getOptionValue(ITCL_OPTION_READONLY).get(0), bool_ptr) != OK) {

        return ERROR;
      }
      read_only = bool_ptr.get(0);
    }
    if ((option_flags & ITCL_OPTION_DEFAULT) != 0) {
      default_value = command_option_list.getOptionValue(ITCL_OPTION_DEFAULT).get(0);
    }
    if ((option_flags & ITCL_OPTION_CGET_METHOD) != 0) {







|


|





|


>






>
|







152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
    int processed_args;
    int option_flags;
    ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();

    for (int i = 1; i < args.size(); i++) {
      my_args.add(args.get(i));
    }
print("args!"+args+"!"+my_args+"!");
    command_option_list.resetOptionValues();
    if (command_option_list.parseOptions(my_args, 0, "itclOption") != OK) {
print("ERR!"+command_option_list.getErrorMsg()+"!");
      interp.setResultString(command_option_list.getErrorMsg());
      return ERROR;
    }
    option_flags = command_option_list.getOptionFlags();
    processed_args = command_option_list.getNumProcessedArgs();
print("storeOption2!"+args.size()+"!"+processed_args);
    if (args.size() - 1 != processed_args) {
      interp.setResultString("usage: option ?option value ...? ?result?");
print("storeopt err2");
      return ERROR;
    }
    /* take care of command as args[0] */
    processed_args++;
    if ((option_flags & ITCL_OPTION_READONLY) != 0) {
      if (interp.int_obj_type.getBool(command_option_list.getOptionValue(ITCL_OPTION_READONLY).get(0), bool_ptr) != OK) {
print("storeopt err3");
    	 return ERROR;
      }
      read_only = bool_ptr.get(0);
    }
    if ((option_flags & ITCL_OPTION_DEFAULT) != 0) {
      default_value = command_option_list.getOptionValue(ITCL_OPTION_DEFAULT).get(0);
    }
    if ((option_flags & ITCL_OPTION_CGET_METHOD) != 0) {

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

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

130
131
132
133

134

135
136
137
138

139

140
141
142
143

144

145
146
147
148

149

150
151
152
153
154
155
156
  public String mySelf() {
    String str = "Namespace!"+id+"!";
    return str;
  } 
      
  /* ==================== toString ===================================== */
  public String toString() {
    return mySelf()+"!"+full_name+"!class_type!"+getItclClassTypeString(class_type)+"!";
  }

  /* ==================== toDebugString ===================================== */
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    str.append("  name: "+name+"\n");
    str.append("  full_name: "+full_name+"\n");
    str.append("  class_type: "+getItclClassTypeString(class_type)+"\n");
    str.append("  command_resolver: "+command_resolver+"\n");
    str.append("  variable_resolver: "+variable_resolver+"\n");
    str.append("  macro_resolver: "+macro_resolver+"\n");

    ArrayList<String> a1 = new ArrayList<String>();
    for (String z: variables.keySet()) {
      a1.add(z);
    }

    str.append("  variables: "+a1.toString()+"\n");

    ArrayList<String> a2 = new ArrayList<String>();
    for (String z: cmd_procs.keySet()) {
      a2.add(z);
    }

    str.append("  cmd_procs: "+a2+"\n");

    ArrayList<String> a3 = new ArrayList<String>();
    for (String z: resolve_variables.keySet()) {
      a3.add(z);
    }

    str.append("  resolve_variables: "+a3+"\n");

    ArrayList<String> a4 = new ArrayList<String>();
    for (String z: resolve_commands.keySet()) {
      a4.add(z);
    }

    str.append("  resolve_commands: "+a4.toString()+"\n");

    str.append("  children: "+children.keySet()+"\n");
    return str.toString();
  }

  /* ==================== getName ===================================== */
  public String getName() {
    return name;







|











>




>

>




>

>




>

>




>

>







111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
  public String mySelf() {
    String str = "Namespace!"+id+"!";
    return str;
  } 
      
  /* ==================== toString ===================================== */
  public String toString() {
    return mySelf()+full_name+"!class_type!"+getItclClassTypeString(class_type);
  }

  /* ==================== toDebugString ===================================== */
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    str.append("  name: "+name+"\n");
    str.append("  full_name: "+full_name+"\n");
    str.append("  class_type: "+getItclClassTypeString(class_type)+"\n");
    str.append("  command_resolver: "+command_resolver+"\n");
    str.append("  variable_resolver: "+variable_resolver+"\n");
    str.append("  macro_resolver: "+macro_resolver+"\n");

    ArrayList<String> a1 = new ArrayList<String>();
    for (String z: variables.keySet()) {
      a1.add(z);
    }
    Collections.sort(a1);
    str.append("  variables: "+a1.toString()+"\n");

    ArrayList<String> a2 = new ArrayList<String>();
    for (String z: cmd_procs.keySet()) {
      a2.add(z);
    }
    Collections.sort(a2);
    str.append("  cmd_procs: "+a2+"\n");

    ArrayList<String> a3 = new ArrayList<String>();
    for (String z: resolve_variables.keySet()) {
      a3.add(z);
    }
    Collections.sort(a3);
    str.append("  resolve_variables: "+a3+"\n");

    ArrayList<String> a4 = new ArrayList<String>();
    for (String z: resolve_commands.keySet()) {
      a4.add(z);
    }
    Collections.sort(a4);
    str.append("  resolve_commands: "+a4.toString()+"\n");
    
    str.append("  children: "+children.keySet()+"\n");
    return str.toString();
  }

  /* ==================== getName ===================================== */
  public String getName() {
    return name;

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

351
352
353
354
355
356
357

358
359
360
361
362
363
364
//print("BDY!"+test_obj.mySelf()+"!"+body+"!");
//print("BDY!"+test_obj.mySelf()+"!"+test_name+"!");

    /* Create a new call frame */
    ArrayList<CallFrame> frame_ptr_ptr = new ArrayList<CallFrame>();
    ApwtclObj result;
    try {

      ret_code = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, interp.global_ns_ptr, CALL_TYPE_NAMESPACE);
    } catch(Exception e) {
print("TERR!"+e+"!");
    }
    if (ret_code != OK) {
      return ERROR;
    }







>







351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
//print("BDY!"+test_obj.mySelf()+"!"+body+"!");
//print("BDY!"+test_obj.mySelf()+"!"+test_name+"!");

    /* Create a new call frame */
    ArrayList<CallFrame> frame_ptr_ptr = new ArrayList<CallFrame>();
    ApwtclObj result;
    try {
print("tcltest runTest PUSF");
      ret_code = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, interp.global_ns_ptr, CALL_TYPE_NAMESPACE);
    } catch(Exception e) {
print("TERR!"+e+"!");
    }
    if (ret_code != OK) {
      return ERROR;
    }

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

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

  /* ==================== initSubCmds ================================== */
  public int initSubCmds(Interp interp) {
//print("itcl initSubCmds called"+interp+"!");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "body", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "class", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "delete", "ItclCommand");
//    interp.command_obj_type.registerNativeSubCommand("::itcl", "expandmacro", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "extendedclass", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "macro", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "mkmember", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "type", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "widget", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "widgetadaptor", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "set", "ItclCommand");
//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classinfo", "ItclCommand");
//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classcget", "ItclCommand");
//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classconfigure", "ItclCommand");
//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classconfigurelist", "ItclCommand");
//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classdestroy", "ItclCommand");
//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classinstall", "ItclCommand");
//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classinstallhull", "ItclCommand");
//    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "classisa", "ItclCommand");

    interp.command_obj_type.registerNativeCommand("::itcl::expandmacro", "ItclCommand", true);
    interp.command_obj_type.registerNativeCommand("::itcl::internal::classinfo", "ItclCommand", true);
    interp.command_obj_type.registerNativeCommand("::itcl::internal::classcget", "ItclCommand", true);
    interp.command_obj_type.registerNativeCommand("::itcl::internal::classconfigure", "ItclCommand", true);
    interp.command_obj_type.registerNativeCommand("::itcl::internal::classconfigurelist", "ItclCommand", true);
    interp.command_obj_type.registerNativeCommand("::itcl::internal::classdestroy", "ItclCommand", true);







<







<
<
<
<
<
<
<
<







34
35
36
37
38
39
40

41
42
43
44
45
46
47








48
49
50
51
52
53
54

  /* ==================== initSubCmds ================================== */
  public int initSubCmds(Interp interp) {
//print("itcl initSubCmds called"+interp+"!");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "body", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "class", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "delete", "ItclCommand");

    interp.command_obj_type.registerNativeSubCommand("::itcl", "extendedclass", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "macro", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "mkmember", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "type", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "widget", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl", "widgetadaptor", "ItclCommand");
    interp.command_obj_type.registerNativeSubCommand("::itcl internal", "set", "ItclCommand");









    interp.command_obj_type.registerNativeCommand("::itcl::expandmacro", "ItclCommand", true);
    interp.command_obj_type.registerNativeCommand("::itcl::internal::classinfo", "ItclCommand", true);
    interp.command_obj_type.registerNativeCommand("::itcl::internal::classcget", "ItclCommand", true);
    interp.command_obj_type.registerNativeCommand("::itcl::internal::classconfigure", "ItclCommand", true);
    interp.command_obj_type.registerNativeCommand("::itcl::internal::classconfigurelist", "ItclCommand", true);
    interp.command_obj_type.registerNativeCommand("::itcl::internal::classdestroy", "ItclCommand", true);

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

538
539
540
541
542
543
544

545
546
547
548
549
550
551
      namespace_ptr = namespace_ptr_ptr.get(0);
    }
    /*
     * Make the specified namespace the current namespace and evaluate the
     * command(s).
     */
    frame_ptr_ptr = new ArrayList<CallFrame>();

    result = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, namespace_ptr, /*isProcCallFrame*/ 0);
    if (result != OK) {
      return ERROR;
    }
if (false) {
//    if (namesp.interp.ensembleRewrite.source_objs == null) {
//      frame_ptr.objc = args.length;







>







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

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

86
87
88
89
90
91
92
93


94
95
96
97
98
99
100
    }
    ApwtclObj package_name = args.get(1);
    ApwtclObj package_version = args.get(2);
    ApwtclObj script = null;
    if (args.size() > 3) {
      script = args.get(3);
    }
    return interp.package_obj_type.setPackageScript(package_name, package_version, script, FUNCTION_FLAGS_LEAVE_ERR_MSG);


  }

  /* ==================== packageNamesCmd ===================================== */
  public int packageNamesCmd(Interp interp, ArrayList<ApwtclObj> args) {
print("package names called");
    if (args.size() != 2 && args.size() != 3) {
      interp.wrongNumArgs(1, args, "package ?version?");







|
>
>







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
    }
    ApwtclObj package_name = args.get(1);
    ApwtclObj package_version = args.get(2);
    ApwtclObj script = null;
    if (args.size() > 3) {
      script = args.get(3);
    }
    int ret = interp.package_obj_type.setPackageScript(package_name, package_version, script, FUNCTION_FLAGS_LEAVE_ERR_MSG);
//print("package ifneeded end");
    return ret;
  }

  /* ==================== packageNamesCmd ===================================== */
  public int packageNamesCmd(Interp interp, ArrayList<ApwtclObj> args) {
print("package names called");
    if (args.size() != 2 && args.size() != 3) {
      interp.wrongNumArgs(1, args, "package ?version?");

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

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
470
471
472

473
474
475
476
477
478
479
...
515
516
517
518
519
520
521

522
523
524
525

526
527
528
529
530
531
532
//print("FR!"+intp.frame_ptr.toDebugString()+"!"+intp.max_nesting_depth+"!");
    if (interp.frame_ptr.level == interp.max_nesting_depth) {
      interp.setResultString("Too many nested calls. Infinite recursion?");
      return ERROR;
    }
    /* Create a new call frame */
    ArrayList<CallFrame> frame_ptr_ptr = new ArrayList<CallFrame>();

    int result = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, cmd_ptr.ns_ptr, CALL_TYPE_PROC);
    if (result != OK) {
      return ERROR;
    }
    call_frame_ptr = frame_ptr_ptr.get(0);
    call_frame_ptr.argv = argv;
    call_frame_ptr.argc = argc;
................................................................................
    call_frame_ptr.proc_args_obj_ptr = cmd_ptr.proc.arg_list_obj_ptr;
    call_frame_ptr.proc_body_obj_ptr = cmd_ptr.proc.body_obj_ptr;
    call_frame_ptr.static_vars = cmd_ptr.proc.static_vars;
    call_frame_ptr.file_name_obj = file_name_obj;
    call_frame_ptr.line = line_no;
    cmd_ptr.proc.arg_list_obj_ptr.incrRefCount("I_COMMAND_OBJ_TYPE_5");
    cmd_ptr.proc.body_obj_ptr.incrRefCount("I_COMMAND_OBJ_TYPE_6");

    interp.frame_ptr = call_frame_ptr;
    /* Install a new stack for local procs */
    prev_local_procs = interp.local_procs;
    interp.local_procs = null;
    /* How many optional args are available */
    optargs = (argc - 1 - param_info.req_arity);
    /* Step 'i' along the actual args, and step 'd' along the formal args */

    i = 1;
    for (d = 0; d < param_info.arg_list.size(); d++) {
      ApwtclObj name_obj_ptr = param_info.arg_list.get(d).name_obj_ptr;

      if (d == param_info.args_pos) {
        /* assign $args */
        ApwtclObj list_obj_ptr = null;
................................................................................
      if (retcode != OK) {
        bad_arg_set = true;
        break;
      }
    }
    if (!bad_arg_set) {
      /* Eval the body */

      retcode = interp.eval_statement.evalObj(cmd_ptr.proc.body_obj_ptr);
    }

    /* Destroy the call frame */

    interp.namespace_obj_type.popStackFrame();
//    if (callFramePtr.vars.size != JIM_HT_INITIAL_SIZE) {
//        JimFreeCallFrame(interp, callFramePtr, JIM_FCF_NONE);
//    } else {
//        JimFreeCallFrame(interp, callFramePtr, JIM_FCF_NOHT);
//    }
    /* Handle the EVAL return code */







>







 







>







>







 







>




>







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
470
471
472
473
474
475
476
477
478
479
480
481
482
...
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
//print("FR!"+intp.frame_ptr.toDebugString()+"!"+intp.max_nesting_depth+"!");
    if (interp.frame_ptr.level == interp.max_nesting_depth) {
      interp.setResultString("Too many nested calls. Infinite recursion?");
      return ERROR;
    }
    /* Create a new call frame */
    ArrayList<CallFrame> frame_ptr_ptr = new ArrayList<CallFrame>();
//print("commandObjType callProcedure PUSF!"+cmd_ptr+"!"+interp.frame_ptr+"!"+interp.var_frame_ptr+"!"+argv+"!");
    int result = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, cmd_ptr.ns_ptr, CALL_TYPE_PROC);
    if (result != OK) {
      return ERROR;
    }
    call_frame_ptr = frame_ptr_ptr.get(0);
    call_frame_ptr.argv = argv;
    call_frame_ptr.argc = argc;
................................................................................
    call_frame_ptr.proc_args_obj_ptr = cmd_ptr.proc.arg_list_obj_ptr;
    call_frame_ptr.proc_body_obj_ptr = cmd_ptr.proc.body_obj_ptr;
    call_frame_ptr.static_vars = cmd_ptr.proc.static_vars;
    call_frame_ptr.file_name_obj = file_name_obj;
    call_frame_ptr.line = line_no;
    cmd_ptr.proc.arg_list_obj_ptr.incrRefCount("I_COMMAND_OBJ_TYPE_5");
    cmd_ptr.proc.body_obj_ptr.incrRefCount("I_COMMAND_OBJ_TYPE_6");
//print("commandObjType callProcedure evalObj0!"+interp.frame_ptr+"!"+interp.var_frame_ptr+"!");
    interp.frame_ptr = call_frame_ptr;
    /* Install a new stack for local procs */
    prev_local_procs = interp.local_procs;
    interp.local_procs = null;
    /* How many optional args are available */
    optargs = (argc - 1 - param_info.req_arity);
    /* Step 'i' along the actual args, and step 'd' along the formal args */
//print("commandObjType callProcedure evalObj1!"+cmd_ptr+"!"+interp.frame_ptr+"!"+interp.var_frame_ptr+"!");
    i = 1;
    for (d = 0; d < param_info.arg_list.size(); d++) {
      ApwtclObj name_obj_ptr = param_info.arg_list.get(d).name_obj_ptr;

      if (d == param_info.args_pos) {
        /* assign $args */
        ApwtclObj list_obj_ptr = null;
................................................................................
      if (retcode != OK) {
        bad_arg_set = true;
        break;
      }
    }
    if (!bad_arg_set) {
      /* Eval the body */
//print("commandObjType callProcedure evalObj!"+cmd_ptr+"!"+interp.frame_ptr+"!"+interp.var_frame_ptr+"!");
      retcode = interp.eval_statement.evalObj(cmd_ptr.proc.body_obj_ptr);
    }

    /* Destroy the call frame */
//print("commandObjType callProcedure POSF!");
    interp.namespace_obj_type.popStackFrame();
//    if (callFramePtr.vars.size != JIM_HT_INITIAL_SIZE) {
//        JimFreeCallFrame(interp, callFramePtr, JIM_FCF_NONE);
//    } else {
//        JimFreeCallFrame(interp, callFramePtr, JIM_FCF_NOHT);
//    }
    /* Handle the EVAL return code */

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

228
229
230
231
232
233
234

235

236
237
238
239
240
241
242
...
350
351
352
353
354
355
356

357
358
359
360

361
362
363
364

365
366
367

368

369
370
371
372
373
374
375
...
669
670
671
672
673
674
675

676
677
678
679
680
681
682
     * public variables go directly to the class namespace
     */
    String var_namespace = "::itcl::internal::variables"+full_class_name;
    class_info.variable_namespace = interp.namespace_obj_type.createNamespace(var_namespace);
    Namespace parse_ns_ptr = interp.variable_obj_type.findNamespace("::itcl::classdefs", interp.global_ns_ptr, NAMESPACE_CREATE_IF_UNKNOWN);
    parse_ns_ptr.setMacroResolver(new Resolve(interp, RESOLVER_TYPE_MACRO));
    ArrayList<CallFrame> frame_ptr = new ArrayList<CallFrame>();

    interp.namespace_obj_type.pushStackFrame(frame_ptr, parse_ns_ptr, CALL_TYPE_EVAL);

    ret_code = interp.eval_statement.evalObj(obj_ptr);
    interp.namespace_obj_type.popStackFrame();
    if (ret_code == OK) {
      /*
       *  At this point, parsing of the class definition has succeeded.
       *  Add built-in methods such as "configure" and "cget"--as long
       *  as they don't conflict with those defined in the class.
................................................................................
      ItclFunction fcn_info = new ItclFunction(interp, protection, kind_val, my_name, class_info);
      if (fcn_info.storeFunctionInfo(my_args) != OK) {
        return ERROR;
      }
      interp.curr_class_info.functions.put(escapeKey(my_name), fcn_info);
      break;
    case ITCL_OPTION:

      if (interp.curr_class_info.options.get(escapeKey(my_name)) != null) {
        interp.setResultString(kind+" "+my_name+" is already defined for "+getItclClassTypeString(class_info.class_type)+" \""+class_info.class_name+"\"");
        return ERROR;
      }

      ItclOption opt_info = new ItclOption(interp, protection, kind_val, my_name_ptr, class_info);
      if (opt_info == null) {
        return ERROR;
      }

      if (opt_info.storeOptionInfo(my_args) != OK) {
          return ERROR;
      }

      interp.curr_class_info.options.put(escapeKey(opt_info.option_name), opt_info);

      break;
    case ITCL_COMPONENT:
    case ITCL_TYPECOMPONENT:
      if (interp.curr_class_info.components.get(escapeKey(my_name)) != null) {
        interp.setResultString(kind+" "+my_name+" is already defined for "+getItclClassTypeString(class_info.class_type)+" \""+class_info.class_name+"\"");
        return ERROR;
      }
................................................................................
//print("cmd_obj4!"+cmd_obj.toDebugString()+"!");
      if (cmd_obj.is_proc) {
//        ret_code = (Integer)cmd_obj.call(interp, my_args, /* ensemble_expand */ true);
        ret_code = interp.command_obj_type.callProcedure(cmd_obj, null, 0, my_args.size(), my_args);
      } else {
        /* Create a new call frame */
        ArrayList<CallFrame>frame_ptr_ptr = new ArrayList<CallFrame>();

        int result = interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, ns_ptr, CALL_TYPE_PROC);
        if (result != OK) {
          return ERROR;
        }
        /* Check if there are too nested calls */
//print("FR!"+i_obj.intp.frame_ptr.toDebugString()+"!"+i_obj.interp.max_nesting_depth+"!");
        interp.cmd_priv_data = cmd_obj.native_fcn.privdata;







>

>







 







>




>




>



>

>







 







>







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

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

251
252
253
254
255
256
257


258
259
260
261
262
263
264
...
387
388
389
390
391
392
393

394
395
396
397
398
399
400
   *      Modifies the interpreter's RAPL call stack.
   *
   *----------------------------------------------------------------------
   */
  public int pushCallFrame(CallFrame frame_ptr, Namespace namespace_ptr, int call_type) {
    Namespace ns_ptr;



    if (namespace_ptr == null) {
      ns_ptr = getCurrentNamespace();
    } else {
      ns_ptr = namespace_ptr;
        /*
         * TODO: Examine whether it would be better to guard based on NAMESPACE_DYING
         * or NAMESPACE_KILLED. It appears that these are not tested because they can
................................................................................
   *----------------------------------------------------------------------
   */
  public int pushStackFrame(ArrayList<CallFrame> frame_ptr, Namespace namespace_ptr, int call_type) {
//if (call_type == 0)  {
//print("ERROR pushStackFrame calltype 0!"+frame_ptr+"!"+namespace_ptr+"!");
//}
    frame_ptr.add(interp.frame_ptr.newCallFrame(call_type, interp.frame_ptr));

    return pushCallFrame(frame_ptr.get(0), namespace_ptr, call_type);
  }

  /* ==================== popStackFrame ===================================== */
  public void popStackFrame() {
//    var free_ptr = interp.eval_statement.curr_call_frame;








>
>







 







>







251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
...
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
   *      Modifies the interpreter's RAPL call stack.
   *
   *----------------------------------------------------------------------
   */
  public int pushCallFrame(CallFrame frame_ptr, Namespace namespace_ptr, int call_type) {
    Namespace ns_ptr;

//print("PUCF!"+namespace_ptr+"!"+getCallTypeString(call_type)+"!");
//print("VARCF!"+interp.var_frame_ptr+"!"+interp.frame_ptr+"!");
    if (namespace_ptr == null) {
      ns_ptr = getCurrentNamespace();
    } else {
      ns_ptr = namespace_ptr;
        /*
         * TODO: Examine whether it would be better to guard based on NAMESPACE_DYING
         * or NAMESPACE_KILLED. It appears that these are not tested because they can
................................................................................
   *----------------------------------------------------------------------
   */
  public int pushStackFrame(ArrayList<CallFrame> frame_ptr, Namespace namespace_ptr, int call_type) {
//if (call_type == 0)  {
//print("ERROR pushStackFrame calltype 0!"+frame_ptr+"!"+namespace_ptr+"!");
//}
    frame_ptr.add(interp.frame_ptr.newCallFrame(call_type, interp.frame_ptr));
//print("PUSF!"+frame_ptr.get(0).mySelf()+namespace_ptr+"!"+getCallTypeString(call_type)+"!");
    return pushCallFrame(frame_ptr.get(0), namespace_ptr, call_type);
  }

  /* ==================== popStackFrame ===================================== */
  public void popStackFrame() {
//    var free_ptr = interp.eval_statement.curr_call_frame;

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

51
52
53
54
55
56
57

58
59
60
61
62
63
64
...
133
134
135
136
137
138
139



140



141

142

143
144
145
146
147
148
149
...
173
174
175
176
177
178
179






180
181

182



183
184
185
186
187
188
189
...
196
197
198
199
200
201
202

203

204
205
206
207
208
209
210
...
216
217
218
219
220
221
222

223

224
225
226
227
228
229
230
...
234
235
236
237
238
239
240



241
242
243
244
245
246
247
...
381
382
383
384
385
386
387

388

389
390
391
392
393

394

395
396
397
398
399
400
401

402

403
404
405
406
407
408
409
...
420
421
422
423
424
425
426

427

428
429
430
431
432
433
434
....
1191
1192
1193
1194
1195
1196
1197

1198
1199
1200
1201
1202
1203
1204
....
1470
1471
1472
1473
1474
1475
1476



1477
1478
1479
1480
1481
1482
1483
....
1547
1548
1549
1550
1551
1552
1553




1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
  private static final int LOOKUP_MSG_MISSING_NAME = 128;
  public static final int LOOKUP_MSG_IS_ARRAY_ELEMENT = 256;

  private int id;
  private Interp interp;
  public int variable_debug;
  public boolean no_trace;


  /* ==================== VariableObjType ================================== */
  public VariableObjType(Interp interp) {
    oid++;
    id = oid;

    this.interp = interp;
................................................................................
      return TOKEN_VAR_ARRAY_NAME;
    }
//print("varobjtype sFA 3");
    ApwtclObj part1_ptr = interp.string_obj_type.newStringObj(var_name, -1, "VARIABLE_OBJ_TYPE_1");
    part1_ptr.incrRefCount("I_VARIABLE_OBJ_TYPE_1");
    ArrayList<String> lookup_err_msg_ptr = new ArrayList<String>();
    ArrayList<Integer> lookup_index_ptr = new ArrayList<Integer>();



    Variable var_obj_ptr = lookupSimpleVar(part1_ptr, FUNCTION_FLAGS_LEAVE_ERR_MSG, /* create_part1 */ false, lookup_err_msg_ptr, lookup_index_ptr);



    part1_ptr.decrRefCount("D_VARIABLE_OBJ_TYPE_1");

//print("varobjtype sFA 4!"+var_obj_ptr+"!"+frame_ptr.ns_ptr+"!");

    if (var_obj_ptr == null) {
      err_msg_ptr_ptr.add(lookup_err_msg_ptr.get(0));
      return ERROR;
    }
    err_msg_ptr_ptr.add(null);
    /* Free the old internal repr and set the new one. */
    obj_ptr.freeIntRep();
................................................................................

  public int setVariable(ApwtclObj name_obj_ptr, ApwtclObj val_obj_ptr, ArrayList<Variable> result_var_ptr) {
    String name;
    Variable var_ptr;
    boolean create = true;
    int err;
    ArrayList<String> err_msg_ptr = new ArrayList<String>();






//print("setVariable1!"+name_obj_ptr+"!");


    if ((err = setFromAny(name_obj_ptr, err_msg_ptr)) != OK) {



//print("setVariable2 not OK!"+err_msg_ptr+"!");
      CallFrame frame_ptr = interp.frame_ptr;

      /* Check for array names like syntax. */
      if (err == TOKEN_VAR_ARRAY_NAME) {
//print("setVariable2a!"+name_obj_ptr+"!"+interp.frame_ptr.ns_ptr+"!");
        int ret = interp.array_obj_type.arraySet(name_obj_ptr, val_obj_ptr, result_var_ptr);
................................................................................
      }
      /* if we did not find the variable it cannot be a namespace variable
       * as namespace variables are created with VAR_UNDEFINED, if not initialized
       * if err_msg_ptr is null
       * only exception global variables starting with :: like ::abc need
       * special handling here
       */

//print("setVariable3!"+name_obj_ptr.getString()+"!"+err_msg_ptr+"!");

      String err_msg = err_msg_ptr.get(0);
      if (err_msg_ptr != null) {
        String my_name = name_obj_ptr.getString();
        if (my_name.indexOf("::") >= 0) {
          if (my_name.substring(2).indexOf("::") > 0) {
            interp.setResultString(err_msg);
            result_var_ptr.add(null);
................................................................................
      /* New variable to create */
      // FIXME need to get tail of variable name here !!
      name = name_obj_ptr.getString();
      if (name.charAt(0) == ':' && name.charAt(1) == ':') {
        name = name.substring(2);
      }
      var_ptr = frame_ptr.getVariable(name, create);

//print("setVariable a!"+name+"!"+var_ptr+"!"+create+"!"+interp.frame_ptr.ns_ptr+"!");      

//print("SEV!"+name+"!"+frame_ptr.variables.get(name)+"!"+interp.var_frame_ptr.variables.get(name)+"!"+frame_ptr.toDebugString()+"!"+interp.var_frame_ptr.toDebugString()+"!");
      result_var_ptr.add(var_ptr);
      var_ptr.obj_ptr = val_obj_ptr;
      val_obj_ptr.incrRefCount("I_VARIABLE_OBJ_TYPE_2");
      var_ptr.link_frame_ptr = null;
      /* Make the object int rep a variable */
      name_obj_ptr.freeIntRep();
................................................................................
      name_obj_ptr.varValue_SetNamespace(frame_ptr.ns_ptr);
      name_obj_ptr.varValue_SetVarPtr(var_ptr);
      if ((var_ptr.type & VAR_UNDEFINED) != 0) {
        var_ptr.type &= ~VAR_UNDEFINED;
      }
      handleVariableTrace(name_obj_ptr, null, TRACE_OP_WRITE, "write", null);
    } else {



//print("SEV2!");
      var_ptr = name_obj_ptr.varValue_GetVarPtr();
      if ((var_ptr.type & VAR_UNDEFINED) != 0) {
        var_ptr.type &= ~VAR_UNDEFINED;
      }
      if (var_ptr.link_frame_ptr == null) {
        val_obj_ptr.incrRefCount("I_VARIABLE_OBJ_TYPE_3");
................................................................................
   *
   * If FUNCTION_FLAGS_UNSHARED is set and the variable is an array element (dict sugar)
   * in a dictionary which is shared, the array variable value is duplicated first.
   * This allows the array element to be updated (e.g. append, lappend) without
   * affecting other references to the dictionary.
   */
  public ApwtclObj getVariable(ApwtclObj name_obj_ptr, int flags, ArrayList<Variable> result_var_ptr) {

//print("getVariable1!"+name_obj_ptr+"!");

//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()+"!");
//print("getVariable1!"+name_obj_ptr+"!");
    ArrayList<String> err_msg_ptr_ptr = new ArrayList<String>();
    switch (setFromAny(name_obj_ptr, err_msg_ptr_ptr)) {
    case OK:

//print("getVariable2!"+name_obj_ptr+"!");

      Variable var_ptr = name_obj_ptr.varValue_GetVarPtr();

      result_var_ptr.add(var_ptr);
      if (!no_trace) {
        handleVariableTrace(name_obj_ptr, null, TRACE_OP_READ, "read", var_ptr);
      }
      if (var_ptr.link_frame_ptr == null) {

//print("getVariable3!"+"@@@"+var_ptr.obj_ptr+"!");

        return var_ptr.obj_ptr;
      } else {
//print("getVariable4!");
        ApwtclObj obj_ptr;

        /* The variable is a link? Resolve it. */
        CallFrame saved_call_frame = interp.frame_ptr;
................................................................................
      break;

    case TOKEN_VAR_ARRAY_NAME:
//print("+++getVariable2array!"+name_obj_ptr+"!");
      /* ARRAY. */
      return interp.array_obj_type.arrayGet(name_obj_ptr, flags, result_var_ptr);
    }

//print("getVariable not ok!"+name_obj_ptr+"!");

    if ((flags & FUNCTION_FLAGS_LEAVE_ERR_MSG) != 0) {
      interp.setResultString("can't read \""+name_obj_ptr.getString()+"\": no such variable");
    }
    result_var_ptr.add(null);
    return null;
  }

................................................................................
      if (entry != null) {
        ns_ptr = entry;
      } else {
        if ((flags & NAMESPACE_CREATE_IF_UNKNOWN) != 0) {
          CallFrame frame_ptr = interp.frame_ptr.newCallFrame(/* call_type */ CALL_TYPE_NAMESPACE, interp.frame_ptr);
          ArrayList<CallFrame> frame_ptr_ptr = new ArrayList<CallFrame>();
          frame_ptr_ptr.add(frame_ptr);

          interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, ns_ptr, /* call_type */ CALL_TYPE_NAMESPACE);
          ns_ptr = interp.namespace_obj_type.createNamespace(ns_name);
          interp.namespace_obj_type.popStackFrame();
          if (ns_ptr == null) {
            panic(true, "could not create namespace '"+ns_name+"'");
          }
        } else {  /* namespace not found and was not created */
................................................................................
   *----------------------------------------------------------------------
   */
  public Variable lookupSimpleVar(ApwtclObj var_name_ptr, int flags, boolean create, ArrayList<String>err_msg_ptr, ArrayList<Integer> index_ptr) {
if (variable_debug > 0) {
print("lookupSimpleVar!"+var_name_ptr+"!cfr!"+interp.var_frame_ptr.toDebugString()+"!flags!"+flags+"!crp1!"+create+"!");
print("FLAGS!"+getVarLookupTypeString(flags)+"!");
}



    CallFrame var_frame_ptr = interp.var_frame_ptr;
    ArrayList<Object> var_obj_ptr = new ArrayList<Object>();
    Variable var_obj = null;
    Variable var_ptr = null;
    int result;
    Resolve res_ptr = null;
    ArrayList<Namespace> var_ns_ptr = null;
................................................................................
     *    3) the active frame was pushed to define the namespace context for a
     *       "namespace eval" or "namespace inscope" command,
     *    4) the name has namespace qualifiers ("::"s).
     * Otherwise, if var_name is a local variable, search in the call frame variables
     *
     * If create and the variable isn't found, create the variable
     */




    if (((flags & (NAMESPACE_LOOKUP_GLOBAL_ONLY | NAMESPACE_LOOKUP_NAMESPACE_ONLY)) != 0)
        || !var_frame_ptr.hasLocalVars()
        || var_name.matches("::.*")) {
      boolean look_global = ((flags & NAMESPACE_LOOKUP_GLOBAL_ONLY) != 0)
        || (ctx_ns_ptr == interp.global_ns_ptr)
        || ((var_name.charAt(0) == ':') && (var_name.charAt(1) == ':'));
if (variable_debug > 1) {
print("look_gobal!"+look_global+"!"+var_frame_ptr.hasLocalVars()+"!"+var_frame_ptr.toDebugString()+"!");
}
      if (look_global) {
        index_ptr.add( -1);
        flags = (flags | NAMESPACE_LOOKUP_GLOBAL_ONLY) & ~NAMESPACE_LOOKUP_NAMESPACE_ONLY;
      } else {
        if ((flags & VAR_LOOKUP_AVOID_RESOLVERS) != 0) {







>







 







>
>
>

>
>
>

>
|
>







 







>
>
>
>
>
>
|
|
>

>
>
>







 







>
|
>







 







>
|
>







 







>
>
>







 







>
|
>





>
|
>







>
|
>







 







>
|
>







 







>







 







>
>
>







 







>
>
>
>






|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
...
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
...
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
...
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
...
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
....
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
....
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
....
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
  private static final int LOOKUP_MSG_MISSING_NAME = 128;
  public static final int LOOKUP_MSG_IS_ARRAY_ELEMENT = 256;

  private int id;
  private Interp interp;
  public int variable_debug;
  public boolean no_trace;
public int dbg;

  /* ==================== VariableObjType ================================== */
  public VariableObjType(Interp interp) {
    oid++;
    id = oid;

    this.interp = interp;
................................................................................
      return TOKEN_VAR_ARRAY_NAME;
    }
//print("varobjtype sFA 3");
    ApwtclObj part1_ptr = interp.string_obj_type.newStringObj(var_name, -1, "VARIABLE_OBJ_TYPE_1");
    part1_ptr.incrRefCount("I_VARIABLE_OBJ_TYPE_1");
    ArrayList<String> lookup_err_msg_ptr = new ArrayList<String>();
    ArrayList<Integer> lookup_index_ptr = new ArrayList<Integer>();
if (dbg != 0) {
print("sFA call lookupSimpleVar");
}
    Variable var_obj_ptr = lookupSimpleVar(part1_ptr, FUNCTION_FLAGS_LEAVE_ERR_MSG, /* create_part1 */ false, lookup_err_msg_ptr, lookup_index_ptr);
if (dbg != 0) {
print("sFA after call lookupSimpleVar");
}
    part1_ptr.decrRefCount("D_VARIABLE_OBJ_TYPE_1");
if (dbg != 0) {
print("varobjtype sFA 4!"+var_obj_ptr+"!"+frame_ptr.ns_ptr.toDebugString()+"!");
}
    if (var_obj_ptr == null) {
      err_msg_ptr_ptr.add(lookup_err_msg_ptr.get(0));
      return ERROR;
    }
    err_msg_ptr_ptr.add(null);
    /* Free the old internal repr and set the new one. */
    obj_ptr.freeIntRep();
................................................................................

  public int setVariable(ApwtclObj name_obj_ptr, ApwtclObj val_obj_ptr, ArrayList<Variable> result_var_ptr) {
    String name;
    Variable var_ptr;
    boolean create = true;
    int err;
    ArrayList<String> err_msg_ptr = new ArrayList<String>();
if (name_obj_ptr.getString().equals("extrainits")) {
dbg = 0;
} else {
dbg = 0;
}
if (dbg != 0) {
print("setVariable1!"+name_obj_ptr+"!"+val_obj_ptr+"!"+interp.frame_ptr+"!"+interp.var_frame_ptr+"!");
}

    if ((err = setFromAny(name_obj_ptr, err_msg_ptr)) != OK) {
if (dbg != 0) {
print("setVariable NOT OK");
}
//print("setVariable2 not OK!"+err_msg_ptr+"!");
      CallFrame frame_ptr = interp.frame_ptr;

      /* Check for array names like syntax. */
      if (err == TOKEN_VAR_ARRAY_NAME) {
//print("setVariable2a!"+name_obj_ptr+"!"+interp.frame_ptr.ns_ptr+"!");
        int ret = interp.array_obj_type.arraySet(name_obj_ptr, val_obj_ptr, result_var_ptr);
................................................................................
      }
      /* if we did not find the variable it cannot be a namespace variable
       * as namespace variables are created with VAR_UNDEFINED, if not initialized
       * if err_msg_ptr is null
       * only exception global variables starting with :: like ::abc need
       * special handling here
       */
if (dbg != 0) {
print("setVariable3!"+name_obj_ptr.getString()+"!"+err_msg_ptr+"!");
}
      String err_msg = err_msg_ptr.get(0);
      if (err_msg_ptr != null) {
        String my_name = name_obj_ptr.getString();
        if (my_name.indexOf("::") >= 0) {
          if (my_name.substring(2).indexOf("::") > 0) {
            interp.setResultString(err_msg);
            result_var_ptr.add(null);
................................................................................
      /* New variable to create */
      // FIXME need to get tail of variable name here !!
      name = name_obj_ptr.getString();
      if (name.charAt(0) == ':' && name.charAt(1) == ':') {
        name = name.substring(2);
      }
      var_ptr = frame_ptr.getVariable(name, create);
if (dbg != 0) {
print("setVariable a!"+name+"!"+var_ptr+"!"+create+"!"+interp.frame_ptr.ns_ptr.toDebugString()+"!"+interp.frame_ptr.toDebugString()+"!");      
}
//print("SEV!"+name+"!"+frame_ptr.variables.get(name)+"!"+interp.var_frame_ptr.variables.get(name)+"!"+frame_ptr.toDebugString()+"!"+interp.var_frame_ptr.toDebugString()+"!");
      result_var_ptr.add(var_ptr);
      var_ptr.obj_ptr = val_obj_ptr;
      val_obj_ptr.incrRefCount("I_VARIABLE_OBJ_TYPE_2");
      var_ptr.link_frame_ptr = null;
      /* Make the object int rep a variable */
      name_obj_ptr.freeIntRep();
................................................................................
      name_obj_ptr.varValue_SetNamespace(frame_ptr.ns_ptr);
      name_obj_ptr.varValue_SetVarPtr(var_ptr);
      if ((var_ptr.type & VAR_UNDEFINED) != 0) {
        var_ptr.type &= ~VAR_UNDEFINED;
      }
      handleVariableTrace(name_obj_ptr, null, TRACE_OP_WRITE, "write", null);
    } else {
if (dbg != 0) {
print("setVariable OK");
}
//print("SEV2!");
      var_ptr = name_obj_ptr.varValue_GetVarPtr();
      if ((var_ptr.type & VAR_UNDEFINED) != 0) {
        var_ptr.type &= ~VAR_UNDEFINED;
      }
      if (var_ptr.link_frame_ptr == null) {
        val_obj_ptr.incrRefCount("I_VARIABLE_OBJ_TYPE_3");
................................................................................
   *
   * If FUNCTION_FLAGS_UNSHARED is set and the variable is an array element (dict sugar)
   * in a dictionary which is shared, the array variable value is duplicated first.
   * This allows the array element to be updated (e.g. append, lappend) without
   * affecting other references to the dictionary.
   */
  public ApwtclObj getVariable(ApwtclObj name_obj_ptr, int flags, ArrayList<Variable> result_var_ptr) {
if (dbg != 0) {
print("getVariable1!"+name_obj_ptr+"!");
}
//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()+"!");
//print("getVariable1!"+name_obj_ptr+"!");
    ArrayList<String> err_msg_ptr_ptr = new ArrayList<String>();
    switch (setFromAny(name_obj_ptr, err_msg_ptr_ptr)) {
    case OK:
if (dbg != 0) {
print("getVariable2!"+name_obj_ptr+"!");
}
      Variable var_ptr = name_obj_ptr.varValue_GetVarPtr();

      result_var_ptr.add(var_ptr);
      if (!no_trace) {
        handleVariableTrace(name_obj_ptr, null, TRACE_OP_READ, "read", var_ptr);
      }
      if (var_ptr.link_frame_ptr == null) {
if (dbg != 0) {
print("getVariable3!"+"@@@"+var_ptr.obj_ptr+"!");
}
        return var_ptr.obj_ptr;
      } else {
//print("getVariable4!");
        ApwtclObj obj_ptr;

        /* The variable is a link? Resolve it. */
        CallFrame saved_call_frame = interp.frame_ptr;
................................................................................
      break;

    case TOKEN_VAR_ARRAY_NAME:
//print("+++getVariable2array!"+name_obj_ptr+"!");
      /* ARRAY. */
      return interp.array_obj_type.arrayGet(name_obj_ptr, flags, result_var_ptr);
    }
if (dbg != 0) {
print("getVariable not ok!"+name_obj_ptr+"!");
}
    if ((flags & FUNCTION_FLAGS_LEAVE_ERR_MSG) != 0) {
      interp.setResultString("can't read \""+name_obj_ptr.getString()+"\": no such variable");
    }
    result_var_ptr.add(null);
    return null;
  }

................................................................................
      if (entry != null) {
        ns_ptr = entry;
      } else {
        if ((flags & NAMESPACE_CREATE_IF_UNKNOWN) != 0) {
          CallFrame frame_ptr = interp.frame_ptr.newCallFrame(/* call_type */ CALL_TYPE_NAMESPACE, interp.frame_ptr);
          ArrayList<CallFrame> frame_ptr_ptr = new ArrayList<CallFrame>();
          frame_ptr_ptr.add(frame_ptr);
//print("variableObjType getNamespaceForQualName PUSF");
          interp.namespace_obj_type.pushStackFrame(frame_ptr_ptr, ns_ptr, /* call_type */ CALL_TYPE_NAMESPACE);
          ns_ptr = interp.namespace_obj_type.createNamespace(ns_name);
          interp.namespace_obj_type.popStackFrame();
          if (ns_ptr == null) {
            panic(true, "could not create namespace '"+ns_name+"'");
          }
        } else {  /* namespace not found and was not created */
................................................................................
   *----------------------------------------------------------------------
   */
  public Variable lookupSimpleVar(ApwtclObj var_name_ptr, int flags, boolean create, ArrayList<String>err_msg_ptr, ArrayList<Integer> index_ptr) {
if (variable_debug > 0) {
print("lookupSimpleVar!"+var_name_ptr+"!cfr!"+interp.var_frame_ptr.toDebugString()+"!flags!"+flags+"!crp1!"+create+"!");
print("FLAGS!"+getVarLookupTypeString(flags)+"!");
}
if (dbg != 0) {
print("lookupSimpleVar!"+interp.var_frame_ptr+"!");
}
    CallFrame var_frame_ptr = interp.var_frame_ptr;
    ArrayList<Object> var_obj_ptr = new ArrayList<Object>();
    Variable var_obj = null;
    Variable var_ptr = null;
    int result;
    Resolve res_ptr = null;
    ArrayList<Namespace> var_ns_ptr = null;
................................................................................
     *    3) the active frame was pushed to define the namespace context for a
     *       "namespace eval" or "namespace inscope" command,
     *    4) the name has namespace qualifiers ("::"s).
     * Otherwise, if var_name is a local variable, search in the call frame variables
     *
     * If create and the variable isn't found, create the variable
     */
if (dbg != 0) {
print("LL!"+((flags & (NAMESPACE_LOOKUP_GLOBAL_ONLY | NAMESPACE_LOOKUP_NAMESPACE_ONLY)) != 0)+"!"+!var_frame_ptr.hasLocalVars()+"!"+var_name.matches("::.*")+"!");
print("CF!"+var_frame_ptr+"!");
}
    if (((flags & (NAMESPACE_LOOKUP_GLOBAL_ONLY | NAMESPACE_LOOKUP_NAMESPACE_ONLY)) != 0)
        || !var_frame_ptr.hasLocalVars()
        || var_name.matches("::.*")) {
      boolean look_global = ((flags & NAMESPACE_LOOKUP_GLOBAL_ONLY) != 0)
        || (ctx_ns_ptr == interp.global_ns_ptr)
        || ((var_name.charAt(0) == ':') && (var_name.charAt(1) == ':'));
if (variable_debug > 1 || dbg != 0) {
print("look_gobal!"+look_global+"!"+var_frame_ptr.hasLocalVars()+"!"+var_frame_ptr.toDebugString()+"!");
}
      if (look_global) {
        index_ptr.add( -1);
        flags = (flags | NAMESPACE_LOOKUP_GLOBAL_ONLY) & ~NAMESPACE_LOOKUP_NAMESPACE_ONLY;
      } else {
        if ((flags & VAR_LOOKUP_AVOID_RESOLVERS) != 0) {

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

8
9
10
11
12
13
14

15
16
17
18
19
20
21
22
23
24
25
26
27
interp alias {} ::itcl::type {} ::itcl type
interp alias {} ::itcl::macro {} ::itcl macro
interp alias {} ::itcl::body {} ::itcl body
interp alias {} ::itcl::mkmember {} ::itcl mkmember
interp alias {} ::itcl::internal::classcget {} ::itcl internal classcget
interp alias {} ::itcl::internal::classconfigure {} ::itcl internal classconfigure
interp alias {} ::itcl::internal::classinstall {} ::itcl internal classinstall

package ifneeded itcl 4.0b6 {
    namespace eval ::itcl { # init
    }
    source [file join $dir itclParse.tcl]
    package provide itcl 4.0b6
}

package ifneeded tcltest 0.1 {
    namespace eval ::tcltest { # init
    }
    package provide tcltest 0.1
}








>













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

package ifneeded tcltest 0.1 {
    namespace eval ::tcltest { # init
    }
    package provide tcltest 0.1
}