Skip to content

Commit

Permalink
Rename Sexp#loc => Sexp#source
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Nov 24, 2013
1 parent bb85ba4 commit abf6f4d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion lib/opal/nodes/literal.rb
Expand Up @@ -59,7 +59,7 @@ def compile_split_lines(value, sexp)
push line
else
line_sexp = s()
line_sexp.loc = [sexp.line + idx, 0]
line_sexp.source = [sexp.line + idx, 0]
frag = Fragment.new(line, line_sexp)
push frag
end
Expand Down
48 changes: 24 additions & 24 deletions lib/opal/parser.rb
Expand Up @@ -59,13 +59,13 @@ def source(tok)

def s0(type, source)
sexp = s(type)
sexp.loc = source
sexp.source = source
sexp
end

def s1(type, first, source)
sexp = s(type, first)
sexp.loc = source
sexp.source = source
sexp
end

Expand Down Expand Up @@ -123,7 +123,7 @@ def new_const(tok)

def new_colon2(lhs, tok, name)
sexp = s(:colon2, lhs, value(name).to_sym)
sexp.loc = source(tok)
sexp.source = source(tok)
sexp
end

Expand All @@ -137,7 +137,7 @@ def new_sym(tok)

def new_alias(kw, new, old)
sexp = s(:alias, new, old)
sexp.loc = source(kw)
sexp.source = source(kw)
sexp
end

Expand Down Expand Up @@ -216,25 +216,25 @@ def new_def(kw, recv, name, args, body, end_tok)
body << s(:nil) if body.size == 1

sexp = s(:def, recv, value(name).to_sym, args, body)
sexp.loc = source(kw)
sexp.source = source(kw)
sexp
end

def new_class(start, path, sup, body, endt)
sexp = s(:class, path, sup, body)
sexp.loc = source(start)
sexp.source = source(start)
sexp
end

def new_sclass(kw, expr, body, end_tok)
sexp = s(:sclass, expr, body)
sexp.loc = source(kw)
sexp.source = source(kw)
sexp
end

def new_module(kw, path, body, end_tok)
sexp = s(:module, path, body)
sexp.loc = source(kw)
sexp.source = source(kw)
sexp
end

Expand All @@ -247,38 +247,38 @@ def new_iter(args, body)

def new_if(if_tok, expr, stmt, tail)
sexp = s(:if, expr, stmt, tail)
sexp.loc = source(if_tok)
sexp.source = source(if_tok)
sexp
end

def new_while(kw, test, body)
sexp = s(:while, test, body)
sexp.loc = source(kw)
sexp.source = source(kw)
sexp
end

def new_until(kw, test, body)
sexp = s(:until, test, body)
sexp.loc = source(kw)
sexp.source = source(kw)
sexp
end

def new_rescue_mod(kw, expr, resc)
sexp = s(:rescue_mod, expr, resc)
sexp.loc = source(kw)
sexp.source = source(kw)
sexp
end

def new_array(start, args, finish)
args ||= []
sexp = s(:array, *args)
sexp.loc = source(start)
sexp.source = source(start)
sexp
end

def new_hash(open, assocs, close)
sexp = s(:hash, *assocs)
sexp.loc = source(open)
sexp.source = source(open)
sexp
end

Expand Down Expand Up @@ -372,7 +372,7 @@ def new_block_args(norm, opt, rest, block)
def new_call(recv, meth, args = nil)
args ||= []
sexp = s(:call, recv, value(meth).to_sym, s(:arglist, *args))
sexp.loc = source(meth)
sexp.source = source(meth)
sexp
end

Expand All @@ -386,25 +386,25 @@ def new_unary_call(op, recv)

def new_and(lhs, tok, rhs)
sexp = s(:and, lhs, rhs)
sexp.loc = source(tok)
sexp.source = source(tok)
sexp
end

def new_or(lhs, tok, rhs)
sexp = s(:or, lhs, rhs)
sexp.loc = source(tok)
sexp.source = source(tok)
sexp
end

def new_irange(beg, op, finish)
sexp = s(:irange, beg, finish)
sexp.loc = source(op)
sexp.source = source(op)
sexp
end

def new_erange(beg, op, finish)
sexp = s(:erange, beg, finish)
sexp.loc = source(op)
sexp.source = source(op)
sexp
end

Expand Down Expand Up @@ -441,7 +441,7 @@ def new_op_asgn(op, lhs, rhs)
def new_op_asgn1(lhs, args, op, rhs)
arglist = s(:arglist, *args)
sexp = s(:op_asgn1, lhs, arglist, value(op), rhs)
sexp.loc = source(op)
sexp.source = source(op)
sexp
end

Expand Down Expand Up @@ -510,7 +510,7 @@ def new_gettable(ref)
raise "Bad new_gettable ref: #{ref.type}"
end

res.loc = ref.loc
res.source = ref.source
res
end

Expand All @@ -535,7 +535,7 @@ def new_var_ref(ref)
s(:call, nil, ref[1], s(:arglist))
end

result.loc = ref.loc
result.source = ref.source
result
else
raise "Bad var_ref type: #{ref.type}"
Expand All @@ -549,7 +549,7 @@ def new_super(kw, args)
sexp = s(:super, s(:arglist, *args))
end

sexp.loc = source(kw)
sexp.source = source(kw)
sexp
end

Expand All @@ -566,7 +566,7 @@ def new_xstr(start_t, str, end_t)
when :evstr then str = s(:dxstr, '', str)
end

str.loc = source(start_t)
str.source = source(start_t)

str
end
Expand Down
6 changes: 3 additions & 3 deletions lib/opal/parser/sexp.rb
Expand Up @@ -3,7 +3,7 @@ class Sexp

attr_reader :array

attr_accessor :loc
attr_accessor :source

def initialize(args)
@array = args
Expand Down Expand Up @@ -54,11 +54,11 @@ def ==(other)
alias eql? ==

def line
@loc && @loc[0]
@source && @source[0]
end

def column
@loc && @loc[1]
@source && @source[1]
end

def inspect
Expand Down

0 comments on commit abf6f4d

Please sign in to comment.