Skip to content

Commit abf6f4d

Browse files
committed
Rename Sexp#loc => Sexp#source
1 parent bb85ba4 commit abf6f4d

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

lib/opal/nodes/literal.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def compile_split_lines(value, sexp)
5959
push line
6060
else
6161
line_sexp = s()
62-
line_sexp.loc = [sexp.line + idx, 0]
62+
line_sexp.source = [sexp.line + idx, 0]
6363
frag = Fragment.new(line, line_sexp)
6464
push frag
6565
end

lib/opal/parser.rb

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ def source(tok)
5959

6060
def s0(type, source)
6161
sexp = s(type)
62-
sexp.loc = source
62+
sexp.source = source
6363
sexp
6464
end
6565

6666
def s1(type, first, source)
6767
sexp = s(type, first)
68-
sexp.loc = source
68+
sexp.source = source
6969
sexp
7070
end
7171

@@ -123,7 +123,7 @@ def new_const(tok)
123123

124124
def new_colon2(lhs, tok, name)
125125
sexp = s(:colon2, lhs, value(name).to_sym)
126-
sexp.loc = source(tok)
126+
sexp.source = source(tok)
127127
sexp
128128
end
129129

@@ -137,7 +137,7 @@ def new_sym(tok)
137137

138138
def new_alias(kw, new, old)
139139
sexp = s(:alias, new, old)
140-
sexp.loc = source(kw)
140+
sexp.source = source(kw)
141141
sexp
142142
end
143143

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

218218
sexp = s(:def, recv, value(name).to_sym, args, body)
219-
sexp.loc = source(kw)
219+
sexp.source = source(kw)
220220
sexp
221221
end
222222

223223
def new_class(start, path, sup, body, endt)
224224
sexp = s(:class, path, sup, body)
225-
sexp.loc = source(start)
225+
sexp.source = source(start)
226226
sexp
227227
end
228228

229229
def new_sclass(kw, expr, body, end_tok)
230230
sexp = s(:sclass, expr, body)
231-
sexp.loc = source(kw)
231+
sexp.source = source(kw)
232232
sexp
233233
end
234234

235235
def new_module(kw, path, body, end_tok)
236236
sexp = s(:module, path, body)
237-
sexp.loc = source(kw)
237+
sexp.source = source(kw)
238238
sexp
239239
end
240240

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

248248
def new_if(if_tok, expr, stmt, tail)
249249
sexp = s(:if, expr, stmt, tail)
250-
sexp.loc = source(if_tok)
250+
sexp.source = source(if_tok)
251251
sexp
252252
end
253253

254254
def new_while(kw, test, body)
255255
sexp = s(:while, test, body)
256-
sexp.loc = source(kw)
256+
sexp.source = source(kw)
257257
sexp
258258
end
259259

260260
def new_until(kw, test, body)
261261
sexp = s(:until, test, body)
262-
sexp.loc = source(kw)
262+
sexp.source = source(kw)
263263
sexp
264264
end
265265

266266
def new_rescue_mod(kw, expr, resc)
267267
sexp = s(:rescue_mod, expr, resc)
268-
sexp.loc = source(kw)
268+
sexp.source = source(kw)
269269
sexp
270270
end
271271

272272
def new_array(start, args, finish)
273273
args ||= []
274274
sexp = s(:array, *args)
275-
sexp.loc = source(start)
275+
sexp.source = source(start)
276276
sexp
277277
end
278278

279279
def new_hash(open, assocs, close)
280280
sexp = s(:hash, *assocs)
281-
sexp.loc = source(open)
281+
sexp.source = source(open)
282282
sexp
283283
end
284284

@@ -372,7 +372,7 @@ def new_block_args(norm, opt, rest, block)
372372
def new_call(recv, meth, args = nil)
373373
args ||= []
374374
sexp = s(:call, recv, value(meth).to_sym, s(:arglist, *args))
375-
sexp.loc = source(meth)
375+
sexp.source = source(meth)
376376
sexp
377377
end
378378

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

387387
def new_and(lhs, tok, rhs)
388388
sexp = s(:and, lhs, rhs)
389-
sexp.loc = source(tok)
389+
sexp.source = source(tok)
390390
sexp
391391
end
392392

393393
def new_or(lhs, tok, rhs)
394394
sexp = s(:or, lhs, rhs)
395-
sexp.loc = source(tok)
395+
sexp.source = source(tok)
396396
sexp
397397
end
398398

399399
def new_irange(beg, op, finish)
400400
sexp = s(:irange, beg, finish)
401-
sexp.loc = source(op)
401+
sexp.source = source(op)
402402
sexp
403403
end
404404

405405
def new_erange(beg, op, finish)
406406
sexp = s(:erange, beg, finish)
407-
sexp.loc = source(op)
407+
sexp.source = source(op)
408408
sexp
409409
end
410410

@@ -441,7 +441,7 @@ def new_op_asgn(op, lhs, rhs)
441441
def new_op_asgn1(lhs, args, op, rhs)
442442
arglist = s(:arglist, *args)
443443
sexp = s(:op_asgn1, lhs, arglist, value(op), rhs)
444-
sexp.loc = source(op)
444+
sexp.source = source(op)
445445
sexp
446446
end
447447

@@ -510,7 +510,7 @@ def new_gettable(ref)
510510
raise "Bad new_gettable ref: #{ref.type}"
511511
end
512512

513-
res.loc = ref.loc
513+
res.source = ref.source
514514
res
515515
end
516516

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

538-
result.loc = ref.loc
538+
result.source = ref.source
539539
result
540540
else
541541
raise "Bad var_ref type: #{ref.type}"
@@ -549,7 +549,7 @@ def new_super(kw, args)
549549
sexp = s(:super, s(:arglist, *args))
550550
end
551551

552-
sexp.loc = source(kw)
552+
sexp.source = source(kw)
553553
sexp
554554
end
555555

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

569-
str.loc = source(start_t)
569+
str.source = source(start_t)
570570

571571
str
572572
end

lib/opal/parser/sexp.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Sexp
33

44
attr_reader :array
55

6-
attr_accessor :loc
6+
attr_accessor :source
77

88
def initialize(args)
99
@array = args
@@ -54,11 +54,11 @@ def ==(other)
5454
alias eql? ==
5555

5656
def line
57-
@loc && @loc[0]
57+
@source && @source[0]
5858
end
5959

6060
def column
61-
@loc && @loc[1]
61+
@source && @source[1]
6262
end
6363

6464
def inspect

0 commit comments

Comments
 (0)