Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JRUBY-4180: [1.8.7] Blocks should be able to receive block arguments …
…(interpreted-mode only + some internals)
- Loading branch information
Showing
29 changed files
with
2,317 additions
and
665 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.jruby.ast; | ||
|
||
import java.util.List; | ||
import org.jruby.ast.visitor.NodeVisitor; | ||
import org.jruby.lexer.yacc.ISourcePosition; | ||
|
||
/** | ||
* Similiar to BlockArg, but with idiosyncracies that 1.8.7 allows: | ||
* | ||
* proc { |a,&b| } | ||
* proc { |a,&FOO| } | ||
* proc { |a,b.c| } | ||
* proc { |a,b[0]| } | ||
* | ||
*/ | ||
public class BlockArg18Node extends Node { | ||
private Node normalBlockArgs; | ||
private Node blockArgAssignee; | ||
|
||
public BlockArg18Node(ISourcePosition position, Node blockArgAssignee, | ||
Node normalBlockArgs) { | ||
super(position); | ||
|
||
assert blockArgAssignee != null : "Must be a value to assign too"; | ||
|
||
this.blockArgAssignee = blockArgAssignee; | ||
this.normalBlockArgs = normalBlockArgs; | ||
} | ||
|
||
public Node getArgs() { | ||
return normalBlockArgs; | ||
} | ||
|
||
public Node getBlockArg() { | ||
return blockArgAssignee; | ||
} | ||
|
||
@Override | ||
public Object accept(NodeVisitor visitor) { | ||
return visitor.visitBlockArg18Node(this); | ||
} | ||
|
||
@Override | ||
public List<Node> childNodes() { | ||
return createList(normalBlockArgs, blockArgAssignee); | ||
} | ||
|
||
@Override | ||
public NodeType getNodeType() { | ||
return NodeType.BLOCKARG18NODE; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.