changeset 13645:497fada09efb

Ruby: remove versioning.
author Chris Seaton <chris.seaton@oracle.com>
date Wed, 15 Jan 2014 19:27:27 +0000
parents bfe7a8c8c3c6
children c318d67d132f
files graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/core/CoreMethod.java graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/core/CoreMethodNodeManager.java graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/core/KernelNodes.java graal/com.oracle.truffle.ruby.parser/src/com/oracle/truffle/ruby/parser/JRubyParser.java graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/RubyContext.java graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/Configuration.java graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/ConfigurationBuilder.java graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/RubyVersion.java graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/core/CoreLibrary.java graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/subsystems/FeatureManager.java graal/com.oracle.truffle.ruby.shell/src/com/oracle/truffle/ruby/shell/CommandLineParser.java graal/com.oracle.truffle.ruby.shell/src/com/oracle/truffle/ruby/shell/Shell.java graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/RubyTests.java graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/core/ContinuationTests.java graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/core/ProcTests.java
diffstat 15 files changed, 22 insertions(+), 205 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/core/CoreMethod.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/core/CoreMethod.java	Wed Jan 15 19:27:27 2014 +0000
@@ -11,7 +11,6 @@
 
 import java.lang.annotation.*;
 
-import com.oracle.truffle.ruby.runtime.configuration.*;
 import com.oracle.truffle.ruby.runtime.methods.*;
 
 @Target(ElementType.TYPE)
@@ -30,8 +29,6 @@
 
     boolean appendCallNode() default false;
 
-    RubyVersion[] versions() default {RubyVersion.RUBY_18, RubyVersion.RUBY_19, RubyVersion.RUBY_20, RubyVersion.RUBY_21};
-
     int minArgs() default Arity.NO_MINIMUM;
 
     int maxArgs() default Arity.NO_MAXIMUM;
--- a/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/core/CoreMethodNodeManager.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/core/CoreMethodNodeManager.java	Wed Jan 15 19:27:27 2014 +0000
@@ -32,9 +32,7 @@
      */
     public static void addMethods(RubyClass rubyObjectClass) {
         for (MethodDetails methodDetails : getMethods()) {
-            if (Arrays.asList(methodDetails.getMethodAnnotation().versions()).contains(rubyObjectClass.getContext().getConfiguration().getRubyVersion())) {
-                addMethod(rubyObjectClass, methodDetails);
-            }
+            addMethod(rubyObjectClass, methodDetails);
         }
     }
 
--- a/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/core/KernelNodes.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/core/KernelNodes.java	Wed Jan 15 19:27:27 2014 +0000
@@ -25,7 +25,6 @@
 import com.oracle.truffle.ruby.nodes.literal.*;
 import com.oracle.truffle.ruby.nodes.yield.*;
 import com.oracle.truffle.ruby.runtime.*;
-import com.oracle.truffle.ruby.runtime.configuration.*;
 import com.oracle.truffle.ruby.runtime.control.*;
 import com.oracle.truffle.ruby.runtime.core.*;
 import com.oracle.truffle.ruby.runtime.core.array.*;
@@ -534,25 +533,7 @@
         }
     }
 
-    @CoreMethod(names = "proc", isModuleMethod = true, needsBlock = true, maxArgs = 0, versions = RubyVersion.RUBY_18)
-    public abstract static class Proc18Node extends CoreMethodNode {
-
-        public Proc18Node(RubyContext context, SourceSection sourceSection) {
-            super(context, sourceSection);
-        }
-
-        public Proc18Node(Proc18Node prev) {
-            super(prev);
-        }
-
-        @Specialization
-        public RubyProc proc(Object self, RubyProc block) {
-            return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.LAMBDA, self, block, block.getMethod());
-
-        }
-    }
-
-    @CoreMethod(names = "proc", isModuleMethod = true, needsBlock = true, maxArgs = 0, versions = {RubyVersion.RUBY_19, RubyVersion.RUBY_20, RubyVersion.RUBY_21})
+    @CoreMethod(names = "proc", isModuleMethod = true, needsBlock = true, maxArgs = 0)
     public abstract static class ProcNode extends CoreMethodNode {
 
         public ProcNode(RubyContext context, SourceSection sourceSection) {
--- a/graal/com.oracle.truffle.ruby.parser/src/com/oracle/truffle/ruby/parser/JRubyParser.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.parser/src/com/oracle/truffle/ruby/parser/JRubyParser.java	Wed Jan 15 19:27:27 2014 +0000
@@ -34,23 +34,6 @@
 
         final org.jrubyparser.Parser parser = new org.jrubyparser.Parser();
 
-        org.jrubyparser.CompatVersion parserVersion = null;
-
-        switch (context.getConfiguration().getRubyVersion()) {
-            case RUBY_18:
-                parserVersion = org.jrubyparser.CompatVersion.RUBY1_8;
-                break;
-            case RUBY_19:
-                parserVersion = org.jrubyparser.CompatVersion.RUBY1_9;
-                break;
-            case RUBY_20:
-                parserVersion = org.jrubyparser.CompatVersion.RUBY2_0;
-                break;
-            case RUBY_21:
-                parserVersion = org.jrubyparser.CompatVersion.RUBY2_0;
-                break;
-        }
-
         // TODO(cs) should this get a new unique method identifier or not?
         final TranslatorEnvironment environment = new TranslatorEnvironment(context, environmentForFrame(context, parentFrame), this, allocateReturnID(), true, true, new UniqueMethodIdentifier());
 
@@ -83,7 +66,7 @@
             }
         }
 
-        final org.jrubyparser.parser.ParserConfiguration parserConfiguration = new org.jrubyparser.parser.ParserConfiguration(0, parserVersion, staticScope);
+        final org.jrubyparser.parser.ParserConfiguration parserConfiguration = new org.jrubyparser.parser.ParserConfiguration(0, org.jrubyparser.CompatVersion.RUBY2_0, staticScope);
 
         // Parse to the JRuby AST
 
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/RubyContext.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/RubyContext.java	Wed Jan 15 19:27:27 2014 +0000
@@ -81,16 +81,11 @@
         // Must initialize threads before fibers
 
         threadManager = new ThreadManager(this);
-
-        if (configuration.getRubyVersion().is19OrLater()) {
-            fiberManager = new FiberManager(this);
-        } else {
-            fiberManager = null;
-        }
+        fiberManager = new FiberManager(this);
     }
 
     public String getLanguageShortName() {
-        return configuration.getRubyVersion().getShortName();
+        return "Ruby";
     }
 
     public RubyDebugManager getDebugManager() {
@@ -187,11 +182,7 @@
         } catch (RaiseException e) {
             throw e;
         } catch (ThrowException e) {
-            if (context.getConfiguration().getRubyVersion().is18OrEarlier()) {
-                throw new RaiseException(context.getCoreLibrary().nameErrorUncaughtThrow(e.getTag()));
-            } else {
-                throw new RaiseException(context.getCoreLibrary().argumentErrorUncaughtThrow(e.getTag()));
-            }
+            throw new RaiseException(context.getCoreLibrary().argumentErrorUncaughtThrow(e.getTag()));
         } catch (BreakShellException | QuitException e) {
             throw e;
         } catch (Throwable e) {
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/Configuration.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/Configuration.java	Wed Jan 15 19:27:27 2014 +0000
@@ -20,8 +20,6 @@
 
     private final String standardLibrary;
 
-    private final RubyVersion rubyVersion;
-
     private final boolean verbose;
     private final int warningLevel;
     private final int taintCheckLevel;
@@ -48,8 +46,6 @@
 
         standardLibrary = builder.getStandardLibrary();
 
-        rubyVersion = builder.getRubyVersion();
-
         verbose = builder.getVerbose();
         warningLevel = builder.getWarningLevel();
         taintCheckLevel = builder.getTaintCheckLevel();
@@ -76,10 +72,6 @@
         return standardLibrary;
     }
 
-    public RubyVersion getRubyVersion() {
-        return rubyVersion;
-    }
-
     public boolean getDebug() {
         return debug;
     }
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/ConfigurationBuilder.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/ConfigurationBuilder.java	Wed Jan 15 19:27:27 2014 +0000
@@ -25,8 +25,6 @@
 
     private String standardLibrary = JRUBY_STDLIB_JAR;
 
-    private RubyVersion rubyVersion = RubyVersion.RUBY_19;
-
     private boolean debug = false;
     private boolean verbose = false;
     private int warningLevel = 0;
@@ -67,8 +65,6 @@
 
         standardLibrary = configuration.getStandardLibrary();
 
-        rubyVersion = configuration.getRubyVersion();
-
         debug = configuration.getDebug();
         verbose = configuration.getVerbose();
         warningLevel = configuration.getWarningLevel();
@@ -99,15 +95,6 @@
         this.standardLibrary = standardLibrary;
     }
 
-    public RubyVersion getRubyVersion() {
-        return rubyVersion;
-    }
-
-    public void setRubyVersion(RubyVersion rubyVersion) {
-        assert rubyVersion != null;
-        this.rubyVersion = rubyVersion;
-    }
-
     public boolean getDebug() {
         return debug;
     }
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/RubyVersion.java	Wed Jan 15 15:11:47 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2013 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 com.oracle.truffle.ruby.runtime.configuration;
-
-/**
- * A Ruby version that we want to be compatible with.
- */
-public enum RubyVersion {
-    RUBY_18("1.8.7", 374), RUBY_19("1.9.3", 448), RUBY_20("2.0.0", 247), RUBY_21("2.1.0", 0);
-
-    private final String version;
-    private final int patch;
-
-    private RubyVersion(String version, int patch) {
-        this.version = version;
-        this.patch = patch;
-    }
-
-    public boolean is18OrEarlier() {
-        return this.compareTo(RUBY_18) <= 0;
-    }
-
-    public boolean is19OrLater() {
-        return this.compareTo(RUBY_19) >= 0;
-    }
-
-    public String getVersion() {
-        return version;
-    }
-
-    public int getPatch() {
-        return patch;
-    }
-
-    public String getShortName() {
-        return "Ruby" + getVersion();
-    }
-
-}
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/core/CoreLibrary.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/core/CoreLibrary.java	Wed Jan 15 19:27:27 2014 +0000
@@ -164,8 +164,8 @@
 
         // Set constants
 
-        objectClass.setConstant("RUBY_VERSION", new RubyString(stringClass, context.getConfiguration().getRubyVersion().getVersion()));
-        objectClass.setConstant("RUBY_PATCHLEVEL", context.getConfiguration().getRubyVersion().getPatch());
+        objectClass.setConstant("RUBY_VERSION", new RubyString(stringClass, "2.1.0"));
+        objectClass.setConstant("RUBY_PATCHLEVEL", 0);
         objectClass.setConstant("RUBY_ENGINE", new RubyString(stringClass, "rubytruffle"));
         objectClass.setConstant("RUBY_PLATFORM", new RubyString(stringClass, "jvm"));
 
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/subsystems/FeatureManager.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/subsystems/FeatureManager.java	Wed Jan 15 19:27:27 2014 +0000
@@ -35,7 +35,7 @@
     public boolean require(String feature) throws IOException {
         // Some features are handled specially
 
-        if (context.getConfiguration().getRubyVersion().is19OrLater() && feature.equals("continuation")) {
+        if (feature.equals("continuation")) {
             // We always load continuations
             return true;
         }
--- a/graal/com.oracle.truffle.ruby.shell/src/com/oracle/truffle/ruby/shell/CommandLineParser.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.shell/src/com/oracle/truffle/ruby/shell/CommandLineParser.java	Wed Jan 15 19:27:27 2014 +0000
@@ -208,15 +208,6 @@
                             configurationBuilder.setStandardLibrary(normalizedArgs.get(n + 1));
                             n++;
                             break;
-                        case "--1.8":
-                            configurationBuilder.setRubyVersion(RubyVersion.RUBY_18);
-                            break;
-                        case "--1.9":
-                            configurationBuilder.setRubyVersion(RubyVersion.RUBY_19);
-                            break;
-                        case "--2.0":
-                            configurationBuilder.setRubyVersion(RubyVersion.RUBY_20);
-                            break;
                         case "--full-object-space":
                             configurationBuilder.setFullObjectSpace(true);
                             break;
@@ -337,9 +328,6 @@
         out.println("Extra rubytruffle switches:");
         out.println("  --home dir                        set the location of the Ruby Truffle installation (default . or $RUBY_TRUFFLE_HOME)");
         out.println("  --stdlib dir                      use a directory for the Ruby standard library");
-        out.println("  --1.8                             1.8 compatibility mode");
-        out.println("  --1.9                             1.9 compatibility mode (default)");
-        out.println("  --2.0                             2.0 compatibility mode");
         out.println("  --full-object-space               enable full ObjectSpace#each_object and similar");
         out.println("  --no-debug                        disable debugging");
         out.println("  --no-trace                        disable tracing");
--- a/graal/com.oracle.truffle.ruby.shell/src/com/oracle/truffle/ruby/shell/Shell.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.shell/src/com/oracle/truffle/ruby/shell/Shell.java	Wed Jan 15 19:27:27 2014 +0000
@@ -117,25 +117,11 @@
         }
 
         if (context.getConfiguration().getStandardLibrary().endsWith(".jar")) {
-            String version = null;
-
-            switch (configurationBuilder.getRubyVersion()) {
-                case RUBY_18:
-                    version = "1.8";
-                    break;
-                case RUBY_19:
-                    version = "1.9";
-                    break;
-                case RUBY_20:
-                    version = "2.0";
-                    break;
-                case RUBY_21:
-                    version = "2.0";
-                    break;
-            }
-
-            loadPath.push(context.makeString("jar:file:" + context.getConfiguration().getStandardLibrary() + "!/META-INF/jruby.home/lib/ruby/" + version));
-
+            /*
+             * Use the 1.9 library, even though we're emulating 2.1, as there are some bugs running
+             * the 2.1 library at the moment.
+             */
+            loadPath.push(context.makeString("jar:file:" + context.getConfiguration().getStandardLibrary() + "!/META-INF/jruby.home/lib/ruby/1.9"));
         } else {
             loadPath.push(context.makeString(context.getConfiguration().getStandardLibrary()));
         }
--- a/graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/RubyTests.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/RubyTests.java	Wed Jan 15 19:27:27 2014 +0000
@@ -51,24 +51,6 @@
     }
 
     /**
-     * Executes some Ruby code of a particular version and asserts that it prints an expected
-     * string. Remember to include the newline characters.
-     */
-    public static void assertPrints(RubyVersion rubyVersion, String expectedOutput, String code, String... args) {
-        ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
-        configurationBuilder.setRubyVersion(rubyVersion);
-        assertPrints(new Configuration(configurationBuilder), expectedOutput, "(test)", code, "", args);
-    }
-
-    /**
-     * Executes some Ruby code in a file and asserts that it prints an expected string. Remember to
-     * include the newline characters.
-     */
-    public static void assertFilePrints(String expectedOutput, String fileName, String... args) {
-        assertPrints(null, expectedOutput, fileName, null, "", args);
-    }
-
-    /**
      * Executes some Ruby code and asserts that it prints an expected string. Remember to include
      * the newline characters. Also takes a string to simulate input.
      */
--- a/graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/core/ContinuationTests.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/core/ContinuationTests.java	Wed Jan 15 19:27:27 2014 +0000
@@ -11,7 +11,6 @@
 
 import org.junit.*;
 
-import com.oracle.truffle.ruby.runtime.configuration.*;
 import com.oracle.truffle.ruby.test.*;
 
 /**
@@ -20,34 +19,24 @@
 public class ContinuationTests extends RubyTests {
 
     @Test
-    public void testRequired18() {
-        assertPrints(RubyVersion.RUBY_18, "", "callcc { |c| c.call }");
-    }
-
-    @Test
-    public void testRequired19() {
-        assertPrints(RubyVersion.RUBY_19, "", "require \"continuation\"; callcc { |c| c.call }");
-    }
-
-    @Test
-    public void testRequired20() {
-        assertPrints(RubyVersion.RUBY_20, "", "require \"continuation\"; callcc { |c| c.call }");
+    public void testRequired() {
+        assertPrints("", "require \"continuation\"; callcc { |c| c.call }");
     }
 
     @Test
     public void testOneShotGoingUpCallstack() {
-        assertPrints(RubyVersion.RUBY_18, "1\n3\n", "callcc { |c| puts 1; c.call; puts 2 }; puts 3");
+        assertPrints("1\n3\n", "require \"continuation\"; callcc { |c| puts 1; c.call; puts 2 }; puts 3");
     }
 
     @Test
     public void testOneShotGoingUpCallstackReturnValue() {
-        assertPrints(RubyVersion.RUBY_18, "14\n", "puts callcc { |c| c.call 14 }");
+        assertPrints("14\n", "require \"continuation\"; puts callcc { |c| c.call 14 }");
     }
 
     @Test
     public void testNestedOneShotGoingUpCallstack() {
-        assertPrints(RubyVersion.RUBY_18, "1\n2\n4\n5\n", "callcc { |c1| puts 1; callcc { |c2| puts 2; c2.call; puts 3 }; puts 4 }; puts 5");
-        assertPrints(RubyVersion.RUBY_18, "1\n2\n5\n", "callcc { |c1| puts 1; callcc { |c2| puts 2; c1.call; puts 3 }; puts 4 }; puts 5");
+        assertPrints("1\n2\n4\n5\n", "require \"continuation\"; callcc { |c1| puts 1; callcc { |c2| puts 2; c2.call; puts 3 }; puts 4 }; puts 5");
+        assertPrints("1\n2\n5\n", "require \"continuation\"; callcc { |c1| puts 1; callcc { |c2| puts 2; c1.call; puts 3 }; puts 4 }; puts 5");
     }
 
 }
--- a/graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/core/ProcTests.java	Wed Jan 15 15:11:47 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/core/ProcTests.java	Wed Jan 15 19:27:27 2014 +0000
@@ -11,7 +11,6 @@
 
 import org.junit.*;
 
-import com.oracle.truffle.ruby.runtime.configuration.*;
 import com.oracle.truffle.ruby.test.*;
 
 /**
@@ -38,18 +37,8 @@
     }
 
     @Test
-    public void testProcReturn18() {
-        assertPrints(RubyVersion.RUBY_18, "2\n", "def foo; x = proc { return 1 }; x.call; return 2; end; puts foo");
-    }
-
-    @Test
-    public void testProcReturn19() {
-        assertPrints(RubyVersion.RUBY_19, "1\n", "def foo; x = proc { return 1 }; x.call; return 2; end; puts foo");
-    }
-
-    @Test
-    public void testProcReturn20() {
-        assertPrints(RubyVersion.RUBY_20, "1\n", "def foo; x = proc { return 1 }; x.call; return 2; end; puts foo");
+    public void testProcReturn() {
+        assertPrints("1\n", "def foo; x = proc { return 1 }; x.call; return 2; end; puts foo");
     }
 
     @Test