Permalink
Browse files

Move compiler2 => compiler, and Compiler2 => Compiler

  • Loading branch information...
1 parent 5aa5cc6 commit 85e98490fe45446e03801840d4628149f8977098 @evanphx evanphx committed Jan 9, 2008
Showing with 169 additions and 6,469 deletions.
  1. +40 −59 Rakefile
  2. +1 −1 bin/ci
  3. +3 −2 kernel/core/compile.rb
  4. +2 −2 kernel/core/context.rb
  5. +1 −22 kernel/core/eval.rb
  6. +5 −5 lib/{compiler2 → compiler}/bytecode.rb
  7. +4 −4 lib/{compiler2 → compiler}/compile.rb
  8. +14 −14 lib/{compiler2 → compiler}/compiler.rb
  9. +2 −2 lib/{compiler2 → compiler}/describe.rb
  10. +3 −3 lib/{compiler2 → compiler}/execute.rb
  11. 0 lib/{compiler2 → compiler}/garnet/bindingagent.rb
  12. 0 lib/{compiler2 → compiler}/garnet/cerberus.rb
  13. 0 lib/{compiler2 → compiler}/garnet/garnet.rb
  14. 0 lib/{compiler2 → compiler}/garnet/test.rbo
  15. +5 −5 lib/{compiler2 → compiler}/generator.rb
  16. +7 −7 lib/{compiler2 → compiler}/graph.rb
  17. +3 −0 lib/compiler/init.rb
  18. +2 −2 lib/{compiler2 → compiler}/local.rb
  19. +3 −3 lib/{compiler2 → compiler}/macro.rb
  20. +6 −6 lib/{compiler2 → compiler}/nodes.rb
  21. +6 −6 lib/{compiler2 → compiler}/plugins.rb
  22. +1 −1 lib/{compiler2 → compiler}/system_hints.rb
  23. +2 −2 lib/{compiler2 → compiler}/text.rb
  24. +0 −551 lib/compiler1/bytecode/assembler.rb
  25. +0 −2,607 lib/compiler1/bytecode/compiler.rb
  26. +0 −184 lib/compiler1/bytecode/disassembler.rb
  27. +0 −385 lib/compiler1/bytecode/plugins.rb
  28. +0 −148 lib/compiler1/bytecode/rubinius.rb
  29. +0 −36 lib/compiler1/bytecode/system_hints.rb
  30. +0 −4 lib/compiler1/init.rb
  31. +0 −46 lib/compiler1/sexp/composite_processor.rb
  32. +0 −31 lib/compiler1/sexp/exceptions.rb
  33. +0 −88 lib/compiler1/sexp/simple_processor.rb
  34. +0 −396 lib/compiler1/translation/local_scoping.rb
  35. +0 −351 lib/compiler1/translation/normalize.rb
  36. +0 −423 lib/compiler1/translation/states.rb
  37. +0 −3 lib/compiler2/init.rb
  38. BIN runtime/stable/compiler.rba
  39. +1 −1 shotgun/lib/Makefile
  40. +3 −3 shotgun/lib/genheader.rb
  41. +1 −117 lib/compiler1/bytecode/encoder.rb → shotgun/lib/instruction_info.rb
  42. +12 −12 shotgun/lib/instructions.rb
  43. +1 −1 spec/{compiler2 → compiler}/array_spec.rb
  44. +1 −1 spec/{compiler2 → compiler}/block_args_spec.rb
  45. +9 −6 spec/{compiler2 → compiler}/call_spec.rb
  46. +6 −1 spec/{compiler2 → compiler}/control_spec.rb
  47. +2 −2 spec/{compiler2 → compiler}/exception_spec.rb
  48. +1 −1 spec/{compiler2 → compiler}/hints_spec.rb
  49. +1 −1 spec/{compiler2 → compiler}/masgn_spec.rb
  50. +2 −2 spec/{compiler2 → compiler}/op_assign_spec.rb
  51. +9 −5 spec/{compiler2 → compiler}/scopes_spec.rb
  52. +1 −1 spec/{compiler2 → compiler}/simple_spec.rb
  53. +6 −6 spec/{compiler2 → compiler}/spec_helper.rb
  54. +3 −2 spec/{compiler2 → compiler}/variables_spec.rb
  55. +0 −26 spec/compiler1/compiler_helper.rb
  56. +0 −607 spec/compiler1/compiler_spec.rb
  57. +0 −69 spec/compiler1/localvars_spec.rb
  58. +0 −134 spec/compiler1/masgn_spec.rb
  59. +0 −72 spec/compiler1/translation/normalize_spec.rb
View
@@ -102,24 +102,20 @@ def create_load_order(files, output=".load_order.txt")
end
end
-def compile(name, output, check_mtime=false)
- dir = File.dirname(output)
+def compile(name, output=nil, check_mtime=false)
+ if output
+ dir = File.dirname(output)
- unless File.exists?(dir)
- FileUtils.mkdir_p dir
- end
-
- if check_mtime and File.exists?(output) and File.mtime(output) > File.mtime(name)
- return
+ unless File.exists?(dir)
+ FileUtils.mkdir_p dir
+ end
+
+ if check_mtime and File.exists?(output) and File.mtime(output) > File.mtime(name)
+ return
+ end
end
- if $compiler == :c2
- inc = "-Iruntime/stable/compiler2.rba -rcompiler2/init"
- elsif $compiler
- inc = "-I#{$compiler} -rcompiler1/init"
- else
- inc = ""
- end
+ inc = "-Iruntime/stable/compiler2.rba -rcompiler2/init"
if ENV['GDB']
sh "shotgun/rubinius --gdb #{inc} compile #{name} #{output}", :verbose => $verbose
@@ -138,11 +134,6 @@ task :stable_compiler do
if ENV['USE_CURRENT']
puts "Use current versions, not stable."
else
- if ENV['USE_C1']
- $compiler = "runtime/stable/compiler1.rba"
- else
- $compiler = :c2
- end
ENV['RBX_BOOTSTRAP'] = "runtime/stable/bootstrap.rba"
ENV['RBX_CORE'] = "runtime/stable/core.rba"
ENV['RBX_LOADER'] = "runtime/stable/loader.rbc"
@@ -266,12 +257,8 @@ file 'runtime/stable/loader.rbc' => 'runtime/loader.rbc' do
cp 'runtime/loader.rbc', 'runtime/stable', :verbose => $verbose
end
-file 'runtime/stable/compiler1.rba' => 'build:compiler1' do
- sh "cd lib; zip -r ../runtime/stable/compiler1.rba compiler1 -x \\*.rb"
-end
-
-file 'runtime/stable/compiler2.rba' => 'build:compiler2' do
- sh "cd lib; zip -r ../runtime/stable/compiler2.rba compiler2 -x \\*.rb"
+file 'runtime/stable/compiler.rba' => 'build:compiler' do
+ sh "cd lib; zip -r ../runtime/stable/compiler.rba compiler -x \\*.rb"
end
Rake::StructGeneratorTask.new do |t|
@@ -409,8 +396,7 @@ task :pristine do
FileList['**/*.rbc'].each do |fn|
next if /^runtime/.match(fn)
next if %r!fixtures/require!.match(fn)
- next if %r!lib/compiler1!.match(fn)
- next if %r!lib/compiler2!.match(fn)
+ next if %r!lib/compiler!.match(fn)
FileUtils.rm fn rescue nil
end
end
@@ -423,11 +409,7 @@ namespace :clean do
rm_f f, :verbose => $verbose
end
- (Dir["lib/compiler1/*.rbc"] + Dir["lib/compiler1/**/*.rbc"]).each do |f|
- rm_f f, :verbose => $verbose
- end
-
- (Dir["lib/compiler2/*.rbc"] + Dir["lib/compiler2/**/*.rbc"]).each do |f|
+ (Dir["lib/compiler/*.rbc"] + Dir["lib/compiler/**/*.rbc"]).each do |f|
rm_f f, :verbose => $verbose
end
@@ -458,8 +440,7 @@ namespace :build do
build:shotgun
build:platform
build:rbc
- compiler1
- compiler2
+ compiler
lib/etc.rb
lib/rbconfig.rb
extensions
@@ -496,21 +477,16 @@ namespace :build do
task :rbc => ([:setup_rbc] + AllPreCompiled)
- task :compiler1 => :stable_compiler do
- compile_dir "lib/compiler1"
- end
-
- task :compiler2 => :stable_compiler do
- compile_dir "lib/compiler2"
+ task :compiler => :stable_compiler do
+ compile_dir "lib/compiler"
end
desc "Rebuild runtime/stable/*. If you don't know why you're running this, don't."
task :stable => %w[
build:all
runtime/stable/bootstrap.rba
runtime/stable/core.rba
- runtime/stable/compiler1.rba
- runtime/stable/compiler2.rba
+ runtime/stable/compiler.rba
runtime/stable/loader.rbc
runtime/stable/platform.rba
]
@@ -658,7 +634,7 @@ namespace :extension do
'lib/ext/digest/md5/*.h',
'lib/ext/digest/defs.h',
] do
- sh './shotgun/rubinius compile lib/ext/digest/md5'
+ compile 'lib/ext/digest/md5'
end
task :fcntl => "lib/ext/fcntl/fcntl.#{$dlext}"
@@ -668,7 +644,7 @@ namespace :extension do
'lib/ext/fcntl/build.rb',
'lib/ext/fcntl/*.c'
] do
- sh "./shotgun/rubinius compile lib/ext/fcntl"
+ compile "lib/ext/fcntl"
end
task :syck => "lib/ext/syck/rbxext.#{$dlext}"
@@ -679,7 +655,7 @@ namespace :extension do
'lib/ext/syck/*.c',
'lib/ext/syck/*.h',
] do
- sh "./shotgun/rubinius compile lib/ext/syck"
+ compile "lib/ext/syck"
end
task :mongrel => "lib/ext/mongrel/http11.#{$dlext}"
@@ -690,7 +666,7 @@ namespace :extension do
'lib/ext/mongrel/*.c',
'lib/ext/mongrel/*.h',
] do
- sh "./shotgun/rubinius compile lib/ext/mongrel"
+ compile "lib/ext/mongrel"
end
task :zlib => %W[lib/ext/zlib/zlib.#{$dlext} lib/zlib.rb]
@@ -700,7 +676,7 @@ namespace :extension do
'lib/ext/zlib/build.rb',
'lib/ext/zlib/*.c'
] do
- sh "./shotgun/rubinius compile lib/ext/zlib"
+ compile "lib/ext/zlib"
end
task :readline => %W[lib/ext/readline/readline.#{$dlext} lib/readline.rb]
@@ -710,7 +686,7 @@ namespace :extension do
'lib/ext/readline/build.rb',
'lib/ext/readline/*.c'
] do
- sh "./shotgun/rubinius compile lib/ext/readline"
+ compile "lib/ext/readline"
end
end
@@ -746,19 +722,24 @@ namespace "doc" do
desc "Generate HTML in doc/vm from YAML and Textile sources"
task "html"
-
- # Define tasks for each opcode html file on the corresponding YAML file
- require 'doc/vm/op_code_info'
- OpCode::Info.op_codes.each do |op|
- html = "doc/vm/op_codes/#{op}.html"
- yaml = "doc/vm/op_codes/#{op}.yaml"
- file html => yaml do
- cd 'doc/vm' do
- ruby "gen_op_code_html.rb #{op}"
+
+ begin
+ # Define tasks for each opcode html file on the corresponding YAML file
+ require 'doc/vm/op_code_info'
+ OpCode::Info.op_codes.each do |op|
+ html = "doc/vm/op_codes/#{op}.html"
+ yaml = "doc/vm/op_codes/#{op}.yaml"
+ file html => yaml do
+ cd 'doc/vm' do
+ ruby "gen_op_code_html.rb #{op}"
+ end
end
+
+ task "html" => html
end
- task "html" => html
+ rescue LoadError
+
end
# Define tasks for each section html file on the corresponding textile file
View
2 bin/ci
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-CI_FILE_SPECS = ['spec/ruby/1.8/core', 'spec/ruby/1.8/language', 'spec/compiler2', 'spec/parser']
+CI_FILE_SPECS = ['spec/ruby/1.8/core', 'spec/ruby/1.8/language', 'spec/compiler', 'spec/parser']
CI_EXCLUDES_DIR = File.expand_path(File.dirname(__FILE__) + '/../spec/data')
require File.dirname(__FILE__) + '/../mspec/scripts/ci'
View
@@ -11,7 +11,7 @@ module Compile
@compiler = nil
- DefaultCompiler = "compiler2"
+ DefaultCompiler = "compiler"
def self.register_compiler(obj)
if $DEBUG
@@ -24,7 +24,8 @@ def self.find_compiler
begin
require "#{DefaultCompiler}/init"
rescue Exception => e
- STDERR.puts "Unable to load default compiler"
+ STDERR.puts "Unable to load default compiler: #{e.message}"
+ puts e.backtrace.show
raise e
end
View
@@ -8,7 +8,7 @@ class MethodContext
# The Nth group of the last regexp match.
#
- # Implemented to support Compiler2.
+ # Implemented to support Compiler.
def nth_ref(n)
if lm = @last_match
return lm[n]
@@ -19,7 +19,7 @@ def nth_ref(n)
# One of the special globals $&, $`, $' or $+.
#
- # Implemented to support Compiler2.
+ # Implemented to support Compiler.
def back_ref(kind)
if lm = @last_match
res = case kind
View
@@ -93,28 +93,7 @@ def instance_eval(string = nil, filename = "(eval)", line = 1, &prc)
string = StringValue(string)
binding = Binding.setup(MethodContext.current.sender)
-
- text = false
- if text
- sexp = string.to_sexp(filename, line, true)
-
- require 'compiler2/init'
- require 'compiler2/text'
-
- p sexp
-
- comp = Compiler2.new(Compiler2::TextGenerator, binding) # flags[:binding])
- node = comp.convert_sexp([:eval_expression, sexp])
- p node
- meth = node.to_description
- puts ""
- puts meth.generator.text
- return nil
-
- return node.to_description(:__eval_script__).to_cmethod
- end
-
-
+
flags = { :binding => binding }
compiled_method = Compile.compile_string string, flags, filename, line
ctx = binding.context
@@ -1,9 +1,9 @@
# Implements methods on each Node subclass for generatng bytecode
# from itself.
-require 'compiler2/generator'
+require 'compiler/generator'
-class Compiler2
+class Compiler
class MethodDescription
def initialize(gen_class, locals)
@generator = gen_class.new
@@ -37,7 +37,7 @@ def inspect
end
end
-class Compiler2
+class Compiler
class Node
class GenerationError < Error; end
@@ -61,7 +61,7 @@ def show_errors(gen)
class ClosedScope
def new_description
- Compiler2::MethodDescription.new(@compiler.generator_class, self.locals)
+ Compiler::MethodDescription.new(@compiler.generator_class, self.locals)
end
def to_description(name=nil)
@@ -608,7 +608,7 @@ def bytecode(g)
# TESTED
class Iter
def bytecode(g)
- desc = Compiler2::MethodDescription.new @compiler.generator_class, @locals
+ desc = Compiler::MethodDescription.new @compiler.generator_class, @locals
desc.name = :__block__
sub = desc.generator
@@ -12,7 +12,7 @@
def interactive
require 'readline'
- c = Compiler2.new(Compiler2::Generator)
+ c = Compiler.new(Compiler::Generator)
puts "Enter ? for help, ^D to exit."
while code = Readline.readline("rbx:compile> ")
@@ -35,7 +35,7 @@ def interactive
# "Batch" mode
def batch(opts)
- c = Compiler2.new(Compiler2::Generator)
+ c = Compiler.new(Compiler::Generator)
verbose = opts['verbose']
# Loopty-doop
@@ -56,8 +56,8 @@ def batch(opts)
#TODO: Figure out why text generation breaks subsequent compilation
if verbose
old_gen = c.generator_class
- c.generator_class = Compiler2::TextGenerator
- txt = Compiler2::TextGenerator.new
+ c.generator_class = Compiler::TextGenerator
+ txt = Compiler::TextGenerator.new
n.bytecode(txt)
txt.close
puts txt.text
Oops, something went wrong.

0 comments on commit 85e9849

Please sign in to comment.