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: f16b8f7dcb88
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8146e0668f3c
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on Dec 13, 2014

  1. Copy the full SHA
    8146e06 View commit details
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBinding;

public class SetTopLevelBindingNode extends RubyNode {

public SetTopLevelBindingNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
public Object execute(VirtualFrame frame) {
final RubyBinding binding = new RubyBinding(getContext().getCoreLibrary().getBindingClass(), RubyArguments.getSelf(frame.getArguments()), frame.materialize());
getContext().getCoreLibrary().getObjectClass().setConstant(this, "TOPLEVEL_BINDING", binding);
return getContext().getCoreLibrary().getNilObject();
}

}
Original file line number Diff line number Diff line change
@@ -311,7 +311,6 @@ public void initialize() {

globalVariablesObject.setInstanceVariable("$DEBUG", context.getRuntime().isDebug());
globalVariablesObject.setInstanceVariable("$VERBOSE", context.getRuntime().warningsEnabled() ? context.getRuntime().isVerbose() : nilObject);

}

public void initializeAfterMethodsAdded() {
Original file line number Diff line number Diff line change
@@ -1030,11 +1030,24 @@ private static org.jruby.ast.Node setRHS(org.jruby.ast.Node node, org.jruby.ast.
add("$-p");
}};

private final Map<String, String> globalVariableAliases = new HashMap<String, String>() {{
put("$-I", "$LOAD_PATH");
put("$:", "$LOAD_PATH");
put("$-d", "$DEBUG");
put("$-v", "$VERBOSE");
put("$-w", "$VERBOSE");
}};

@Override
public RubyNode visitGlobalAsgnNode(org.jruby.ast.GlobalAsgnNode node) {
final SourceSection sourceSection = translate(node.getPosition());

final String name = node.getName();
String name = node.getName();

if (globalVariableAliases.containsKey(name)) {
name = globalVariableAliases.get(name);
}

RubyNode rhs = node.getValueNode().accept(this);

if (readOnlyGlobalVariables.contains(name)) {
@@ -1077,7 +1090,6 @@ public RubyNode visitGlobalAsgnNode(org.jruby.ast.GlobalAsgnNode node) {
if (name.equals("$stdout")) {
rhs = new CheckStdoutVariableTypeNode(context, sourceSection, rhs);
}

final ObjectLiteralNode globalVariablesObjectNode = new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getGlobalVariablesObject());
return new WriteInstanceVariableNode(context, sourceSection, name, globalVariablesObjectNode, rhs, true);

@@ -1086,7 +1098,12 @@ public RubyNode visitGlobalAsgnNode(org.jruby.ast.GlobalAsgnNode node) {

@Override
public RubyNode visitGlobalVarNode(org.jruby.ast.GlobalVarNode node) {
final String name = node.getName();
String name = node.getName();

if (globalVariableAliases.containsKey(name)) {
name = globalVariableAliases.get(name);
}

final SourceSection sourceSection = translate(node.getPosition());

if (FRAME_LOCAL_GLOBAL_VARIABLES.contains(name)) {
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.truffle.nodes.*;
import org.jruby.truffle.nodes.control.*;
import org.jruby.truffle.nodes.core.SetTopLevelBindingNode;
import org.jruby.truffle.nodes.literal.*;
import org.jruby.truffle.nodes.methods.*;
import org.jruby.truffle.runtime.*;
@@ -185,6 +186,10 @@ public RubyRootNode parse(RubyNode currentNode, RubyContext context, Source sour

truffleNode = wrapper.wrap(truffleNode);

// Binding

truffleNode = SequenceNode.sequence(context, sourceSection, new SetTopLevelBindingNode(context, sourceSection), truffleNode);

// Shell result

return new RubyRootNode(context, truffleNode.getSourceSection(), environment.getFrameDescriptor(), sharedMethodInfo, truffleNode);
2 changes: 2 additions & 0 deletions core/src/main/ruby/jruby/truffle/core/kernel.rb
Original file line number Diff line number Diff line change
@@ -105,6 +105,8 @@ def self.set_encoding(external, internal)
end
end

ARGF = Object.new

# Here temporarily while we adapt to the newly imported specs

class Channel
6 changes: 0 additions & 6 deletions spec/truffle/tags/language/predefined_tags.txt
Original file line number Diff line number Diff line change
@@ -6,10 +6,6 @@ fails(inherited):Predefined global $-0 raises a TypeError if assigned a boolean
fails(inherited):Predefined global $-0 raises a TypeError if assigned a Fixnum
fails(inherited):Predefined global $/ changes $-0
fails(inherited):Predefined global $` sets an empty result to the encoding of the source String
fails:Execution variable $: is the same object as $LOAD_PATH and $-I
fails:Global variable $-d is an alias of $DEBUG
fails:Global variable $-v is an alias of $VERBOSE
fails:Global variable $-w is an alias of $VERBOSE
fails:Global variable $0 raises a TypeError when not given an object that can be coerced to a String
fails:Predefined global $! remains nil after a failed core class "checked" coercion against a class that defines method_missing
fails:Predefined global $' is equivalent to MatchData#post_match on the last match $~
@@ -31,5 +27,3 @@ fails:Predefined global $~ changes the value of derived capture globals when ass
fails:Predefined global $~ changes the value of the derived following match global
fails:Predefined global $~ changes the value of the derived full match global
fails:Predefined global $~ changes the value of the derived preceding match global
fails:The predefined global constants includes TOPLEVEL_BINDING
fails:The predefined standard objects includes ARGF