Skip to content

Commit

Permalink
Remove defines_[defn|defs] flags from compiler
Browse files Browse the repository at this point in the history
These flags are no longer used, and exact targets of these methods are
determined at runtime instead of being hardcoded to the compiler.
  • Loading branch information
adambeynon committed Oct 14, 2013
1 parent 290f9cb commit 34f06e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
15 changes: 5 additions & 10 deletions lib/opal/parser.rb
Expand Up @@ -190,9 +190,6 @@ def top(sexp, options = {})
@scope.add_temp "self = $opal.top",
"$scope = $opal",
"nil = $opal.nil"
if @scope.defines_defn
@scope.add_temp "def = $opal.Object._proto"
end

@helpers.keys.each { |h| @scope.add_temp "$#{h} = $opal.#{h}" }

Expand Down Expand Up @@ -763,10 +760,6 @@ def process_iter(sexp, level)
code << f("\n#@indent", sexp)
code << process(body, :stmt)

if @scope.defines_defn
@scope.add_temp "def = ((self._isClass) ? self._proto : self)"
end

to_vars = [f("\n#@indent", sexp), @scope.to_vars, f("\n#@indent", sexp)]
end
end
Expand Down Expand Up @@ -1080,11 +1073,9 @@ def js_def(recvr, mid, args, stmts, line, end_line, sexp, level)
jsid = mid_to_jsid mid.to_s

if recvr
@scope.defines_defs = true
smethod = true if @scope.class_scope? && recvr.first == :self
recv = process(recvr)
else
@scope.defines_defn = true
recv = 'self'
end

Expand Down Expand Up @@ -1199,7 +1190,11 @@ def js_def(recvr, mid, args, stmts, line, end_line, sexp, level)
[f("#{uses_super}#{@scope.proto}#{jsid} = ", sexp), result]
elsif @scope.iter?
[f("$opal.defn(self, '$#{mid}', "), result, f(")")]
else # :top
elsif @scope.type == :sclass
[f("self._proto#{jsid} = ", sexp), result]
elsif @scope.type == :top
[f("$opal.Object._proto#{jsid} = ", sexp), result]
else
[f("def#{jsid} = ", sexp), result]
end

Expand Down
6 changes: 0 additions & 6 deletions lib/opal/target_scope.rb
Expand Up @@ -19,9 +19,6 @@ class TargetScope

attr_reader :type

attr_accessor :defines_defn
attr_accessor :defines_defs

# One of - :class, :module, :top, :iter, :def
attr_accessor :mid

Expand Down Expand Up @@ -51,9 +48,6 @@ def initialize(type, parser)
@unique = "a"
@while_stack = []

@defines_defs = false
@defines_defn = false

@methods = []

@uses_block = false
Expand Down

0 comments on commit 34f06e3

Please sign in to comment.