Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 79a402114228
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2392b82bed7d
Choose a head ref
  • 2 commits
  • 8 files changed
  • 1 contributor

Commits on Dec 13, 2016

  1. Copy the full SHA
    1477ccc View commit details
  2. Copy the full SHA
    2392b82 View commit details
Original file line number Diff line number Diff line change
@@ -29,16 +29,14 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the EPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
package org.jruby.truffle.parser;
package org.jruby.truffle.collections;

/**
* Simple key-value pair object.
*/
public class KeyValuePair<K,V> {
private K key;
private V value;
public class Tuple<K,V> {

public KeyValuePair(K key, V value) {
private final K key;
private final V value;

public Tuple(K key, V value) {
this.key = key;
this.value = value;
}
@@ -55,4 +53,5 @@ public V getValue() {
public String toString() {
return key + "=>" + value;
}

}
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.RubyLanguage;
import org.jruby.truffle.builtins.PrimitiveNodeConstructor;
import org.jruby.truffle.collections.Tuple;
import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.core.IsNilNode;
import org.jruby.truffle.core.IsRubiniusUndefinedNode;
@@ -1846,7 +1847,7 @@ public RubyNode visitHashNode(HashParseNode node) {

final List<RubyNode> keyValues = new ArrayList<>();

for (KeyValuePair<ParseNode, ParseNode> pair: node.getPairs()) {
for (Tuple<ParseNode, ParseNode> pair: node.getPairs()) {
if (pair.getKey() == null) {
// This null case is for splats {a: 1, **{b: 2}, c: 3}
final RubyNode hashLiteralSoFar = HashLiteralNode.create(context, fullSourceSection, keyValues.toArray(new RubyNode[keyValues.size()]));
39 changes: 0 additions & 39 deletions truffle/src/main/java/org/jruby/truffle/parser/IRScopeType.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
***** END LICENSE BLOCK *****/
package org.jruby.truffle.parser.ast;

import org.jruby.truffle.parser.KeyValuePair;
import org.jruby.truffle.collections.Tuple;
import org.jruby.truffle.parser.ast.types.ILiteralNode;
import org.jruby.truffle.parser.ast.visitor.NodeVisitor;
import org.jruby.truffle.parser.lexer.ISourcePosition;
@@ -44,15 +44,15 @@
* of default values in a method call.
*/
public class HashParseNode extends ParseNode implements ILiteralNode {
private final List<KeyValuePair<ParseNode,ParseNode>> pairs;
private final List<Tuple<ParseNode,ParseNode>> pairs;

public HashParseNode(ISourcePosition position) {
super(position, false);

pairs = new ArrayList<>();
}

public HashParseNode(ISourcePosition position, KeyValuePair<ParseNode,ParseNode> pair) {
public HashParseNode(ISourcePosition position, Tuple<ParseNode,ParseNode> pair) {
this(position);

pairs.add(pair);
@@ -62,7 +62,7 @@ public NodeType getNodeType() {
return NodeType.HASHNODE;
}

public HashParseNode add(KeyValuePair<ParseNode,ParseNode> pair) {
public HashParseNode add(Tuple<ParseNode,ParseNode> pair) {
if (pair.getKey() != null && pair.getKey().containsVariableAssignment() ||
pair.getValue() != null && pair.getValue().containsVariableAssignment()) {
containsVariableAssignment = true;
@@ -84,14 +84,14 @@ public boolean isEmpty() {
return pairs.isEmpty();
}

public List<KeyValuePair<ParseNode,ParseNode>> getPairs() {
public List<Tuple<ParseNode,ParseNode>> getPairs() {
return pairs;
}

public List<ParseNode> childNodes() {
List<ParseNode> children = new ArrayList<>();

for (KeyValuePair<ParseNode,ParseNode> pair: pairs) {
for (Tuple<ParseNode,ParseNode> pair: pairs) {
children.add(pair.getKey());
children.add(pair.getValue());
}
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
import org.jruby.truffle.core.string.ByteList;
import org.jruby.truffle.core.string.StringSupport;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.parser.KeyValuePair;
import org.jruby.truffle.collections.Tuple;
import org.jruby.truffle.parser.RubyWarnings;
import org.jruby.truffle.parser.Signature;
import org.jruby.truffle.parser.ast.AliasParseNode;
@@ -136,6 +136,7 @@
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static org.jruby.truffle.parser.lexer.LexingCommon.ASCII8BIT_ENCODING;
import static org.jruby.truffle.parser.lexer.LexingCommon.USASCII_ENCODING;
@@ -644,7 +645,7 @@ private boolean checkAssignmentInCondition(ParseNode node) {
private boolean isStaticContent(ParseNode node) {
if (node instanceof HashParseNode) {
HashParseNode hash = (HashParseNode) node;
for (KeyValuePair<ParseNode, ParseNode> pair : hash.getPairs()) {
for (Tuple<ParseNode, ParseNode> pair : hash.getPairs()) {
if (!isStaticContent(pair.getKey()) || !isStaticContent(pair.getValue())) return false;
}
return true;
@@ -1035,10 +1036,10 @@ public DStrParseNode createDStrNode(ISourcePosition position) {
return dstr;
}

public KeyValuePair<ParseNode, ParseNode> createKeyValue(ParseNode key, ParseNode value) {
public Tuple<ParseNode, ParseNode> createKeyValue(ParseNode key, ParseNode value) {
if (key != null && key instanceof StrParseNode) ((StrParseNode) key).setFrozen(true);

return new KeyValuePair<>(key, value);
return new Tuple<>(key, value);
}

public ParseNode asSymbol(ISourcePosition position, String value) {
@@ -1207,7 +1208,7 @@ public ArgsTailHolder new_args_tail(ISourcePosition position, ListParseNode keyw
public ParseNode remove_duplicate_keys(HashParseNode hash) {
List<ParseNode> encounteredKeys = new ArrayList<>();

for (KeyValuePair<ParseNode,ParseNode> pair: hash.getPairs()) {
for (Tuple<ParseNode,ParseNode> pair: hash.getPairs()) {
ParseNode key = pair.getKey();
if (key == null) continue;
int index = encounteredKeys.indexOf(key);
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
import org.jruby.truffle.core.rope.CodeRange;
import org.jruby.truffle.core.string.ByteList;
import org.jruby.truffle.interop.ForeignCodeNode;
import org.jruby.truffle.parser.KeyValuePair;
import org.jruby.truffle.collections.Tuple;
import org.jruby.truffle.parser.RubyWarnings;
import org.jruby.truffle.parser.ast.ArgsParseNode;
import org.jruby.truffle.parser.ast.ArgumentParseNode;
@@ -4578,13 +4578,13 @@ public Object yyparse (RubyLexer yyLex) throws java.io.IOException {
};
states[608] = new ParserState() {
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) {
yyVal = new HashParseNode(lexer.getPosition(), ((KeyValuePair)yyVals[0+yyTop]));
yyVal = new HashParseNode(lexer.getPosition(), ((Tuple)yyVals[0+yyTop]));
return yyVal;
}
};
states[609] = new ParserState() {
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) {
yyVal = ((HashParseNode)yyVals[-2+yyTop]).add(((KeyValuePair)yyVals[0+yyTop]));
yyVal = ((HashParseNode)yyVals[-2+yyTop]).add(((Tuple)yyVals[0+yyTop]));
return yyVal;
}
};
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ package org.jruby.truffle.parser.parser;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.rope.CodeRange;
import org.jruby.truffle.interop.ForeignCodeNode;
import org.jruby.truffle.parser.KeyValuePair;
import org.jruby.truffle.collections.Tuple;
import org.jruby.truffle.parser.RubyWarnings;
import org.jruby.truffle.parser.ast.ArgsParseNode;
import org.jruby.truffle.parser.ast.ArgumentParseNode;
@@ -254,7 +254,7 @@ public class RubyParser {
// ENEBO: missing when_args
%type <HashParseNode> assoc_list
%type <HashParseNode> assocs
%type <KeyValuePair> assoc
%type <Tuple> assoc
%type <ListParseNode> mlhs_head mlhs_post
%type <ListParseNode> f_block_optarg
%type <BlockPassParseNode> opt_block_arg block_arg none_block_pass
Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@
***** END LICENSE BLOCK *****/
package org.jruby.truffle.parser.scope;

import org.jruby.truffle.parser.IRScopeType;
import org.jruby.truffle.parser.Signature;
import org.jruby.truffle.parser.ast.AssignableParseNode;
import org.jruby.truffle.parser.ast.DAsgnParseNode;
@@ -78,8 +77,6 @@ public class StaticScope implements Serializable {
// File name where this static scope came from or null if a native or artificial scope
private String file;

protected IRScopeType scopeType;

private static final String[] NO_NAMES = new String[0];

private Type type;
@@ -129,14 +126,6 @@ protected StaticScope(Type type, StaticScope enclosingScope, String[] names) {
this.isBlockOrEval = (type != Type.LOCAL);
}

public IRScopeType getScopeType() {
return scopeType;
}

public void setScopeType(IRScopeType scopeType) {
this.scopeType = scopeType;
}

/**
* Check that all strings in the given array are the interned versions.
*