#wrapper versions of all commands that import code into a running program: #require, load, eval and friends. the wrapped versions pass the code to #import to rubylexervsruby, to test whether it gets lexed correctly. an #exception is raised if an lex error happens, else the code should behave #as normal, just much slower. class Kernel System_extension_extension= case RUBY_PLATFORM when /darwin/: 'o' when /windows/i: 'dll' else 'so' end System_ext_rex=/\.#{System_extension_extension}$/o def require_name_resolve(name) add_ext=case name when System_ext_rex,/\.rb$/: else name=/(#{name})(#{System_ext_rex}|\.rb)?/ end name=/#{File::SEPARATOR}#{name}$/ $:.find{|dir| dir.chomp File::SEPARATOR Dir[/#{dir}#{name}/] } end #reallyy jonesing for :wrap here alias stdlib__require require def require feat name=feat name=require_name_resolve(name) unless File.abs_path?(name) return(false) unless name return(true) if $".grep(feat) $"<name, :linenum=>linenum, :locals=>eval("local_variables",binding)) return stdlib__eval code,binding,filename,linenum end huh Binding.of_caller{|bg| eval code,bg,name,linenum} end huh#got to do module_eval, class_eval, instance_eval, etc end class Object alias stdlib__instance_eval instance_eval def instance_eval(code,&block) block and return stdlib__instance_eval &block eval code, stdlib__instance_eval{binding} end end class Module alias stdlib__module_eval module_eval alias module_eval instance_eval end class Class alias stdlib__class_eval class_eval alias class_eval instance_eval end class Binding alias stdlib__eval eval def eval code,name='(eval)',linenum=1 rubylexervsruby(code, :name=>name, :linenum=>linenum, :locals=>eval("local_variables",binding)) huh #should set code to (effectively) output of tokentest #how to do that within rubylexervsruby return stdlib__eval code,self,filename,linenum end end =begin def Module def new o=Object.extend self end end =end