Changeset 488

Show
Ignore:
Timestamp:
03/16/2008 22:17:12 (6 months ago)
Author:
why
Message:
  • shoes/ruby.c: set up $0.
  • lib/shoes.rb: with each loaded script, set $0 and FILE.
  • samples/irb.rb: set FILE and LINE.
Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/shoes.rb

    r482 r488  
    218218        path = File.basename(path) 
    219219      end 
    220       eval(File.read(path), TOPLEVEL_BINDING) 
     220      $0.replace path 
     221      eval(File.read(path), TOPLEVEL_BINDING, path) 
    221222    end 
    222223  end 
  • trunk/samples/irb.rb

    r374 r488  
    3333    end 
    3434    unless @line.empty? 
    35       obj = eval @line, TOPLEVEL_BINDING 
     35      obj = eval @line, TOPLEVEL_BINDING, "(irb)", @line_no 
    3636    end 
     37    @line_no += @line.scan(/\n/).length 
    3738    @line = '' 
    3839    @exp_line_no = @line_no 
  • trunk/shoes/ruby.c

    r487 r488  
    38503850{ 
    38513851  char proc[SHOES_BUFSIZE]; 
     3852  VALUE progname = rb_str_new2("(eval)"); 
     3853  rb_define_variable("$0", &progname); 
     3854  rb_define_variable("$PROGRAM_NAME", &progname); 
     3855 
    38523856  instance_eval_proc = rb_eval_string("lambda{|o,b| o.instance_eval(&b)}"); 
    38533857  rb_gc_register_address(&instance_eval_proc);