FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
jruby/src/org/jruby/ast/ArgsNode.java at serializable_procs · MSNexploder/jruby · GitHub
MSNexploder
/
jruby
Public
forked from
jruby/jruby
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
jruby
/
src
/
org
/
jruby
/
ast
/
ArgsNode.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
493 lines (430 loc) · 19.1 KB
Breadcrumbs
jruby
/
src
/
org
/
jruby
/
ast
/
ArgsNode.java
Copy path
File metadata and controls
493 lines (430 loc) · 19.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
/*
***** BEGIN LICENSE BLOCK *****
* Version: CPL 1.0/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Common Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.eclipse.org/legal/cpl-v10.html
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com>
* Copyright (C) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr>
* Copyright (C) 2001-2002 Jan Arne Petersen <jpetersen@uni-bonn.de>
* Copyright (C) 2002 Anders Bengtsson <ndrsbngtssn@yahoo.se>
* Copyright (C) 2004 Thomas E Enebo <enebo@acm.org>
* Copyright (C) 2007 Mirko Stocker <me@misto.ch>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the CPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
////////////////////////////////////////////////////////////////////////////////
// NOTE: THIS FILE IS GENERATED! DO NOT EDIT THIS FILE!
// generated from: src/org/jruby/ast/ArgsNode.erb
// using arities: src/org/jruby/ast/ArgsNode.arities.erb
////////////////////////////////////////////////////////////////////////////////
package
org
.
jruby
.
ast
;
import
java
.
io
.
IOException
;
import
java
.
io
.
ObjectInput
;
import
java
.
io
.
ObjectOutput
;
import
java
.
util
.
List
;
import
org
.
jruby
.
Ruby
;
import
org
.
jruby
.
RubyArray
;
import
org
.
jruby
.
ast
.
visitor
.
NodeVisitor
;
import
org
.
jruby
.
javasupport
.
util
.
RuntimeHelpers
;
import
org
.
jruby
.
lexer
.
yacc
.
ISourcePosition
;
import
org
.
jruby
.
runtime
.
Arity
;
import
org
.
jruby
.
runtime
.
Block
;
import
org
.
jruby
.
runtime
.
DynamicScope
;
import
org
.
jruby
.
runtime
.
ThreadContext
;
import
org
.
jruby
.
runtime
.
builtin
.
IRubyObject
;
/**
* Represents the argument declarations of a method. The fields:
* foo(p1, ..., pn, o1 = v1, ..., on = v2, *r, q1, ..., qn)
*
* p1...pn = pre arguments
* o1...on = optional arguments
* r = rest argument
* q1...qn = post arguments (only in 1.9)
*/
public
class
ArgsNode
extends
Node
{
private
static
final
long
serialVersionUID
=
0L
;
private
ListNode
pre
;
private
int
preCount
;
private
ListNode
optArgs
;
protected
ArgumentNode
restArgNode
;
protected
int
restArg
;
private
BlockArgNode
blockArgNode
;
protected
Arity
arity
;
private
int
requiredArgsCount
;
protected
boolean
hasOptArgs
;
protected
boolean
hasMasgnArgs
;
protected
int
maxArgsCount
;
protected
boolean
isSimple
;
// Only in ruby 1.9 methods
private
ListNode
post
;
private
int
postCount
;
private
int
postIndex
;
public
ArgsNode
() {
super
();
}
/**
*
* @param optionalArguments Node describing the optional arguments
* This Block will contain assignments to locals (LAsgnNode)
* @param restArguments index of the rest argument in the local table
* (the array argument prefixed by a * which collects
* all additional params)
* or -1 if there is none.
* @param argsCount number of regular arguments
* @param restArgNode The rest argument (*args).
* @param blockArgNode An optional block argument (&arg).
**/
public
ArgsNode
(
ISourcePosition
position
,
ListNode
pre
,
ListNode
optionalArguments
,
RestArgNode
rest
,
ListNode
post
,
BlockArgNode
blockArgNode
) {
super
(
position
);
this
.
pre
=
pre
;
this
.
preCount
=
pre
==
null
?
0
:
pre
.
size
();
this
.
post
=
post
;
this
.
postCount
=
post
==
null
?
0
:
post
.
size
();
int
optArgCount
=
optionalArguments
==
null
?
0
:
optionalArguments
.
size
();
this
.
postIndex
=
getPostCount
(
preCount
,
optArgCount
,
rest
);
this
.
optArgs
=
optionalArguments
;
this
.
restArg
=
rest
==
null
? -
1
:
rest
.
getIndex
();
this
.
restArgNode
=
rest
;
this
.
blockArgNode
=
blockArgNode
;
this
.
requiredArgsCount
=
preCount
+
postCount
;
this
.
hasOptArgs
=
getOptArgs
() !=
null
;
this
.
hasMasgnArgs
=
hasMasgnArgs
();
this
.
maxArgsCount
=
getRestArg
() >=
0
? -
1
:
getRequiredArgsCount
() +
getOptionalArgsCount
();
this
.
arity
=
calculateArity
();
this
.
isSimple
= !(
hasMasgnArgs
||
hasOptArgs
||
restArg
>=
0
||
postCount
>
0
);
}
private
int
getPostCount
(
int
preCount
,
int
optArgCount
,
RestArgNode
rest
) {
// Simple-case: If we have a rest we know where it is
if
(
rest
!=
null
)
return
rest
.
getIndex
() +
1
;
return
preCount
+
optArgCount
;
}
public
NodeType
getNodeType
() {
return
NodeType
.
ARGSNODE
;
}
protected
Arity
calculateArity
() {
if
(
restArgNode
instanceof
UnnamedRestArgNode
)
return
Arity
.
optional
();
if
(
getOptArgs
() !=
null
||
getRestArg
() >=
0
)
return
Arity
.
required
(
getRequiredArgsCount
());
return
Arity
.
createArity
(
getRequiredArgsCount
());
}
protected
boolean
hasMasgnArgs
() {
if
(
preCount
>
0
)
for
(
Node
node
:
pre
.
childNodes
()) {
if
(
node
instanceof
AssignableNode
)
return
true
;
}
if
(
postCount
>
0
)
for
(
Node
node
:
post
.
childNodes
()) {
if
(
node
instanceof
AssignableNode
)
return
true
;
}
return
false
;
}
/**
* Accept for the visitor pattern.
* @param iVisitor the visitor
**/
public
Object
accept
(
NodeVisitor
iVisitor
) {
return
iVisitor
.
visitArgsNode
(
this
);
}
/**
* Gets the required arguments at the beginning of the argument definition
*/
public
ListNode
getPre
() {
return
pre
;
}
@
Deprecated
public
ListNode
getArgs
() {
return
pre
;
}
public
Arity
getArity
() {
return
arity
;
}
public
int
getRequiredArgsCount
() {
return
requiredArgsCount
;
}
public
int
getOptionalArgsCount
() {
return
optArgs
==
null
?
0
:
optArgs
.
size
();
}
public
ListNode
getPost
() {
return
post
;
}
public
int
getMaxArgumentsCount
() {
return
maxArgsCount
;
}
/**
* Gets the optArgs.
* @return Returns a ListNode
*/
public
ListNode
getOptArgs
() {
return
optArgs
;
}
/**
* Gets the restArg.
* @return Returns a int
*/
public
int
getRestArg
() {
return
restArg
;
}
/**
* Gets the restArgNode.
* @return Returns an ArgumentNode
*/
public
ArgumentNode
getRestArgNode
() {
return
restArgNode
;
}
@
Deprecated
public
BlockArgNode
getBlockArgNode
() {
return
blockArgNode
;
}
/**
* Gets the explicit block argument of the parameter list (&block).
*
* @return Returns a BlockArgNode
*/
public
BlockArgNode
getBlock
() {
return
blockArgNode
;
}
public
int
getPostCount
() {
return
postCount
;
}
public
int
getPostIndex
() {
return
postIndex
;
}
public
int
getPreCount
() {
return
preCount
;
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
[]
args
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
// Bind 'normal' parameter values to the local scope for this method.
if
(!
hasMasgnArgs
) {
// no arg grouping, just use bulk assignment methods
if
(
preCount
>
0
)
scope
.
setArgValues
(
args
,
Math
.
min
(
args
.
length
,
preCount
));
if
(
postCount
>
0
)
scope
.
setEndArgValues
(
args
,
postIndex
,
postCount
);
}
else
{
masgnAwareArgAssign
(
context
,
runtime
,
self
,
args
,
block
,
scope
);
}
// optArgs and restArgs require more work, so isolate them and ArrayList creation here
if
(
hasOptArgs
||
restArg
!= -
1
)
prepareOptOrRestArgs
(
context
,
runtime
,
scope
,
self
,
args
);
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
private
void
masgnAwareArgAssign
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
[]
args
,
Block
block
,
DynamicScope
scope
) {
// arg grouping, use slower arg walking logic
if
(
preCount
>
0
) {
int
size
=
pre
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++) {
Node
next
=
pre
.
get
(
i
);
if
(
next
instanceof
AssignableNode
) {
((
AssignableNode
)
next
).
assign
(
runtime
,
context
,
self
,
args
[
i
],
block
,
false
);
}
else
{
scope
.
setValue
(
i
,
args
[
i
],
0
);
}
}
}
if
(
postCount
>
0
) {
int
size
=
post
.
size
();
int
argsLength
=
args
.
length
;
for
(
int
i
=
0
;
i
<
size
;
i
++) {
Node
next
=
post
.
get
(
i
);
if
(
next
instanceof
AssignableNode
) {
((
AssignableNode
)
next
).
assign
(
runtime
,
context
,
self
,
args
[
argsLength
-
postCount
+
i
],
block
,
false
);
}
else
{
scope
.
setValue
(
i
+
postIndex
,
args
[
argsLength
-
postCount
+
i
],
0
);
}
}
}
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
if
(
isSimple
) {
scope
.
setArgValues
();
}
else
{
prepare
(
context
,
runtime
,
self
,
IRubyObject
.
NULL_ARRAY
,
block
);
}
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
arg0
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
if
(
isSimple
) {
scope
.
setArgValues
(
arg0
);
}
else
{
prepare
(
context
,
runtime
,
self
,
new
IRubyObject
[] {
arg0
},
block
);
}
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
arg0
,
IRubyObject
arg1
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
if
(
isSimple
) {
scope
.
setArgValues
(
arg0
,
arg1
);
}
else
{
prepare
(
context
,
runtime
,
self
,
new
IRubyObject
[] {
arg0
,
arg1
},
block
);
}
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
arg0
,
IRubyObject
arg1
,
IRubyObject
arg2
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
if
(
isSimple
) {
scope
.
setArgValues
(
arg0
,
arg1
,
arg2
);
}
else
{
prepare
(
context
,
runtime
,
self
,
new
IRubyObject
[] {
arg0
,
arg1
,
arg2
},
block
);
}
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
arg0
,
IRubyObject
arg1
,
IRubyObject
arg2
,
IRubyObject
arg3
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
if
(
isSimple
) {
scope
.
setArgValues
(
arg0
,
arg1
,
arg2
,
arg3
);
}
else
{
prepare
(
context
,
runtime
,
self
,
new
IRubyObject
[] {
arg0
,
arg1
,
arg2
,
arg3
},
block
);
}
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
arg0
,
IRubyObject
arg1
,
IRubyObject
arg2
,
IRubyObject
arg3
,
IRubyObject
arg4
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
if
(
isSimple
) {
scope
.
setArgValues
(
arg0
,
arg1
,
arg2
,
arg3
,
arg4
);
}
else
{
prepare
(
context
,
runtime
,
self
,
new
IRubyObject
[] {
arg0
,
arg1
,
arg2
,
arg3
,
arg4
},
block
);
}
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
arg0
,
IRubyObject
arg1
,
IRubyObject
arg2
,
IRubyObject
arg3
,
IRubyObject
arg4
,
IRubyObject
arg5
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
if
(
isSimple
) {
scope
.
setArgValues
(
arg0
,
arg1
,
arg2
,
arg3
,
arg4
,
arg5
);
}
else
{
prepare
(
context
,
runtime
,
self
,
new
IRubyObject
[] {
arg0
,
arg1
,
arg2
,
arg3
,
arg4
,
arg5
},
block
);
}
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
arg0
,
IRubyObject
arg1
,
IRubyObject
arg2
,
IRubyObject
arg3
,
IRubyObject
arg4
,
IRubyObject
arg5
,
IRubyObject
arg6
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
if
(
isSimple
) {
scope
.
setArgValues
(
arg0
,
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
arg6
);
}
else
{
prepare
(
context
,
runtime
,
self
,
new
IRubyObject
[] {
arg0
,
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
arg6
},
block
);
}
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
arg0
,
IRubyObject
arg1
,
IRubyObject
arg2
,
IRubyObject
arg3
,
IRubyObject
arg4
,
IRubyObject
arg5
,
IRubyObject
arg6
,
IRubyObject
arg7
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
if
(
isSimple
) {
scope
.
setArgValues
(
arg0
,
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
arg6
,
arg7
);
}
else
{
prepare
(
context
,
runtime
,
self
,
new
IRubyObject
[] {
arg0
,
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
arg6
,
arg7
},
block
);
}
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
arg0
,
IRubyObject
arg1
,
IRubyObject
arg2
,
IRubyObject
arg3
,
IRubyObject
arg4
,
IRubyObject
arg5
,
IRubyObject
arg6
,
IRubyObject
arg7
,
IRubyObject
arg8
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
if
(
isSimple
) {
scope
.
setArgValues
(
arg0
,
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
arg6
,
arg7
,
arg8
);
}
else
{
prepare
(
context
,
runtime
,
self
,
new
IRubyObject
[] {
arg0
,
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
arg6
,
arg7
,
arg8
},
block
);
}
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
public
void
prepare
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
arg0
,
IRubyObject
arg1
,
IRubyObject
arg2
,
IRubyObject
arg3
,
IRubyObject
arg4
,
IRubyObject
arg5
,
IRubyObject
arg6
,
IRubyObject
arg7
,
IRubyObject
arg8
,
IRubyObject
arg9
,
Block
block
) {
DynamicScope
scope
=
context
.
getCurrentScope
();
if
(
isSimple
) {
scope
.
setArgValues
(
arg0
,
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
arg6
,
arg7
,
arg8
,
arg9
);
}
else
{
prepare
(
context
,
runtime
,
self
,
new
IRubyObject
[] {
arg0
,
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
arg6
,
arg7
,
arg8
,
arg9
},
block
);
}
if
(
getBlock
() !=
null
)
processBlockArg
(
scope
,
runtime
,
block
);
}
public
void
checkArgCount
(
Ruby
runtime
,
int
argsLength
) {
// arity.checkArity(runtime, argsLength);
Arity
.
checkArgumentCount
(
runtime
,
argsLength
,
requiredArgsCount
,
maxArgsCount
);
}
protected
void
prepareOptOrRestArgs
(
ThreadContext
context
,
Ruby
runtime
,
DynamicScope
scope
,
IRubyObject
self
,
IRubyObject
[]
args
) {
prepareRestArg
(
context
,
runtime
,
scope
,
args
,
prepareOptionalArguments
(
context
,
runtime
,
self
,
args
));
}
protected
int
prepareOptionalArguments
(
ThreadContext
context
,
Ruby
runtime
,
IRubyObject
self
,
IRubyObject
[]
args
) {
return
hasOptArgs
?
assignOptArgs
(
args
,
runtime
,
context
,
self
,
preCount
) :
preCount
;
}
protected
void
prepareRestArg
(
ThreadContext
context
,
Ruby
runtime
,
DynamicScope
scope
,
IRubyObject
[]
args
,
int
givenArgsCount
) {
if
(
restArg
>=
0
) {
int
sizeOfRestArg
=
args
.
length
-
postCount
-
givenArgsCount
;
if
(
sizeOfRestArg
<=
0
) {
// no more values to stick in rest arg
scope
.
setValue
(
restArg
,
RubyArray
.
newArray
(
runtime
),
0
);
}
else
{
scope
.
setValue
(
restArg
,
RubyArray
.
newArrayNoCopy
(
runtime
,
args
,
givenArgsCount
,
sizeOfRestArg
),
0
);
}
}
}
protected
int
assignOptArgs
(
IRubyObject
[]
args
,
Ruby
runtime
,
ThreadContext
context
,
IRubyObject
self
,
int
givenArgsCount
) {
// assign given optional arguments to their variables
int
j
=
0
;
for
(
int
i
=
preCount
;
i
<
args
.
length
-
postCount
&&
j
<
optArgs
.
size
();
i
++,
j
++) {
// in-frame EvalState should already have receiver set as self, continue to use it
optArgs
.
get
(
j
).
assign
(
runtime
,
context
,
self
,
args
[
i
],
Block
.
NULL_BLOCK
,
true
);
givenArgsCount
++;
}
// assign the default values, adding to the end of allArgs
for
(
int
i
=
0
;
j
<
optArgs
.
size
();
i
++,
j
++) {
optArgs
.
get
(
j
).
interpret
(
runtime
,
context
,
self
,
Block
.
NULL_BLOCK
);
}
return
givenArgsCount
;
}
protected
void
processBlockArg
(
DynamicScope
scope
,
Ruby
runtime
,
Block
block
) {
scope
.
setValue
(
getBlock
().
getCount
(),
RuntimeHelpers
.
processBlockArgument
(
runtime
,
block
),
0
);
}
public
List
<
Node
>
childNodes
() {
if
(
post
!=
null
)
return
Node
.
createList
(
pre
,
optArgs
,
restArgNode
,
post
,
blockArgNode
);
return
Node
.
createList
(
pre
,
optArgs
,
restArgNode
,
blockArgNode
);
}
public
void
writeExternal
(
ObjectOutput
out
)
throws
IOException
{
super
.
writeExternal
(
out
);
out
.
writeObject
(
pre
);
out
.
writeInt
(
preCount
);
out
.
writeObject
(
optArgs
);
out
.
writeObject
(
restArgNode
);
out
.
writeInt
(
restArg
);
out
.
writeObject
(
blockArgNode
);
out
.
writeObject
(
arity
);
out
.
writeInt
(
requiredArgsCount
);
out
.
writeBoolean
(
hasOptArgs
);
out
.
writeBoolean
(
hasMasgnArgs
);
out
.
writeInt
(
maxArgsCount
);
out
.
writeBoolean
(
isSimple
);
out
.
writeObject
(
post
);
out
.
writeInt
(
postCount
);
out
.
writeInt
(
postIndex
);
}
public
void
readExternal
(
ObjectInput
in
)
throws
IOException
,
ClassNotFoundException
{
super
.
readExternal
(
in
);
pre
= (
ListNode
)
in
.
readObject
();
preCount
=
in
.
readInt
();
optArgs
= (
ListNode
)
in
.
readObject
();
restArgNode
= (
ArgumentNode
)
in
.
readObject
();
restArg
=
in
.
readInt
();
blockArgNode
= (
BlockArgNode
)
in
.
readObject
();
arity
= (
Arity
)
in
.
readObject
();
requiredArgsCount
=
in
.
readInt
();
hasOptArgs
=
in
.
readBoolean
();
hasMasgnArgs
=
in
.
readBoolean
();
maxArgsCount
=
in
.
readInt
();
isSimple
=
in
.
readBoolean
();
post
= (
ListNode
)
in
.
readObject
();
postCount
=
in
.
readInt
();
postIndex
=
in
.
readInt
();
}
}
Back
|
FazBrowse Home
|
New Git URL