ALDT (Arnulf's LaTeX Documentation Tool)

Check-in [5d7b8549ff]
Login

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

Overview
Comment:fixes
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:5d7b8549ffa806544a3e3248548584c26dc8d65b
User & Date: arnulf 2012-08-26 20:19:43
Context
2012-08-29
17:34
fixes and new code check-in: 55cf454cd6 user: arnulf tags: trunk
2012-08-26
20:19
fixes check-in: 5d7b8549ff user: arnulf tags: trunk
19:29
fixes and new code check-in: eaea8012cb user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to EvalStatement.tcl.

340
341
342
343
344
345
346


347
348
349
350
351
352
353
...
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422

423
424

425
426

427
428
429

430
431
432
433
434
435
436
437
438
439
440
441


442
443
444
445
446
447




448
449

450
451
452
453

454
455


456
457

458

459


460
461
462
463
464
465
466
467

468
469
470
471

472
473
474

475

476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491

492
493
494
495
496
497
498
::itcl::body EvalStatement::evalObj {script_obj_ptr} {
if {$eval_stmt_debug > 0} {
puts "EVALOBJ!$script_obj_ptr!"
}
    set retcode [::Interp::string2ReturnCode OK]
    set line_no 0
    set had_comment false



    incr eval_level
if {$eval_stmt_debug > 0} {
puts "EVALOBJ 1a level!$eval_level![$script_obj_ptr toDebugString]!"
if {$eval_stmt_debug > 1} {
puts "EVALOBJ 1b level!$eval_level![$script_obj_ptr mySelf]!"
}
................................................................................
      if {$macro_cmd_level == $eval_level} {
        set had_macro_cmd false
      }
      incr eval_level -1
      return true
    }
puts "EVALOBJ5"
    if (script.script_object.len == 3
        && script.script_object.tokens.get(1).obj_ptr.obj_type == OBJ_TYPE_COMMAND
	    && script.script_object.tokens.get(1).obj_ptr.cmdValue_GetResolvedCmdNamePtr().cmd_ptr.is_proc == false
        && script.script_object.tokens.get(1).obj_ptr.cmdValue_GetResolvedCmdNamePtr().cmd_ptr.name.equals("incr")
        && script.script_object.tokens.get(2).obj_ptr.obj_type == OBJ_TYPE_VARIABLE) {

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

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

     * Think for example to this:
     *

     * set x {llength $x; ... some more code ...}; eval $x
     *

     * In order to preserve the internal rep, we increment the
     * inUse field of the script internal rep structure. 
     */

    script.script_object.ref_count++;
    token = script.script_object.tokens;
    /* Execute every command sequentially until the end of the script
     * or an error occurs.
     */
//print("EVALOBJ7");

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


      int num_comments = 0;

      /* First token of the line is always TOKEN_LINE */
      argc = token.get(i).obj_ptr.scriptLineValue_GetArgc();
//print("I!"+i+"!"+argc+"!"+getTokenString(token.get(i).token)+"!"+token.get(i).obj_ptr.ToDebugString()+"!");
      line_no = token.get(i).obj_ptr.scriptLineValue_GetLine();




      /* Skip the TOKEN_LINE token */
      i++;

      /* Populate the arguments objects.
       * If an error occurs, retcode will be set and
       * 'j' will be set to the number of args expanded
       */

      had_comment = false;
for (j = 0; j < argc; j++) {


if (eval_stmt_debug > -2) {
print("all J!"+j+"!"+getTokenString(token.get(j+i).token)+"!"+token.get(j+i).obj_ptr+"!");

}              

}


      for (j = 0; j < argc; j++) {
//print("J!"+j+"!"+argc+"!"+argv+"!");
        int word_tokens = 1;
        boolean expand = false;
        ApwtclObj word_obj_ptr = null;

if (eval_stmt_debug > -2) {
print("J!"+j+"!"+getTokenString(token.get(i).token)+"!"+token.get(i).obj_ptr+"!");

if (eval_stmt_debug > 1) {
print("evalObj dump1 i!"+i+"!");
script.dumpToken(i);
print("J!"+j+"!"+getTokenString(token.get(i).token)+"!"+token.get(i).obj_ptr.toDebugString()+"!");

}
}
        if (token.get(i).token == TOKEN_WORD) {

//script.DumpToken(i);

          word_tokens = (int)token.get(i++).obj_ptr.wideValue_GetValue();
          if (word_tokens < 0) {
            expand = true;
            word_tokens = -word_tokens;
          }
        }
            had_comment = false;
        if (word_tokens == 1) {
          /* Fast path if the token does not
           * need interpolation 
           */
//print("word_tokens 1!");
if (eval_stmt_debug > -2) {
print("evalObj dump2 i!"+i+"!");
script.dumpToken(i);
print("argv!"+argv+"!");

}
          switch (token.get(i).token) {
          case TOKEN_COMMENT:
            had_comment = true;
            num_comments++;
            break;
          case TOKEN_QUOTE_ESC:







>
>







 







|
|
|
|
|

|

|
|
|
|
|
|
|

|
|
|


|
|
|
<
>
|
<
>
|
<
>
|
|
<
>
|
<
|
|
<
|

<
<
<
<
<
>
>
|

|
<
<
<
>
>
>
>
|
<
>
|
|
|
<
>
|
<
>
>
|
<
>

>

>
>
|
<
|
|
|

|
<
>
|
|
|
<
>


<
>
|
>
|
|
|
|


|
|
|
|
<
|
|
|
|
<
>







340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
...
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423

424
425

426
427

428
429
430

431
432

433
434

435
436





437
438
439
440
441



442
443
444
445
446

447
448
449
450

451
452

453
454
455

456
457
458
459
460
461
462

463
464
465
466
467

468
469
470
471

472
473
474

475
476
477
478
479
480
481
482
483
484
485
486
487

488
489
490
491

492
493
494
495
496
497
498
499
::itcl::body EvalStatement::evalObj {script_obj_ptr} {
if {$eval_stmt_debug > 0} {
puts "EVALOBJ!$script_obj_ptr!"
}
    set retcode [::Interp::string2ReturnCode OK]
    set line_no 0
    set had_comment false
    set argv [list]
    set argc 0

    incr eval_level
if {$eval_stmt_debug > 0} {
puts "EVALOBJ 1a level!$eval_level![$script_obj_ptr toDebugString]!"
if {$eval_stmt_debug > 1} {
puts "EVALOBJ 1b level!$eval_level![$script_obj_ptr mySelf]!"
}
................................................................................
      if {$macro_cmd_level == $eval_level} {
        set had_macro_cmd false
      }
      incr eval_level -1
      return true
    }
puts "EVALOBJ5"
    if {[[$script getScriptObject] getLen] == 3
        && [[[lindex [[$script getScriptObject] getTokens] 1] getObjptr] getObjType] == [::Interp::string2ObjType OBJ_TYPE_COMMAND]
	    && [[[[[[lindex [$script getScriptObject] getTokens] 1] getObjPtr] cmdValue_GetResolvedCmdNamePtr] getCmdPtr] getIsProc] == false
        && [[[[[[lindex [$script getScriptobject] getTokens] 1] getObjPtr] cmdValue_GetResolvedCmdNamePtr] getCmdPtr] getName] eq "incr"
        && [[[[lindex [$script getScriptObject] getTokens] 2] getObjPtr] getObjType] == [::Interp::string2ObjType OBJ_TYPE_VARIABLE]} {

      set obj_ptr [::Interp::variable_obj_type getVariable(script.script_object.tokens.get(2).obj_ptr, FUNCTION_FLAGS_NONE, var_ptr]

      if {$obj_ptr != [list] && ![$obj_ptr isShared] && [$obj_ptr getObjType] == [::Interp::string2ObjType OBJ_TYPE_INT]} {
#FIXME!!        JimWideValue(obj_ptr)++;
        $obj_ptr invalidateStringRep
        $script_obj_ptr decrRefCount "D_EVAL_STATEMENT_5"
        ::Interp::setResult $obj_ptr
        if {$macro_cmd_level == $eval_level} {
          set ad_macro_cmd false
        }
        # can only uncomment, if JimWideValue above is fixed!!
#        eval_level--;
#        return OK;
      }
    }
puts "EVALOBJ6"
    # Now we have to make sure the internal repr will not be
    # freed on shimmering.

    #
    # Think for example to this:

    #
    # set x {llength $x; ... some more code ...}; eval $x

    #
    # In order to preserve the internal rep, we increment the
    # inUse field of the script internal rep structure. 

    [$script getScriptObject] setRefCount [expr {[[$script getScriptObject] getRefCount] + 1}]
    set token [[$script getScriptObject] getTokens]

    # Execute every command sequentially until the end of the script
    # or an error occurs.

puts "EVALOBJ7"






    set i 0
    while {$i < [[$script getScriptObject] getLen] && $retcode == [::Interp::string2ReturnCode OK]} {
      set num_comments 0

      # First token of the line is always TOKEN_LINE 



puts "I0!$i!"
      set argc [[[lindex $token $i] getObjPtr] scriptLineValue_GetArgc]
puts "I!$i!$argc![::Parser::Token::token2String [[lindex $token $i] getToken]]![[[lindex $token $i] getObjPtr] toDebugString]!"
      set line_no [[[lindex $token $i] getObjPtr] scriptLineValue_GetLine]
      # Skip the TOKEN_LINE token 

      incr i
      # Populate the arguments objects.
      # If an error occurs, retcode will be set and
      # 'j' will be set to the number of args expanded

      
      set had_comment false

      set j 0
while {$j < $argc} {
if {$eval_stmt_debug > -2} {

puts "all J!$j![::Parser::Token::token2String [lindex $token [expr {$j + $i}]] getToken]![lindex $token [expr {$j + $i}] getObjPtr]!"
}              
incr j
}
      set j 0
      while {$j < $argc} {
puts "J!$j!$argc!$argv!"

        set word_tokens 1
        set expand false
        set word_obj_ptr [list]

if {$eval_stmt_debug > -2} {

puts "J!$j![::Parser::Token::token2String [[lindex $token $i] getToken]]![[lindex $token $i] getObjPtr]!"
if {$eval_stmt_debug > 1} {
puts "evalObj dump1 i!$i!"
$script dumpToken $i

puts "J!$j![::Parser::Token::token2String [[lindex $token $i] getToken]]![[[lindex $token $i] getObjPtr] toDebugString]!"
}
}

        if {[[lindex $token $i] getToken] == [::Parser::Token::string2Token TOKEN_WORD]} {
# $script DumpToken $i
          set word_tokens [[[lindex $token $i] getObjPtr] wideValue_GetValue]
	  incr i
          if {$word_tokens < 0} {
            set expand true
            set word_tokens [expr {-$word_tokens}]
          }
        }
        set had_comment false
        if {$word_tokens == 1} {
          # Fast path if the token does not
          # need interpolation 

puts "word_tokens 1!"
if {$eval_stmt_debug > -2} {
puts "evalObj dump2 i!$i!"
$script dumpToken $i

puts "argv!$argv!"
}
          switch (token.get(i).token) {
          case TOKEN_COMMENT:
            had_comment = true;
            num_comments++;
            break;
          case TOKEN_QUOTE_ESC:

Changes to Script.tcl.

200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
      incr i
    }
    set line_no [[lindex $parse_token_list 0] getLine]
    $script_object setLine $line_no
    $script_object setTokens [list]
    set i 0
    while {$i < $count} {
      set script_token [uplevel 0 ::Parser::ScriptToken #auto]
      $script_object addToken $script_token
      incr i
    }
    set token_idx 0
    # This is the first token for the current command
    set token_list_idx 0
    set line_first_idx $token_idx







|







200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
      incr i
    }
    set line_no [[lindex $parse_token_list 0] getLine]
    $script_object setLine $line_no
    $script_object setTokens [list]
    set i 0
    while {$i < $count} {
      set script_token [uplevel #0 ::Parser::ScriptToken #auto]
      $script_object addToken $script_token
      incr i
    }
    set token_idx 0
    # This is the first token for the current command
    set token_list_idx 0
    set line_first_idx $token_idx

Changes to ScriptLineObjType.tcl.

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

    if {$debug_script > 0} {
      set str "line=$line, argc=$argc"
      set obj_ptr [$::Interp::string_obj_type newStringObj $str -1 "SCRIPT_LINE_OBJ_TYPE_1"]
    } else {
      set obj_ptr [$::Interp::string_obj_type newEmptyStringObj "SCRIPT_LINE_OBJ_TYPE_2"]
    }
    $obj_ptr setObjType OBJ_TYPE_SCRIPT_LINE
    $obj_ptr scriptLineValue_SetArgc $argc
    $obj_ptr scriptLineValue_SetLine $line

    return $obj_ptr
  }

}








|








63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

    if {$debug_script > 0} {
      set str "line=$line, argc=$argc"
      set obj_ptr [$::Interp::string_obj_type newStringObj $str -1 "SCRIPT_LINE_OBJ_TYPE_1"]
    } else {
      set obj_ptr [$::Interp::string_obj_type newEmptyStringObj "SCRIPT_LINE_OBJ_TYPE_2"]
    }
    $obj_ptr setObjType [::Interp::string2ObjType OBJ_TYPE_SCRIPT_LINE]
    $obj_ptr scriptLineValue_SetArgc $argc
    $obj_ptr scriptLineValue_SetLine $line

    return $obj_ptr
  }

}

Changes to SourceObjType.tcl.

73
74
75
76
77
78
79
80
81
82
83
84
  # ==================== setSourceInfo ==================================
::itcl::body SourceObjType::setSourceInfo {obj_ptr file_name_ptr line_number} {
    ::Interp::panic [$obj_ptr isShared] "setSourceInfo called with shared object"
    ::Interp::panic [expr {[$obj_ptr getObjType] < 0}] "setSourceInfo called with obj_type < 0"
    $file_name_ptr incrRefCount "I_SOURCE_OBJ_TYPE_2"
    $obj_ptr sourceValue_SetFileNameObj $file_name_ptr
    $obj_ptr sourceValue_SetLineNumber $line_number
    $obj_ptr setObjType OBJ_TYPE_SOURCE
  }

}








|




73
74
75
76
77
78
79
80
81
82
83
84
  # ==================== setSourceInfo ==================================
::itcl::body SourceObjType::setSourceInfo {obj_ptr file_name_ptr line_number} {
    ::Interp::panic [$obj_ptr isShared] "setSourceInfo called with shared object"
    ::Interp::panic [expr {[$obj_ptr getObjType] < 0}] "setSourceInfo called with obj_type < 0"
    $file_name_ptr incrRefCount "I_SOURCE_OBJ_TYPE_2"
    $obj_ptr sourceValue_SetFileNameObj $file_name_ptr
    $obj_ptr sourceValue_SetLineNumber $line_number
    $obj_ptr setObjType [::Interp::string2ObjType OBJ_TYPE_SOURCE]
  }

}