Skip to content

Commit ceee797

Browse files
committedJun 17, 2014
Remove const_missing compiler option
1 parent 63a99aa commit ceee797

File tree

6 files changed

+8
-21
lines changed

6 files changed

+8
-21
lines changed
 

‎CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
* Cleanup generated code for constant access. All constant lookups now go through `$scope.get('CONST_NAME')` to produce cleaner code and a unified place for const missing dispatch.
1515

16+
* Remove `const_missing` option from compiler. All constant lookups are now strict.
17+
1618
## 0.6.2 2014-04-25
1719

1820
* Added Range#size

‎lib/opal/cli.rb

-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ def processor_option_names
126126
%w[
127127
method_missing_enabled
128128
arity_check_enabled
129-
const_missing_enabled
130129
dynamic_require_severity
131130
source_map_enabled
132131
irb_enabled

‎lib/opal/cli_options.rb

-4
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ def initialize
103103
options[:arity_check] = true
104104
end
105105

106-
on('-C', '--no-const-missing', 'Enable/Disable const missing') do
107-
options[:const_missing] = false
108-
end
109-
110106
dynamic_require_levels = %w[error warning ignore]
111107
on('-D', '--dynamic-require LEVEL', dynamic_require_levels,
112108
'Set level of dynamic require severity.',

‎lib/opal/compiler.rb

-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ def self.compiler_option(name, default_value, options = {})
3636
# adds an arity check to every method definition
3737
compiler_option :arity_check, false, :as => :arity_check?
3838

39-
# checks every constant access, delagating to const_missing if needed
40-
compiler_option :const_missing, false, :as => :const_missing?
41-
4239
# compile top level local vars with support for irb style vars
4340
compiler_option :irb, false, :as => :irb?
4441

‎lib/opal/nodes/constants.rb

+4-11
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ class ConstNode < Base
1010
def compile
1111
if name == :DATA and compiler.eof_content
1212
push("$__END__")
13-
elsif compiler.const_missing?
14-
push "$scope.get('#{name}')"
1513
else
16-
push "$scope.#{name}"
14+
push "$scope.get('#{name}')"
1715
end
1816
end
1917
end
@@ -49,14 +47,9 @@ class ConstGetNode < Base
4947
children :base, :name
5048

5149
def compile
52-
if compiler.const_missing?
53-
push "(("
54-
push expr(base)
55-
push ")._scope.get('#{name}'))"
56-
else
57-
push expr(base)
58-
wrap '(', ")._scope.#{name}"
59-
end
50+
push "(("
51+
push expr(base)
52+
push ")._scope.get('#{name}'))"
6053
end
6154
end
6255

‎spec/cli/compiler_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
end
4141

4242
it "should compile constant lookups" do
43-
expect_compiled("Object").to include("scope.Object")
44-
expect_compiled("Array").to include("scope.Array")
43+
expect_compiled("Object").to include("Object")
44+
expect_compiled("Array").to include("Array")
4545
end
4646

4747
describe "class names" do

0 commit comments

Comments
 (0)
Please sign in to comment.