Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 423af6ce6a26
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 49aaf1cf8b9f
Choose a head ref

Commits on Oct 23, 2013

  1. Copy the full SHA
    bceb785 View commit details
  2. Copy the full SHA
    9afc625 View commit details
  3. Some more node generation

    adambeynon committed Oct 23, 2013
    Copy the full SHA
    b0fa09a View commit details
  4. Copy the full SHA
    320243e View commit details
  5. Copy the full SHA
    e5ea41e View commit details
  6. Copy the full SHA
    cda41cf View commit details
  7. Copy the full SHA
    c3489b2 View commit details
  8. Copy the full SHA
    999c542 View commit details
  9. Add some definition nodes

    adambeynon committed Oct 23, 2013
    Copy the full SHA
    7931e88 View commit details
  10. Copy the full SHA
    65cd7ab View commit details
  11. Copy the full SHA
    447ea4b View commit details
  12. Copy the full SHA
    b028dc7 View commit details
  13. Copy the full SHA
    bddd78c View commit details
  14. Copy the full SHA
    5ac0604 View commit details
  15. masgn compiler node

    adambeynon committed Oct 23, 2013
    Copy the full SHA
    b7a2ed4 View commit details
  16. Some more nodes

    adambeynon committed Oct 23, 2013
    Copy the full SHA
    f668dbd View commit details
  17. Copy the full SHA
    c2b7f14 View commit details
  18. Copy the full SHA
    f3ab61e View commit details
  19. Copy the full SHA
    ab6b019 View commit details
  20. Cleanup parser a little

    adambeynon committed Oct 23, 2013
    Copy the full SHA
    6ef6fc4 View commit details
  21. Copy the full SHA
    ecc6628 View commit details
  22. Copy the full SHA
    0a183c4 View commit details
  23. Cleanup node hierarchy

    adambeynon committed Oct 23, 2013
    Copy the full SHA
    b78ba9e View commit details
  24. Copy the full SHA
    41e83ca View commit details
  25. Use correct opal-sprockets

    adambeynon committed Oct 23, 2013
    Copy the full SHA
    49aaf1c View commit details
Showing with 3,090 additions and 2,425 deletions.
  1. +2 −0 Gemfile
  2. +2 −2 README.md
  3. +7 −8 Rakefile
  4. +4 −10 lib/opal.rb
  5. +4 −4 lib/opal/builder.rb
  6. +9 −20 lib/opal/cli.rb
  7. +310 −0 lib/opal/compiler.rb
  8. +16 −13 lib/opal/{require_parser.rb → dependency_compiler.rb}
  9. +3 −3 lib/opal/erb.rb
  10. +25 −27 lib/opal/fragment.rb
  11. +24 −0 lib/opal/nodes.rb
  12. +54 −0 lib/opal/nodes/array.rb
  13. +150 −0 lib/opal/nodes/base.rb
  14. +11 −0 lib/opal/nodes/base_scope.rb
  15. +146 −0 lib/opal/nodes/call.rb
  16. +132 −0 lib/opal/nodes/call_special.rb
  17. +96 −0 lib/opal/nodes/case.rb
  18. +43 −0 lib/opal/nodes/class.rb
  19. +91 −0 lib/opal/nodes/constants.rb
  20. +158 −0 lib/opal/nodes/def.rb
  21. +111 −0 lib/opal/nodes/defined.rb
  22. +182 −0 lib/opal/nodes/definitions.rb
  23. +67 −0 lib/opal/nodes/hash.rb
  24. +105 −0 lib/opal/nodes/helpers.rb
  25. +60 −0 lib/opal/nodes/if.rb
  26. +118 −0 lib/opal/nodes/iter.rb
  27. +193 −0 lib/opal/nodes/literal.rb
  28. +211 −0 lib/opal/nodes/logic.rb
  29. +62 −0 lib/opal/nodes/masgn.rb
  30. +46 −0 lib/opal/nodes/module.rb
  31. +134 −0 lib/opal/nodes/rescue.rb
  32. +26 −0 lib/opal/nodes/singleton_class.rb
  33. +97 −0 lib/opal/nodes/super.rb
  34. +63 −0 lib/opal/nodes/top.rb
  35. +155 −0 lib/opal/nodes/variables.rb
  36. +65 −0 lib/opal/nodes/while.rb
  37. +84 −0 lib/opal/nodes/yield.rb
  38. +0 −2,314 lib/opal/parser.rb
  39. +6 −6 lib/opal/target_scope.rb
  40. +1 −1 opal.gemspec
  41. +9 −9 spec/opal/parser/irb_spec.rb
  42. +1 −1 spec/opal/source_map_spec.rb
  43. +2 −2 spec/parser/parse_spec.rb
  44. +3 −3 stdlib/opal-gem.js.erb
  45. +1 −1 stdlib/opal-parser.rb
  46. +1 −1 stdlib/opal-source-maps.js.erb
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
source 'https://rubygems.org'
gemspec

gem 'opal-sprockets', :github => 'opal/opal-sprockets'

# Stick with older racc until
# https://github.com/tenderlove/racc/issues/32
# is solved.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -15,11 +15,11 @@ See the website, [http://opalrb.org](http://opalrb.org).

### Compiling ruby code

`Opal.parse` is a simple interface to just compile a string of ruby into a
`Opal.compile` is a simple interface to just compile a string of ruby into a
string of javascript code.

```ruby
Opal.parse("puts 'wow'") # => "(function() { ... })()"
Opal.compile("puts 'wow'") # => "(function() { ... })()"
```

Running this by itself is not enough, you need the opal runtime/corelib.
15 changes: 7 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -29,22 +29,22 @@ require 'opal-sprockets'
# We can't do this at runtime, so we hijack the method (and make sure we only
# do this at the top level). We figure out which file we are including, and
# add it to our require list
class ::Opal::Parser
alias_method :mspec_process_call, :process_call
class Opal::Compiler
alias_method :mspec_handle_call, :handle_call

def process_call(sexp, level)
if sexp[1] == :language_version and @scope.top?
lang_type = sexp[2][2][1]
def handle_call(sexp)
if sexp[2] == :language_version and @scope.top?
lang_type = sexp[3][2][1]
target = "rubyspec/language/versions/#{lang_type}_1.9"

if File.exist?(target)
@requires << target
end

return f("nil")
return fragment("nil")
end

mspec_process_call sexp, level
mspec_handle_call sexp
end
end

@@ -138,7 +138,6 @@ task :build_specs do

env = SpecEnvironment.new
env.build
env.build_min
end

desc <<-DESC
14 changes: 4 additions & 10 deletions lib/opal.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
require 'opal/parser'
require 'opal/require_parser'
require 'opal/compiler'
require 'opal/dependency_compiler'
require 'opal/builder'
require 'opal/erb'
require 'opal/version'

# Opal is a ruby to javascript compiler, with a runtime for running
# in any javascript environment.
#
# Opal::Parser is the core class used for parsing ruby and generating
# javascript from its syntax tree. Opal::Processor is the main system used
# for compiling larger programs. Opal::Processor uses sprockets to maintain
# an environment of load paths, which can be used to require other ruby or
# javascript sources.
module Opal

def self.parse(source, options = {})
Parser.new.parse(source, options)
def self.compile(source, options = {})
Compiler.new.compile(source, options)
end

def self.gem_dir
8 changes: 4 additions & 4 deletions lib/opal/builder.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'opal/require_parser'
require 'opal/dependency_compiler'
require 'erb'

module Opal
@@ -70,10 +70,10 @@ def build_asset(path)
end

def compile_ruby(str, options={})
parser = RequireParser.new
result = parser.parse str, options
compiler = DependencyCompiler.new
result = compiler.compile str, options

parser.requires.each do |r|
compiler.requires.each do |r|
require_asset r
end

29 changes: 9 additions & 20 deletions lib/opal/cli.rb
Original file line number Diff line number Diff line change
@@ -108,9 +108,9 @@ def show_compiled_source
if sprockets[filename]
puts sprockets[filename].to_a.last
elsif File.exist?(filename)
puts Opal.parse File.read(filename), options
puts Opal.compile File.read(filename), options
else
puts Opal.parse(filename, options)
puts Opal.compile(filename, options)
end
end

@@ -132,9 +132,9 @@ def set_processor_options
end

def map
parser = Opal::Parser.new
parser.parse(filename, options)
parser.source_map
compiler = Opal::Compiler.new
compiler.compile(filename, options)
compiler.source_map
end

def source
@@ -153,9 +153,7 @@ def processor_options
]
end




##
# SPROCKETS

def sprockets
@@ -184,18 +182,14 @@ def require_opal_sprockets
end
end




##
# OUTPUT

def puts *args
output.puts *args
end




##
# EVALS

def evals_source
@@ -215,16 +209,11 @@ def prepare_eval_code
end
end




##
# SOURCE

def sexp
Opal::Grammar.new.parse(source)
end



end
end
Loading