Permalink
Browse files

Bring branch up to date with trunk

git-svn-id: http://svn.codehaus.org/jruby/branches/jruby-joni@5071 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
1 parent 9422ebc commit 382fc80e7b019e4544e2250f1356dffb5cc28158 @olabini olabini committed Nov 27, 2007
Showing with 2,648 additions and 1,462 deletions.
  1. +40 −142 bin/jrubyc
  2. +1 −6 maven/jruby-complete/pom.xml
  3. +7 −0 maven/jruby/pom.xml
  4. +1 −1 pom.xml
  5. +0 −84 src/org/jruby/JRubyC.java
  6. +5 −3 src/org/jruby/Main.java
  7. +8 −10 src/org/jruby/Ruby.java
  8. +2 −2 src/org/jruby/RubyArgsFile.java
  9. +30 −20 src/org/jruby/RubyArray.java
  10. +3 −2 src/org/jruby/RubyBinding.java
  11. +24 −0 src/org/jruby/RubyClass.java
  12. +2 −1 src/org/jruby/RubyEnumerable.java
  13. +1 −1 src/org/jruby/RubyEnumerator.java
  14. +30 −19 src/org/jruby/RubyFile.java
  15. +3 −3 src/org/jruby/RubyFixnum.java
  16. +11 −2 src/org/jruby/RubyFloat.java
  17. +5 −4 src/org/jruby/RubyGlobal.java
  18. +14 −13 src/org/jruby/RubyIO.java
  19. +8 −5 src/org/jruby/RubyJRuby.java
  20. +52 −33 src/org/jruby/RubyKernel.java
  21. +2 −1 src/org/jruby/RubyMarshal.java
  22. +39 −35 src/org/jruby/RubyModule.java
  23. +2 −1 src/org/jruby/RubyNumeric.java
  24. +43 −118 src/org/jruby/RubyObject.java
  25. +2 −1 src/org/jruby/RubyObjectSpace.java
  26. +26 −9 src/org/jruby/RubyRange.java
  27. +3 −2 src/org/jruby/RubyRegexp.java
  28. +4 −2 src/org/jruby/RubySignal.java
  29. +1 −1 src/org/jruby/RubyString.java
  30. +12 −12 src/org/jruby/RubyStruct.java
  31. +4 −1 src/org/jruby/RubySymbol.java
  32. +3 −3 src/org/jruby/RubyThread.java
  33. +2 −2 src/org/jruby/RubyUnboundMethod.java
  34. +6 −101 src/org/jruby/RubyUndef.java
  35. +1 −1 src/org/jruby/RubyYAML.java
  36. +3 −2 src/org/jruby/ast/executable/RubiniusMachine.java
  37. +1 −1 src/org/jruby/ast/executable/RubiniusRunner.java
  38. +5 −4 src/org/jruby/ast/executable/YARVMachine.java
  39. +2 −1 src/org/jruby/ast/util/ArgsUtil.java
  40. +74 −17 src/org/jruby/compiler/impl/HeapBasedVariableCompiler.java
  41. +18 −15 src/org/jruby/compiler/impl/StandardASMCompiler.java
  42. +1 −1 src/org/jruby/compiler/yarv/StandardYARVCompiler.java
  43. +28 −22 src/org/jruby/evaluator/ASTInterpreter.java
  44. +6 −5 src/org/jruby/evaluator/AssignmentVisitor.java
  45. +11 −11 src/org/jruby/ext/Generator.java
  46. +2 −1 src/org/jruby/internal/runtime/methods/DefaultMethod.java
  47. +1 −1 src/org/jruby/internal/runtime/methods/DynamicMethod.java
  48. +1 −1 src/org/jruby/internal/runtime/methods/YARVMethod.java
  49. +12 −11 src/org/jruby/javasupport/Java.java
  50. +1 −1 src/org/jruby/javasupport/JavaArrayUtilities.java
  51. +14 −12 src/org/jruby/javasupport/JavaClass.java
  52. +2 −2 src/org/jruby/javasupport/JavaObject.java
  53. +1 −1 src/org/jruby/javasupport/JavaUtil.java
  54. +3 −0 src/org/jruby/javasupport/bsf/JRubyEngine.java
  55. +5 −5 src/org/jruby/javasupport/proxy/JavaProxyClass.java
  56. +4 −2 src/org/jruby/javasupport/proxy/JavaProxyConstructor.java
  57. +2 −2 src/org/jruby/javasupport/proxy/JavaProxyReflectionObject.java
  58. +51 −15 src/org/jruby/javasupport/util/RuntimeHelpers.java
  59. +2 −2 src/org/jruby/parser/BlockStaticScope.java
  60. +1 −1 src/org/jruby/parser/LocalStaticScope.java
  61. +4 −1 src/org/jruby/parser/ParserConfiguration.java
  62. +1 −1 src/org/jruby/parser/StaticScope.java
  63. +8 −37 src/org/jruby/runtime/Binding.java
  64. +0 −1 src/org/jruby/runtime/Block.java
  65. +8 −0 src/org/jruby/runtime/BlockBody.java
  66. +7 −2 src/org/jruby/runtime/CallBlock.java
  67. +16 −8 src/org/jruby/runtime/CompiledBlock.java
  68. +15 −7 src/org/jruby/runtime/CompiledBlockLight.java
  69. +3 −3 src/org/jruby/runtime/CompiledSharedScopeBlock.java
  70. +5 −3 src/org/jruby/runtime/Dispatcher.java
  71. +131 −213 src/org/jruby/runtime/DynamicScope.java
  72. +11 −6 src/org/jruby/runtime/InterpretedBlock.java
  73. +7 −2 src/org/jruby/runtime/MethodBlock.java
  74. +1 −1 src/org/jruby/runtime/ObjectSpace.java
  75. +2 −2 src/org/jruby/runtime/SharedScopeBlock.java
  76. +35 −7 src/org/jruby/runtime/ThreadContext.java
  77. +10 −145 src/org/jruby/runtime/builtin/IRubyObject.java
  78. +33 −0 src/org/jruby/runtime/builtin/InstanceVariables.java
  79. +85 −0 src/org/jruby/runtime/builtin/InternalVariables.java
  80. +1 −1 src/org/jruby/runtime/callback/InvocationCallbackFactory.java
  81. +40 −0 src/org/jruby/runtime/marshal/CoreObjectType.java
  82. +105 −97 src/org/jruby/runtime/marshal/MarshalStream.java
  83. +10 −10 src/org/jruby/runtime/marshal/UnmarshalStream.java
  84. +279 −0 src/org/jruby/runtime/scope/ManyVarsDynamicScope.java
  85. +156 −0 src/org/jruby/runtime/scope/NoVarsDynamicScope.java
  86. +191 −0 src/org/jruby/runtime/scope/OneVarDynamicScope.java
  87. +230 −0 src/org/jruby/runtime/scope/TwoVarDynamicScope.java
  88. +0 −65 src/org/jruby/util/CodegenUtils.java
  89. +8 −5 src/org/jruby/util/IOHandlerUnseekable.java
  90. +108 −0 src/org/jruby/util/JavaNameMangler.java
  91. +9 −8 src/org/jruby/util/ShellLauncher.java
  92. +2 −2 src/org/jruby/util/Sprintf.java
  93. +90 −0 src/org/jruby/util/TypeConverter.java
  94. +1 −2 src/org/jruby/util/ZlibInflate.java
  95. +3 −2 src/org/jruby/yaml/JRubyConstructor.java
  96. +187 −0 test/bench/bench_local_vars.rb
  97. +0 −45 test/bench/bench_uncaptured_local_vars.rb
  98. +3 −0 test/jruby_index
  99. +1 −1 test/org/jruby/test/TestKernel.java
  100. +1 −2 test/org/jruby/test/TestRubyObject.java
  101. +1 −1 test/rubicon/test_exception.rb
  102. +3 −3 test/testEval.rb
  103. +1 −1 test/test_array.rb
  104. +25 −0 test/test_eval.rb
  105. +80 −0 test/test_eval_with_binding.rb
  106. +9 −1 test/test_io.rb
  107. +43 −0 test/test_proc_visibility.rb
  108. +31 −0 test/test_zlib.rb
View
@@ -1,148 +1,46 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# jruby.sh - Start Script for the JRuby interpreter
-#
-# Environment Variable Prequisites
-#
-# JRUBY_BASE (Optional) Base directory for resolving dynamic portions
-# of a JRuby installation. If not present, resolves to
-# the same directory that JRUBY_HOME points to.
-#
-# JRUBY_HOME (Optional) May point at your JRuby "build" directory.
-# If not present, the current working directory is assumed.
-#
-# JRUBY_OPTS (Optional) Default JRuby command line args
-# JRUBY_SHELL Where/What is system shell
-#
-# JAVA_HOME Must point at your Java Development Kit installation.
-#
-# -----------------------------------------------------------------------------
+#!/usr/bin/env jruby
-cygwin=false
+require 'jruby'
-# ----- Identify OS we are running under --------------------------------------
-case "`uname`" in
-CYGWIN*) cygwin=true
-esac
+runtime = JRuby.runtime
-# ----- Verify and Set Required Environment Variables -------------------------
+if ARGV.size < 1
+ puts "Usage: jrubyc <filename.rb> [<filename.rb> ...]"
+ exit
+end
-if [ -z "$JRUBY_HOME" ] ; then
- ## resolve links - $0 may be a link to home
- PRG=$0
- progname=`basename "$0"`
+ARGV.each do |filename|
+ unless File.exists? filename
+ puts "Error -- file not found: #{filename}"
+ next
+ end
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '.*/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="`dirname $PRG`/$link"
- fi
- done
+ begin
+ file = File.open(filename)
+ destdir = Dir.pwd
- JRUBY_HOME_1=`dirname "$PRG"` # the ./bin dir
- JRUBY_HOME_1=`dirname "$JRUBY_HOME_1"` # the . dir
- if [ -d "${JRUBY_HOME_1}/lib" ] ; then
- JRUBY_HOME="${JRUBY_HOME_1}"
- fi
-else
- if $cygwin; then
- JRUBY_HOME=`cygpath -u "$JRUBY_HOME"`
- fi
-fi
-
-if [ -z "$JRUBY_OPTS" ] ; then
- JRUBY_OPTS=""
-fi
-
-if [ -z "$JAVA_HOME" ] ; then
- JAVA_CMD='java'
-else
- if $cygwin; then
- JAVA_HOME=`cygpath -u "$JAVA_HOME"`
- fi
- JAVA_CMD="$JAVA_HOME/bin/java"
-fi
-
-JRUBY_SHELL=/bin/sh
-
-# ----- Set Up The System Classpath -------------------------------------------
-
-if [ "$JRUBY_PARENT_CLASSPATH" != "" ]; then
- # Use same classpath propagated from parent jruby
- CP=$JRUBY_PARENT_CLASSPATH
-else
- if [ "$CLASSPATH" != "" ]; then
- CP="$CLASSPATH"
- if $cygwin; then
- CP=`cygpath -p -u "$CP"`
- fi
- else
- CP=""
- fi
-
- CP_DELIMETER=":"
-
- # add necessary jars for command-line execution
- for j in "$JRUBY_HOME"/lib/*.jar; do
- if [ "$CP" ]; then
- CP="$CP$CP_DELIMETER$j"
- else
- CP="$j"
- fi
- done
-
- if $cygwin; then
- CP=`cygpath -p -w "$CP"`
- fi
-fi
-
-# ----- Set Up JRUBY_BASE If Necessary -------------------------------------
-
-if [ -z "$JRUBY_BASE" ] ; then
- JRUBY_BASE="$JRUBY_HOME"
-fi
-
-# ----- Execute The Requested Command -----------------------------------------
-
-DEBUG=""
-if [ "$1" = "JAVA_DEBUG" ]; then
- DEBUG="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"
- shift
-else
- if [ "$1" = "JPROFILER" ]; then
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JPROFILER_PATH/bin/linux-x86
- DEBUG="-Xrunjprofiler:port=8000,noexit -Xbootclasspath/a:/$JPROFILER_PATH/bin/agent.jar"
- shift
- else if [ "$1" = "HPROF" ]; then
- DEBUG="-Xrunhprof:cpu=samples"
- shift
- fi
- fi
-fi
-
-if $cygwin; then
- JAVA_HOME=`cygpath --mixed "$JAVA_HOME"`
- JRUBY_BASE=`cygpath --mixed "$JRUBY_BASE"`
- JRUBY_HOME=`cygpath --mixed "$JRUBY_HOME"`
- JRUBY_SHELL=`cygpath --mixed "$JRUBY_SHELL"`
-fi
-
-EN_US=
-if [ "$1" = "EN_US" ]; then
- EN_US="-Duser.language=en -Duser.country=US"
- shift
-fi
-
-if [ "$1" = "SERVER" ]; then
- DEBUG="-server"
- shift
-fi
-
-exec "$JAVA_CMD" $JAVA_OPTS $DEBUG -Xmx256m -Xss1024k -ea -classpath "$CP" \
-"-Djruby.base=$JRUBY_BASE" "-Djruby.home=$JRUBY_HOME" \
-"-Djruby.lib=$JRUBY_BASE/lib" -Djruby.script=jruby \
-"-Djruby.shell=$JRUBY_SHELL" $EN_US \
-org.jruby.JRubyC $JRUBY_OPTS "$@"
+ BAIS = java.io.ByteArrayInputStream
+ Mangler = org.jruby.util.JavaNameMangler
+ BytecodeCompiler = org.jruby.compiler.impl.StandardASMCompiler
+ ASTCompiler = org.jruby.compiler.ASTCompiler
+ JavaFile = java.io.File
+
+ inspector = org.jruby.compiler.ASTInspector.new
+
+ source = file.read
+ node = runtime.parse_file(BAIS.new(source.to_java_bytes), filename, nil)
+
+ classpath = Mangler.mangle_filename_for_classpath(filename)
+
+ inspector.inspect(node)
+
+ compiler = BytecodeCompiler.new(classpath, filename)
+ ASTCompiler.compile_root(node, compiler, inspector)
+
+ compiler.write_class(JavaFile.new(destdir))
+ rescue
+ puts "Failure during compilation of file #{filename}:\n#{$!}"
+ ensure
+ file.close unless file.nil?
+ end
+end
@@ -16,12 +16,6 @@
<dependencies>
<dependency>
- <groupId>backport-util-concurrent</groupId>
- <artifactId>backport-util-concurrent</artifactId>
- <version>3.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>0.9.91</version>
@@ -61,6 +55,7 @@
<groupId>org.jruby.extras</groupId>
<artifactId>jna</artifactId>
<version>jruby-pre</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
View
@@ -19,36 +19,43 @@
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>0.9.91</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.0</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm-commons</artifactId>
<version>3.0</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm-util</artifactId>
<version>3.0</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm-analysis</artifactId>
<version>3.0</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm-tree</artifactId>
<version>3.0</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jruby.extras</groupId>
<artifactId>jna</artifactId>
<version>jruby-pre</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
View
@@ -245,7 +245,7 @@
<id>jruby-release</id>
<activation>
<property>
- <name>performRelease</name>
+ <name>release</name>
<value>true</value>
</property>
</activation>
View
@@ -1,84 +0,0 @@
-/*
- * JRubyC.java
- *
- * Created on January 11, 2007, 11:24 PM
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package org.jruby;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import java.nio.charset.CharsetDecoder;
-import org.jruby.ast.Node;
-import org.jruby.compiler.ASTInspector;
-import org.jruby.compiler.ASTCompiler;
-import org.jruby.compiler.NotCompilableException;
-import org.jruby.compiler.impl.StandardASMCompiler;
-import org.jruby.util.KCode;
-
-/**
- *
- * @author headius
- */
-public class JRubyC {
-
- public static void main(String args[]) {
- Ruby runtime = Ruby.newInstance();
-
- try {
- if (args.length < 1) {
- System.out.println("Usage: jrubyc <filename> [<filename> ...]");
- return;
- }
- for (int i = 0; i < args.length; i++) {
- String filename = args[i];
- if (filename.startsWith("./")) filename = filename.substring(2);
- File srcfile = new File(filename);
- if (!srcfile.exists()) {
- System.out.println("Error -- file not found: " + filename);
- return;
- }
-
- // destination directory
- File destfile = new File(System.getProperty("user.dir"));
-
- int size = (int)srcfile.length();
- byte[] chars = new byte[size];
- new FileInputStream(srcfile).read(chars);
- // FIXME: -K encoding?
- String content = new String(chars);
- Node scriptNode = runtime.parseFile(new ByteArrayInputStream(content.getBytes("ISO-8859-1")), filename, null);
-
- ASTInspector inspector = new ASTInspector();
- inspector.inspect(scriptNode);
-
- // do the compile
- String classPath = filename.substring(0, filename.lastIndexOf(".")).replace('-', '_').replace('.', '_');
- int lastSlashIndex = classPath.lastIndexOf('/');
- if (!Character.isJavaIdentifierStart(classPath.charAt(lastSlashIndex + 1))) {
- if (lastSlashIndex == -1) {
- classPath = "_" + classPath;
- } else {
- classPath = classPath.substring(0, lastSlashIndex + 1) + "_" + classPath.substring(lastSlashIndex + 1);
- }
- }
- StandardASMCompiler compiler = new StandardASMCompiler(classPath, filename);
- ASTCompiler.compileRoot(scriptNode, compiler, inspector);
-
- compiler.writeClass(destfile);
- }
- } catch (IOException ioe) {
- ioe.printStackTrace();
- System.err.println("Error -- IO exception during compile: " + ioe.getMessage());
- } catch (NotCompilableException nce) {
- System.err.println("Error -- Not compilable: " + nce.getMessage());
- }
- }
-
-}
View
@@ -149,9 +149,11 @@ public void printUsage() {
config.getOutput().println(" -- optional -- before rubyfile.rb for compatibility with ruby");
config.getOutput().println(" -d set debugging flags (set $DEBUG to true)");
config.getOutput().println(" -v print version number, then turn on verbose mode");
- config.getOutput().println(" -O run with ObjectSpace disabled (improves performance)");
+ config.getOutput().println(" -O run with ObjectSpace disabled (default; improves performance)");
+ config.getOutput().println(" +O run with ObjectSpace enabled (default; reduces performance)");
config.getOutput().println(" -S cmd run the specified command in JRuby's bin dir");
- config.getOutput().println(" -C pre-compile scripts before running (EXPERIMENTAL)");
+ config.getOutput().println(" -C disable all compilation");
+ config.getOutput().println(" +C force compilation of all scripts before they are run (except eval)");
config.getOutput().println(" -y read a YARV-compiled Ruby script and run that (EXPERIMENTAL)");
config.getOutput().println(" -Y compile a Ruby script into YARV bytecodes and run this (EXPERIMENTAL)");
config.getOutput().println(" -R read a Rubinius-compiled Ruby script and run that (EXPERIMENTAL)");
@@ -184,7 +186,7 @@ private int runInterpreter() {
return 0;
} catch (RaiseException rj) {
RubyException raisedException = rj.getException();
- if (raisedException.isKindOf(runtime.fastGetClass("SystemExit"))) {
+ if (runtime.fastGetClass("SystemExit").isInstance(raisedException)) {
IRubyObject status = raisedException.callMethod(runtime.getCurrentContext(), "status");
if (status != null && !status.isNil()) {
Oops, something went wrong.

0 comments on commit 382fc80

Please sign in to comment.