opal 0.8.0.beta1 → 0.8.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitmodules +0 -24
- data/.jshintrc +51 -0
- data/.travis.yml +6 -1
- data/CHANGELOG.md +2 -0
- data/Gemfile +3 -7
- data/README.md +2 -3
- data/Rakefile +1 -0
- data/lib/mspec/opal/rake_task.rb +1 -1
- data/lib/opal/builder.rb +21 -3
- data/lib/opal/builder_processors.rb +2 -2
- data/lib/opal/cli.rb +8 -5
- data/lib/opal/erb.rb +1 -1
- data/lib/opal/nodes/call.rb +1 -1
- data/lib/opal/nodes/call_special.rb +1 -1
- data/lib/opal/nodes/helpers.rb +6 -4
- data/lib/opal/nodes/iter.rb +2 -2
- data/lib/opal/nodes/singleton_class.rb +2 -1
- data/lib/opal/parser/lexer.rb +3 -2
- data/lib/opal/path_reader.rb +8 -1
- data/lib/opal/paths.rb +23 -16
- data/lib/opal/regexp_anchors.rb +5 -0
- data/lib/opal/sprockets/erb.rb +1 -1
- data/lib/opal/sprockets/processor.rb +21 -35
- data/lib/opal/sprockets/source_map_server.rb +5 -5
- data/lib/opal/version.rb +3 -1
- data/lib/tilt/opal.rb +11 -5
- data/opal.gemspec +2 -2
- data/opal/corelib/array.rb +196 -4
- data/opal/corelib/enumerable.rb +1 -1
- data/opal/corelib/enumerator.rb +2 -2
- data/opal/corelib/hash.rb +6 -6
- data/opal/corelib/kernel.rb +5 -3
- data/opal/corelib/module.rb +18 -12
- data/opal/corelib/regexp.rb +110 -4
- data/opal/corelib/runtime.js +12 -4
- data/opal/corelib/string.rb +51 -95
- data/opal/corelib/string/inheritance.rb +22 -0
- data/opal/corelib/variables.rb +1 -1
- data/spec/filters/bugs/array.rb +3 -39
- data/spec/filters/bugs/basic_object.rb +20 -0
- data/spec/filters/bugs/date.rb +5 -0
- data/spec/filters/bugs/enumerable.rb +9 -0
- data/spec/filters/bugs/enumerator.rb +0 -7
- data/spec/filters/bugs/hash.rb +2 -0
- data/spec/filters/bugs/kernel.rb +5 -0
- data/spec/filters/bugs/language.rb +14 -0
- data/spec/filters/bugs/method.rb +5 -0
- data/spec/filters/bugs/module.rb +23 -0
- data/spec/filters/bugs/regular_expressions.rb +41 -0
- data/spec/filters/bugs/singleton.rb +3 -0
- data/spec/filters/bugs/string.rb +2 -9
- data/spec/filters/bugs/stringscanner.rb +3 -0
- data/spec/filters/bugs/time.rb +19 -0
- data/spec/filters/unsupported/module.rb +6 -0
- data/spec/filters/unsupported/mutable_strings.rb +8 -0
- data/spec/filters/unsupported/regular_expressions.rb +90 -0
- data/spec/lib/builder_spec.rb +12 -6
- data/spec/lib/cli_spec.rb +2 -2
- data/spec/lib/path_reader_spec.rb +12 -0
- data/spec/lib/sprockets/server_spec.rb +7 -8
- data/spec/lib/tilt/opal_spec.rb +18 -0
- data/spec/opal/core/language/regexp_spec.rb +1 -1
- data/spec/opal/core/runtime/bridged_classes_spec.rb +48 -1
- data/spec/rubyspecs +88 -78
- data/stdlib/encoding.rb +3 -0
- data/stdlib/native.rb +1 -1
- data/stdlib/pp.rb +27 -6
- data/stdlib/set.rb +10 -0
- data/tasks/linting.rake +18 -0
- data/tasks/testing.rake +11 -4
- data/{stdlib → vendored-minitest}/minitest.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/assertions.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/autorun.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/benchmark.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/expectations.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/hell.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/mock.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/parallel.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/pride.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/pride_plugin.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/spec.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/test.rb +0 -0
- data/{stdlib → vendored-minitest}/minitest/unit.rb +0 -0
- data/vendored-minitest/test/unit.rb +23 -0
- metadata +31 -29
- data/stdlib/test/unit.rb +0 -10
- data/tasks/documentation.rake +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3afa0a5d5b918de046d4985b97fa8464b5e73014
|
4
|
+
data.tar.gz: a0a71fde911085d35f81cf363dd1d6569cb2119f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a64a3b104c5b74e7fece49e701449e0bc69d55883848622e5697cd69aa228203ad78ca8d692af4da0d81bc3b950b31cfbbb053c99a2ccfa0fe7048aded6787c1
|
7
|
+
data.tar.gz: c1f7ca3700b01bac88d7c401d7d2affe59985738415a9dd82aebf2217943d81d61a50e37827f1114a727bf30b33e4a511ffad3ab7e8b606cc1c466023c10ddd8
|
data/.gitmodules
CHANGED
@@ -1,30 +1,6 @@
|
|
1
1
|
[submodule "spec/corelib"]
|
2
2
|
path = spec/corelib
|
3
3
|
url = https://github.com/opal/rubyspec
|
4
|
-
[submodule "spec/stdlib/rubysl-singleton"]
|
5
|
-
path = spec/stdlib/rubysl-singleton
|
6
|
-
url = https://github.com/rubysl/rubysl-singleton
|
7
|
-
[submodule "spec/stdlib/rubysl-observer"]
|
8
|
-
path = spec/stdlib/rubysl-observer
|
9
|
-
url = https://github.com/rubysl/rubysl-observer
|
10
|
-
[submodule "spec/stdlib/rubysl-strscan"]
|
11
|
-
path = spec/stdlib/rubysl-strscan
|
12
|
-
url = https://github.com/rubysl/rubysl-strscan
|
13
|
-
[submodule "spec/stdlib/rubysl-delegate"]
|
14
|
-
path = spec/stdlib/rubysl-delegate
|
15
|
-
url = https://github.com/rubysl/rubysl-delegate
|
16
|
-
[submodule "spec/stdlib/rubysl-erb"]
|
17
|
-
path = spec/stdlib/rubysl-erb
|
18
|
-
url = https://github.com/rubysl/rubysl-erb
|
19
|
-
[submodule "spec/stdlib/rubysl-set"]
|
20
|
-
path = spec/stdlib/rubysl-set
|
21
|
-
url = https://github.com/rubysl/rubysl-set
|
22
|
-
[submodule "spec/stdlib/rubysl-pathname"]
|
23
|
-
path = spec/stdlib/rubysl-pathname
|
24
|
-
url = https://github.com/rubysl/rubysl-pathname
|
25
|
-
[submodule "spec/stdlib/rubysl-date"]
|
26
|
-
path = spec/stdlib/rubysl-date
|
27
|
-
url = https://github.com/rubysl/rubysl-date
|
28
4
|
[submodule "test/cruby"]
|
29
5
|
path = test/cruby
|
30
6
|
url = https://github.com/ruby/ruby.git
|
data/.jshintrc
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
{
|
2
|
+
// http://jshint.com/docs/options
|
3
|
+
|
4
|
+
"curly" : true, // Require curly braces around blocks in loops and conditionals
|
5
|
+
"eqeqeq" : true, // Prohibit the use of == and != in favor of === and !==
|
6
|
+
"es3" : true, // Adhere to ECMAScript 3 specification
|
7
|
+
"forin" : true, // Require all for in loops to filter object's items (hasOwnProperty)
|
8
|
+
"latedef" : true, // Prohibit the use of a variable before it was defined
|
9
|
+
"noarg" : true, // Prohibit the use of arguments.caller and arguments.callee
|
10
|
+
"nonbsp" : true, // Warn about "non-breaking whitespace" characters
|
11
|
+
"undef" : true, // Prohibit the use of explicitly undeclared variables
|
12
|
+
"unused" : true, // Warn when you define and never use your variables
|
13
|
+
|
14
|
+
"globals": {
|
15
|
+
"Opal": true,
|
16
|
+
"OpalNode": true,
|
17
|
+
"callPhantom": true,
|
18
|
+
"JSON": true
|
19
|
+
},
|
20
|
+
|
21
|
+
"browser": true,
|
22
|
+
"node": true,
|
23
|
+
|
24
|
+
// Currently the following checks are failing:
|
25
|
+
|
26
|
+
"-W003": false, // 'variable' was used before it was defined
|
27
|
+
"-W004": false, // 'variable' is already defined
|
28
|
+
"-W018": false, // Confusing use of '!'
|
29
|
+
"-W021": false, // '$ClassName' is a function
|
30
|
+
"-W024": false, // Expected an identifier and instead saw 'eval' (a reserved word)
|
31
|
+
"-W027": false, // Unreachable ';' after 'return'
|
32
|
+
"-W032": false, // Unnecessary semicolon
|
33
|
+
"-W030": false, // Expected an assignment or function call and instead saw an expression
|
34
|
+
"-W033": false, // Missing semicolon
|
35
|
+
"-W038": false, // 'variable' used out of scope
|
36
|
+
"-W041": false, // Use '===' to compare with 'true'
|
37
|
+
"-W049": false, // Unexpected escaped character '<' in regular expression
|
38
|
+
"-W053": false, // Do not use String as a constructor
|
39
|
+
"-W058": false, // Missing '()' invoking a constructor
|
40
|
+
"-W061": false, // eval can be harmful
|
41
|
+
"-W065": false, // Missing radix parameter
|
42
|
+
"-W069": false, // ['prop'] is better written in dot notation
|
43
|
+
"-W080": false, // It's not necessary to initialize 'result' to 'undefined'
|
44
|
+
"-W083": false, // Don't make functions within a loop
|
45
|
+
"-W086": false, // Expected a 'break' statement before 'case'
|
46
|
+
"-W089": false, // The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype
|
47
|
+
"-W093": false, // Did you mean to return a conditional instead of an assignment?
|
48
|
+
"-W098": false, // 'variable' is defined but never used
|
49
|
+
"-W116": false, // Expected '===' and instead saw '=='
|
50
|
+
"-W120": false // You might be leaking a variable ($ClassName) here
|
51
|
+
}
|
data/.travis.yml
CHANGED
@@ -13,7 +13,7 @@ matrix:
|
|
13
13
|
env: RUN=default TZ="/usr/share/zoneinfo/Pacific/Fiji"
|
14
14
|
|
15
15
|
- rvm: 2.2
|
16
|
-
env: RUN=
|
16
|
+
env: RUN=rspec TILT_VERSION=2.0.1
|
17
17
|
|
18
18
|
- rvm: 2.1
|
19
19
|
env: RUN=rspec
|
@@ -33,6 +33,11 @@ matrix:
|
|
33
33
|
- rvm: jruby-head
|
34
34
|
env: RUN=rspec
|
35
35
|
|
36
|
+
- rvm: 2.2
|
37
|
+
script:
|
38
|
+
- npm install -g jshint
|
39
|
+
- bundle exec rake lint
|
40
|
+
|
36
41
|
allow_failures:
|
37
42
|
- rvm: 1.8.7
|
38
43
|
- rvm: 1.9.3
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -9,15 +9,14 @@ gem 'json', '< 1.8.1' if RUBY_VERSION.to_f == 2.1 and RUBY_ENGINE == 'ruby'
|
|
9
9
|
gem 'rubysl', :platform => :rbx
|
10
10
|
gem 'thin', platform: :mri
|
11
11
|
|
12
|
-
# Uncomment to try with sprockets 3.0:
|
13
|
-
#
|
14
|
-
# gem 'sprockets', '~> 3.0.0.beta'
|
15
|
-
|
16
12
|
group :repl do
|
17
13
|
gem 'therubyracer', :platform => :mri, :require => 'v8'
|
18
14
|
gem 'therubyrhino', :platform => :jruby
|
19
15
|
end
|
20
16
|
|
17
|
+
tilt_version = ENV['TILT_VERSION']
|
18
|
+
gem 'tilt', tilt_version if tilt_version
|
19
|
+
|
21
20
|
unless ENV['CI']
|
22
21
|
gem 'rb-fsevent'
|
23
22
|
gem 'guard', require: false
|
@@ -25,6 +24,3 @@ unless ENV['CI']
|
|
25
24
|
end
|
26
25
|
|
27
26
|
gem 'mspec', github: 'rubyspec/mspec'
|
28
|
-
|
29
|
-
sprockets_version = ENV['SPROCKETS_VERSION']
|
30
|
-
gem 'sprockets', sprockets_version if sprockets_version
|
data/README.md
CHANGED
@@ -7,9 +7,8 @@
|
|
7
7
|
Opal is a ruby to javascript source-to-source compiler. It also has an
|
8
8
|
implementation of the ruby corelib.
|
9
9
|
|
10
|
-
Opal is [hosted on github](http://github.com/opal/opal)
|
11
|
-
|
12
|
-
ask questions on [stackoverflow (tag #opalrb)](http://stackoverflow.com/questions/ask?tags=opalrb).
|
10
|
+
Opal is [hosted on github](http://github.com/opal/opal). Chat is available on *Gitter* at [opal/opal](https://gitter.im/opal/opal) and the Freenode IRC channel at [#opal](http://webchat.freenode.net/?channels=opal).
|
11
|
+
Ask questions on [stackoverflow (tag #opalrb)](http://stackoverflow.com/questions/ask?tags=opalrb). Get the [Opalist newsletter](http://opalist.co) for updates and community news.
|
13
12
|
|
14
13
|
[](http://opalrb.org/docs/api)
|
15
14
|
[](https://gitter.im/opal/opal)
|
data/Rakefile
CHANGED
data/lib/mspec/opal/rake_task.rb
CHANGED
data/lib/opal/builder.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'opal/path_reader'
|
2
2
|
require 'opal/builder_processors'
|
3
|
+
require 'opal/paths'
|
3
4
|
require 'set'
|
4
5
|
|
5
6
|
module Opal
|
@@ -42,13 +43,24 @@ module Opal
|
|
42
43
|
processed << asset
|
43
44
|
self
|
44
45
|
rescue MissingRequire => error
|
45
|
-
raise error, "A file required by #{filename.inspect} wasn't found.\n#{error.message}"
|
46
|
+
raise error, "A file required by #{filename.inspect} wasn't found.\n#{error.message}", error.backtrace
|
46
47
|
end
|
47
48
|
|
48
49
|
def build_require(path, options = {})
|
49
50
|
process_require(path, options)
|
50
51
|
end
|
51
52
|
|
53
|
+
def initialize_copy(other)
|
54
|
+
super
|
55
|
+
@stubs = other.stubs.dup
|
56
|
+
@preload = other.preload.dup
|
57
|
+
@processors = other.processors.dup
|
58
|
+
@path_reader = other.path_reader.dup
|
59
|
+
@prerequired = other.prerequired.dup
|
60
|
+
@compiler_options = other.compiler_options.dup
|
61
|
+
@processed = other.processed.dup
|
62
|
+
end
|
63
|
+
|
52
64
|
def to_s
|
53
65
|
processed.map(&:to_s).join("\n")
|
54
66
|
end
|
@@ -57,6 +69,12 @@ module Opal
|
|
57
69
|
processed.map(&:source_map).reduce(:+).as_json.to_json
|
58
70
|
end
|
59
71
|
|
72
|
+
def append_paths(*paths)
|
73
|
+
path_reader.append_paths(*paths)
|
74
|
+
end
|
75
|
+
|
76
|
+
include UseGem
|
77
|
+
|
60
78
|
attr_reader :processed
|
61
79
|
|
62
80
|
attr_accessor :processors, :default_processor, :path_reader,
|
@@ -84,7 +102,7 @@ module Opal
|
|
84
102
|
globs = extensions.map { |ext| File.join base, tree, '**', "*.#{ext}" }
|
85
103
|
|
86
104
|
Dir[*globs].map do |file|
|
87
|
-
Pathname(file).relative_path_from(Pathname(base)).to_s.gsub(/(\.js)?(\.(?:#{extensions.join '|'}))
|
105
|
+
Pathname(file).relative_path_from(Pathname(base)).to_s.gsub(/(\.js)?(\.(?:#{extensions.join '|'}))#{REGEXP_END}/, '')
|
88
106
|
end
|
89
107
|
end
|
90
108
|
end
|
@@ -101,7 +119,7 @@ module Opal
|
|
101
119
|
end
|
102
120
|
|
103
121
|
def process_require(filename, options)
|
104
|
-
filename.gsub!(/\.(rb|js|opal)
|
122
|
+
filename.gsub!(/\.(rb|js|opal)#{REGEXP_END}/, '')
|
105
123
|
return if prerequired.include?(filename)
|
106
124
|
return if already_processed.include?(filename)
|
107
125
|
already_processed << filename
|
@@ -27,7 +27,7 @@ module Opal
|
|
27
27
|
matches = extensions.join('|')
|
28
28
|
matches = "(#{matches})" if extensions.size == 1
|
29
29
|
|
30
|
-
@match_regexp = Regexp.new "\\.#{matches}
|
30
|
+
@match_regexp = Regexp.new "\\.#{matches}#{REGEXP_END}"
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.extensions
|
@@ -87,7 +87,7 @@ module Opal
|
|
87
87
|
|
88
88
|
def compiled
|
89
89
|
@compiled ||= begin
|
90
|
-
compiler = compiler_for(@source, file: @filename.gsub(/\.(rb|js|opal)
|
90
|
+
compiler = compiler_for(@source, file: @filename.gsub(/\.(rb|js|opal)#{REGEXP_END}/, ''))
|
91
91
|
compiler.compile
|
92
92
|
compiler
|
93
93
|
end
|
data/lib/opal/cli.rb
CHANGED
@@ -87,11 +87,10 @@ module Opal
|
|
87
87
|
|
88
88
|
attr_reader :exit_status
|
89
89
|
|
90
|
-
def
|
91
|
-
Opal.paths.concat load_paths
|
92
|
-
gems.each { |gem_name| Opal.use_gem gem_name }
|
93
|
-
|
90
|
+
def build
|
94
91
|
builder = Opal::Builder.new stubs: stubs, compiler_options: compiler_options
|
92
|
+
builder.append_paths(*load_paths)
|
93
|
+
gems.each { |gem_name| builder.use_gem gem_name }
|
95
94
|
|
96
95
|
builder.build 'opal' unless skip_opal_require?
|
97
96
|
|
@@ -116,7 +115,11 @@ module Opal
|
|
116
115
|
|
117
116
|
builder.build_str 'Kernel.exit', '(exit)' unless no_exit
|
118
117
|
|
119
|
-
builder
|
118
|
+
builder
|
119
|
+
end
|
120
|
+
|
121
|
+
def compiled_source
|
122
|
+
build.to_s
|
120
123
|
end
|
121
124
|
|
122
125
|
def show_compiled_source
|
data/lib/opal/erb.rb
CHANGED
@@ -76,7 +76,7 @@ module Opal
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def wrap_compiled(result)
|
79
|
-
path = @file_name.sub(/\.opalerb
|
79
|
+
path = @file_name.sub(/\.opalerb#{REGEXP_END}/, '')
|
80
80
|
result = "Template.new('#{path}') do |output_buffer|\noutput_buffer.append(\"#{result}\")\noutput_buffer.join\nend\n"
|
81
81
|
end
|
82
82
|
end
|
data/lib/opal/nodes/call.rb
CHANGED
@@ -12,7 +12,7 @@ module Opal
|
|
12
12
|
|
13
13
|
def default_compile
|
14
14
|
# Skip, for now, if the method has square brackets: []=
|
15
|
-
return super if meth.to_s !~
|
15
|
+
return super if meth.to_s !~ /#{REGEXP_START}\w+=#{REGEXP_END}/
|
16
16
|
|
17
17
|
with_temp do |args_tmp|
|
18
18
|
with_temp do |recv_tmp|
|
data/lib/opal/nodes/helpers.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
+
require 'opal/regexp_anchors'
|
2
|
+
|
1
3
|
module Opal
|
2
4
|
module Nodes
|
3
5
|
module Helpers
|
4
6
|
|
5
7
|
# Reserved javascript keywords - we cannot create variables with the
|
6
8
|
# same name (ref: http://stackoverflow.com/a/9337272/601782)
|
7
|
-
ES51_RESERVED_WORD =
|
9
|
+
ES51_RESERVED_WORD = /#{REGEXP_START}(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)#{REGEXP_END}/
|
8
10
|
|
9
11
|
# ES3 reserved words that aren’t ES5.1 reserved words
|
10
|
-
ES3_RESERVED_WORD_EXCLUSIVE =
|
12
|
+
ES3_RESERVED_WORD_EXCLUSIVE = /#{REGEXP_START}(?:int|byte|char|goto|long|final|float|short|double|native|throws|boolean|abstract|volatile|transient|synchronized)#{REGEXP_END}/
|
11
13
|
|
12
14
|
# Immutable properties of the global object
|
13
|
-
IMMUTABLE_PROPS =
|
15
|
+
IMMUTABLE_PROPS = /#{REGEXP_START}(?:NaN|Infinity|undefined)#{REGEXP_END}/
|
14
16
|
|
15
17
|
# Doesn't take in account utf8
|
16
|
-
BASIC_IDENTIFIER_RULES =
|
18
|
+
BASIC_IDENTIFIER_RULES = /#{REGEXP_START}[$_a-z][$_a-z\d]*#{REGEXP_END}/i
|
17
19
|
|
18
20
|
|
19
21
|
def property(name)
|
data/lib/opal/nodes/iter.rb
CHANGED
@@ -67,7 +67,7 @@ module Opal
|
|
67
67
|
elsif arg.type == :array
|
68
68
|
arg[1..-1].each_with_index do |_arg, _idx|
|
69
69
|
_arg = variable(_arg[1])
|
70
|
-
push "#{_arg} = #{params[idx]}[#{_idx}];"
|
70
|
+
push "var #{_arg} = #{params[idx]}[#{_idx}];"
|
71
71
|
end
|
72
72
|
else
|
73
73
|
raise "Bad block arg type"
|
@@ -115,7 +115,7 @@ module Opal
|
|
115
115
|
sexp.each do |arg|
|
116
116
|
if arg[0] == :lasgn
|
117
117
|
ref = variable(arg[1])
|
118
|
-
|
118
|
+
self.add_arg ref
|
119
119
|
result << ref
|
120
120
|
elsif arg[0] == :array
|
121
121
|
result << scope.next_temp
|
@@ -14,8 +14,9 @@ module Opal
|
|
14
14
|
add_temp '$scope = self.$$scope'
|
15
15
|
add_temp 'def = self.$$proto'
|
16
16
|
|
17
|
+
body_stmt = stmt(compiler.returns(body))
|
17
18
|
line scope.to_vars
|
18
|
-
line
|
19
|
+
line body_stmt
|
19
20
|
end
|
20
21
|
|
21
22
|
line "})(", recv(object), ".$singleton_class())"
|
data/lib/opal/parser/lexer.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'opal/regexp_anchors'
|
1
2
|
require 'strscan'
|
2
3
|
require 'opal/parser/keywords'
|
3
4
|
|
@@ -558,7 +559,7 @@ module Opal
|
|
558
559
|
matched += scanner.matched
|
559
560
|
end
|
560
561
|
|
561
|
-
elsif matched =~
|
562
|
+
elsif matched =~ /#{REGEXP_START}[A-Z]/
|
562
563
|
result = :tCONSTANT
|
563
564
|
else
|
564
565
|
result = :tIDENTIFIER
|
@@ -627,7 +628,7 @@ module Opal
|
|
627
628
|
@lex_state = :expr_end
|
628
629
|
end
|
629
630
|
|
630
|
-
return matched =~
|
631
|
+
return matched =~ /#{REGEXP_START}[A-Z]/ ? :tCONSTANT : :tIDENTIFIER
|
631
632
|
end
|
632
633
|
|
633
634
|
# Does the heavy lifting for `next_token`.
|
data/lib/opal/path_reader.rb
CHANGED
@@ -13,13 +13,20 @@ module Opal
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def expand(path)
|
16
|
-
|
16
|
+
if Pathname.new(path).absolute? || path =~ %r{\A\.?\.#{File::SEPARATOR}}
|
17
|
+
path
|
18
|
+
else
|
19
|
+
file_finder.find(path)
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def paths
|
20
24
|
file_finder.paths
|
21
25
|
end
|
22
26
|
|
27
|
+
def append_paths(*paths)
|
28
|
+
file_finder.append_paths(*paths)
|
29
|
+
end
|
23
30
|
|
24
31
|
private
|
25
32
|
|
data/lib/opal/paths.rb
CHANGED
@@ -16,31 +16,38 @@ module Opal
|
|
16
16
|
# here should only be paths which contain code targeted at being compiled by
|
17
17
|
# Opal.
|
18
18
|
def self.append_path(path)
|
19
|
-
|
19
|
+
append_paths(path)
|
20
|
+
end
|
21
|
+
def self.append_paths(*paths)
|
22
|
+
self.paths.concat(paths)
|
20
23
|
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
module UseGem
|
26
|
+
def use_gem(gem_name, include_dependencies = true)
|
27
|
+
append_paths(*require_paths_for_gem(gem_name, include_dependencies))
|
25
28
|
end
|
26
|
-
|
29
|
+
|
30
|
+
private
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
def require_paths_for_gem(gem_name, include_dependencies)
|
33
|
+
paths = []
|
34
|
+
spec = Gem::Specification.find_by_name(gem_name)
|
31
35
|
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
spec.runtime_dependencies.each do |dependency|
|
37
|
+
paths += require_paths_for_gem(dependency.name, include_dependencies)
|
38
|
+
end if include_dependencies
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
+
gem_dir = spec.gem_dir
|
41
|
+
spec.require_paths.map do |path|
|
42
|
+
paths << File.join(gem_dir, path)
|
43
|
+
end
|
40
44
|
|
41
|
-
|
45
|
+
paths
|
46
|
+
end
|
42
47
|
end
|
43
48
|
|
49
|
+
extend UseGem
|
50
|
+
|
44
51
|
# Private, don't add to these directly (use .append_path instead).
|
45
52
|
def self.paths
|
46
53
|
@paths ||= [core_dir.untaint, std_dir.untaint, gem_dir.untaint]
|