yarv-diff:152
From: ko1 atdot.net
Date: 12 Dec 2005 18:59:03 -0000
Subject: [yarv-diff:152] r311 - in trunk: . lib template yarvtest
Author: ko1
Date: 2005-12-13 03:59:03 +0900 (Tue, 13 Dec 2005)
New Revision: 311
Added:
trunk/lib/un.rb
Modified:
trunk/ChangeLog
trunk/eval_proc.c
trunk/insns.def
trunk/template/insns_info.inc.tmpl
trunk/template/minsns.inc.tmpl
trunk/template/opt_sc.inc.tmpl
trunk/template/optinsn.inc.tmpl
trunk/template/optunifs.inc.tmpl
trunk/template/vm.inc.tmpl
trunk/template/vmtc.inc.tmpl
trunk/test.rb
trunk/vm.c
trunk/yarvcore.h
trunk/yarvtest/test_syntax.rb
Log:
* eval_proc.c : fix indent
* insns.def : fix getspecial instruction to return nil
if no entry
* yarvtest/test_syntax.rb : add a test for above
* lib/un.rb : added
* template/*.tmpl : fix typo
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/ChangeLog 2005-12-12 18:59:03 UTC (rev 311)
@@ -4,6 +4,20 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+2005-12-13(Tue) 03:55:27 +0900 Koichi Sasada <ko1 atdot.net>
+
+ * eval_proc.c : fix indent
+
+ * insns.def : fix getspecial instruction to return nil
+ if no entry
+
+ * yarvtest/test_syntax.rb : add a test for above
+
+ * lib/un.rb : added
+
+ * template/*.tmpl : fix typo
+
+
2005-12-13(Mon) 01:38:17 +0900 Minero Aoki <aamine loveruby.net>
* yarv.h: add prototypes.
Modified: trunk/eval_proc.c
===================================================================
--- trunk/eval_proc.c 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/eval_proc.c 2005-12-12 18:59:03 UTC (rev 311)
@@ -433,13 +433,12 @@
}
void
-bm_mark(data)
- struct METHOD *data;
+bm_mark(struct METHOD *data)
{
- rb_gc_mark(data->rklass);
- rb_gc_mark(data->klass);
- rb_gc_mark(data->recv);
- rb_gc_mark((VALUE)data->body);
+ rb_gc_mark(data->rklass);
+ rb_gc_mark(data->klass);
+ rb_gc_mark(data->recv);
+ rb_gc_mark((VALUE)data->body);
}
static VALUE
Modified: trunk/insns.def
===================================================================
--- trunk/insns.def 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/insns.def 2005-12-12 18:59:03 UTC (rev 311)
@@ -100,7 +100,7 @@
val = rb_ary_entry(ary, idx);
}
else{
- val = Qundef;
+ val = Qnil;
}
}
}
Added: trunk/lib/un.rb
===================================================================
--- trunk/lib/un.rb 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/lib/un.rb 2005-12-12 18:59:03 UTC (rev 311)
@@ -0,0 +1,235 @@
+#
+# = un.rb
+#
+# Copyright (c) 2003 WATANABE Hirofumi <eban ruby-lang.org>
+#
+# This program is free software.
+# You can distribute/modify this program under the same terms of Ruby.
+#
+# == Utilities to replace common UNIX commands in Makefiles etc
+#
+# == SYNOPSIS
+#
+# ruby -run -e cp -- [OPTION] SOURCE DEST
+# ruby -run -e ln -- [OPTION] TARGET LINK_NAME
+# ruby -run -e mv -- [OPTION] SOURCE DEST
+# ruby -run -e rm -- [OPTION] FILE
+# ruby -run -e mkdir -- [OPTION] DIRS
+# ruby -run -e rmdir -- [OPTION] DIRS
+# ruby -run -e install -- [OPTION] SOURCE DEST
+# ruby -run -e chmod -- [OPTION] OCTAL-MODE FILE
+# ruby -run -e touch -- [OPTION] FILE
+# ruby -run -e help [COMMAND]
+
+require "fileutils"
+require "optparse"
+
+module FileUtils
+# @fileutils_label = ""
+ @fileutils_output = $stdout
+end
+
+def setup(options = "")
+ ARGV.map! do |x|
+ case x
+ when /^-/
+ x.delete "^-#{options}v"
+ when /[*?\[{]/
+ Dir[x]
+ else
+ x
+ end
+ end
+ ARGV.flatten!
+ ARGV.delete_if{|x| x == "-"}
+ opt_hash = {}
+ OptionParser.new do |o|
+ options.scan(/.:?/) do |s|
+ o.on("-" + s.tr(":", " ")) do |val|
+ opt_hash[s.delete(":").intern] = val
+ end
+ end
+ o.on("-v") do opt_hash[:verbose] = true end
+ o.parse!
+ end
+ yield ARGV, opt_hash
+end
+
+##
+# Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
+#
+# ruby -run -e cp -- [OPTION] SOURCE DEST
+#
+# -p preserve file attributes if possible
+# -r copy recursively
+# -v verbose
+#
+
+def cp
+ setup("pr") do |argv, options|
+ cmd = "cp"
+ cmd += "_r" if options.delete :r
+ options[:preserve] = true if options.delete :p
+ dest = argv.pop
+ argv = argv[0] if argv.size == 1
+ FileUtils.send cmd, argv, dest, options
+ end
+end
+
+##
+# Create a link to the specified TARGET with LINK_NAME.
+#
+# ruby -run -e ln -- [OPTION] TARGET LINK_NAME
+#
+# -s make symbolic links instead of hard links
+# -f remove existing destination files
+# -v verbose
+#
+
+def ln
+ setup("sf") do |argv, options|
+ cmd = "ln"
+ cmd += "_s" if options.delete :s
+ options[:force] = true if options.delete :f
+ dest = argv.pop
+ argv = argv[0] if argv.size == 1
+ FileUtils.send cmd, argv, dest, options
+ end
+end
+
+##
+# Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
+#
+# ruby -run -e mv -- [OPTION] SOURCE DEST
+#
+# -v verbose
+#
+
+def mv
+ setup do |argv, options|
+ dest = argv.pop
+ argv = argv[0] if argv.size == 1
+ FileUtils.mv argv, dest, options
+ end
+end
+
+##
+# Remove the FILE
+#
+# ruby -run -e rm -- [OPTION] FILE
+#
+# -f ignore nonexistent files
+# -r remove the contents of directories recursively
+# -v verbose
+#
+
+def rm
+ setup("fr") do |argv, options|
+ cmd = "rm"
+ cmd += "_r" if options.delete :r
+ options[:force] = true if options.delete :f
+ FileUtils.send cmd, argv, options
+ end
+end
+
+##
+# Create the DIR, if they do not already exist.
+#
+# ruby -run -e mkdir -- [OPTION] DIR
+#
+# -p no error if existing, make parent directories as needed
+# -v verbose
+#
+
+def mkdir
+ setup("p") do |argv, options|
+ cmd = "mkdir"
+ cmd += "_p" if options.delete :p
+ FileUtils.send cmd, argv, options
+ end
+end
+
+##
+# Remove the DIR.
+#
+# ruby -run -e rmdir -- [OPTION] DIR
+#
+# -v verbose
+#
+
+def rmdir
+ setup do |argv, options|
+ FileUtils.rmdir argv, options
+ end
+end
+
+##
+# Copy SOURCE to DEST.
+#
+# ruby -run -e install -- [OPTION] SOURCE DEST
+#
+# -p apply access/modification times of SOURCE files to
+# corresponding destination files
+# -m set permission mode (as in chmod), instead of 0755
+# -v verbose
+#
+
+def install
+ setup("pm:") do |argv, options|
+ options[:mode] = (mode = options.delete :m) ? mode.oct : 0755
+ options[:preserve] = true if options.delete :p
+ dest = argv.pop
+ argv = argv[0] if argv.size == 1
+ FileUtils.install argv, dest, options
+ end
+end
+
+##
+# Change the mode of each FILE to OCTAL-MODE.
+#
+# ruby -run -e chmod -- [OPTION] OCTAL-MODE FILE
+#
+# -v verbose
+#
+
+def chmod
+ setup do |argv, options|
+ mode = argv.shift.oct
+ FileUtils.chmod mode, argv, options
+ end
+end
+
+##
+# Update the access and modification times of each FILE to the current time.
+#
+# ruby -run -e touch -- [OPTION] FILE
+#
+# -v verbose
+#
+
+def touch
+ setup do |argv, options|
+ FileUtils.touch argv, options
+ end
+end
+
+##
+# Display help message.
+#
+# ruby -run -e help [COMMAND]
+#
+
+def help
+ setup do |argv,|
+ all = argv.empty?
+ open(__FILE__) do |me|
+ while me.gets("##\n")
+ if help = me.gets("\n\n")
+ if all or argv.delete help[/-e \w+/].sub(/-e /, "")
+ print help.gsub(/^# ?/, "")
+ end
+ end
+ end
+ end
+ end
+end
Modified: trunk/template/insns_info.inc.tmpl
===================================================================
--- trunk/template/insns_info.inc.tmpl 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/template/insns_info.inc.tmpl 2005-12-12 18:59:03 UTC (rev 311)
@@ -3,7 +3,7 @@
----
This file is auto generated by insns2vm.rb
- DO NOT TOUGH!
+ DO NOT TOUCH!
If you want to fix something, you must edit 'tmpl/insns_info.inc.tmpl'
or insns2vm.rb
Modified: trunk/template/minsns.inc.tmpl
===================================================================
--- trunk/template/minsns.inc.tmpl 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/template/minsns.inc.tmpl 2005-12-12 18:59:03 UTC (rev 311)
@@ -3,7 +3,7 @@
----
This file is auto generated by insns2vm.rb
- DO NOT TOUGH!
+ DO NOT TOUCH!
If you want to fix something, you must edit 'tmpl/minsns.inc.tmpl'
or insns2vm.rb
Modified: trunk/template/opt_sc.inc.tmpl
===================================================================
--- trunk/template/opt_sc.inc.tmpl 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/template/opt_sc.inc.tmpl 2005-12-12 18:59:03 UTC (rev 311)
@@ -6,7 +6,7 @@
----
This file is auto generated by insns2vm.rb
- DO NOT TOUGH!
+ DO NOT TOUCH!
If you want to fix something, you must edit 'tmpl/opt_sc.inc.tmpl'
or rb/insns2vm.rb
Modified: trunk/template/optinsn.inc.tmpl
===================================================================
--- trunk/template/optinsn.inc.tmpl 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/template/optinsn.inc.tmpl 2005-12-12 18:59:03 UTC (rev 311)
@@ -6,7 +6,7 @@
----
This file is auto generated by insns2vm.rb
- DO NOT TOUGH!
+ DO NOT TOUCH!
If you want to fix something, you must edit 'tmpl/optinsn.inc.tmpl'
or rb/insns2vm.rb
Modified: trunk/template/optunifs.inc.tmpl
===================================================================
--- trunk/template/optunifs.inc.tmpl 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/template/optunifs.inc.tmpl 2005-12-12 18:59:03 UTC (rev 311)
@@ -6,7 +6,7 @@
----
This file is auto generated by insns2vm.rb
- DO NOT TOUGH!
+ DO NOT TOUCH!
If you want to fix something, you must edit 'tmpl/optunifs.inc.tmpl'
or rb/insns2vm.rb
Modified: trunk/template/vm.inc.tmpl
===================================================================
--- trunk/template/vm.inc.tmpl 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/template/vm.inc.tmpl 2005-12-12 18:59:03 UTC (rev 311)
@@ -6,7 +6,7 @@
----
This file is auto generated by insns2vm.rb
- DO NOT TOUGH!
+ DO NOT TOUCH!
If you want to fix something, you must edit 'insns.c'
*/
Modified: trunk/template/vmtc.inc.tmpl
===================================================================
--- trunk/template/vmtc.inc.tmpl 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/template/vmtc.inc.tmpl 2005-12-12 18:59:03 UTC (rev 311)
@@ -6,7 +6,7 @@
----
This file is auto generated by insns2vm.rb
- DO NOT TOUGH!
+ DO NOT TOUCH!
If you want to fix something, you must edit 'tmpl/vmtc.inc.tmpl'
or insns2vm.rb
Modified: trunk/test.rb
===================================================================
--- trunk/test.rb 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/test.rb 2005-12-12 18:59:03 UTC (rev 311)
@@ -1,3 +1,6 @@
+
+__END__
+
pr = File.method(:basename)
#pr = pr.to_proc
#p pr
Modified: trunk/vm.c
===================================================================
--- trunk/vm.c 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/vm.c 2005-12-12 18:59:03 UTC (rev 311)
@@ -163,6 +163,7 @@
if(ENV_IN_HEAP_P(envptr)){
return ENV_VAL(envptr);
}
+
if(envptr != endptr){
VALUE *penvptr = GC_GUARDED_PTR_REF(*envptr);
yarv_control_frame_t *pcfp = cfp;
Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/yarvcore.h 2005-12-12 18:59:03 UTC (rev 311)
@@ -248,7 +248,7 @@
/* instruction sequence type */
int type;
-
+
/* klass/module nest information stack */
VALUE klass_nest_stack; /* Array */
VALUE klass;
Modified: trunk/yarvtest/test_syntax.rb
===================================================================
--- trunk/yarvtest/test_syntax.rb 2005-12-12 16:41:38 UTC (rev 310)
+++ trunk/yarvtest/test_syntax.rb 2005-12-12 18:59:03 UTC (rev 311)
@@ -359,7 +359,6 @@
}
sum
}
-
ae %q{
sum = 0
30.times{|ib|
@@ -369,6 +368,27 @@
}
sum
}
+ ae %q{
+ t = nil
+ "this must not print
+ Type: NUM
+ 123
+ 456
+ Type: ARP
+ aaa
+ bbb
+ \f
+ this must not print
+ hoge
+ Type: ARP
+ aaa
+ bbb
+ ".each{|l|
+ if (t = l[/^Type: (.*)/, 1])..(/^\f/ =~ l)
+ p [t, l]
+ end
+ }
+ }
end
def test_defined_vars
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml