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: 2dcbc66dd91e
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3bd1281e0c6c
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Nov 3, 2016

  1. Copy the full SHA
    1d64986 View commit details
  2. Copy the full SHA
    3bd1281 View commit details
4 changes: 2 additions & 2 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -1127,7 +1127,7 @@ public void initializeEncodingManager() {
initializeEncodingAliases();

// External should always have a value, but Encoding.external_encoding{,=} will lazily setup
final String externalEncodingName = getContext().getJRubyRuntime().getInstanceConfig().getExternalEncoding();
final String externalEncodingName = getContext().getJRubyInterop().getExternalEncoding();
if (externalEncodingName != null && !externalEncodingName.equals("")) {
final DynamicObject loadedEncoding = getContext().getEncodingManager().getRubyEncoding(externalEncodingName);
if (loadedEncoding == null) {
@@ -1140,7 +1140,7 @@ public void initializeEncodingManager() {
getContext().getEncodingManager().setDefaultExternalEncoding(getContext().getEncodingManager().getLocaleEncoding());
}

final String internalEncodingName = getContext().getJRubyRuntime().getInstanceConfig().getInternalEncoding();
final String internalEncodingName = getContext().getJRubyInterop().getInternalEncoding();
if (internalEncodingName != null && !internalEncodingName.equals("")) {
final DynamicObject rubyEncoding = getContext().getEncodingManager().getRubyEncoding(internalEncodingName);
if (rubyEncoding == null) {
Original file line number Diff line number Diff line change
@@ -145,4 +145,12 @@ public Collection<String> getRequiredLibraries() {
public boolean isFrozenStringLiteral() {
return jrubyRuntime.getInstanceConfig().isFrozenStringLiteral();
}

public String getExternalEncoding() {
return jrubyRuntime.getInstanceConfig().getExternalEncoding();
}

public String getInternalEncoding() {
return jrubyRuntime.getInstanceConfig().getInternalEncoding();
}
}
115 changes: 0 additions & 115 deletions truffle/src/main/java/org/jruby/truffle/parser/Helpers.java
Original file line number Diff line number Diff line change
@@ -343,17 +343,6 @@ public static Errno errnoFromException(Throwable t) {
return null;
}

public static RubyModule getNthScopeModule(StaticScope scope, int depth) {
int n = depth;
while (n > 0) {
scope = scope.getEnclosingScope();
if (scope.getScopeType() != null) {
n--;
}
}
return scope.getModule();
}

public static RubyArray viewArgsArray(ThreadContext context, RubyArray rubyArray, int preArgsCount, int postArgsCount) {
int n = rubyArray.getLength();
if (preArgsCount + postArgsCount >= n) {
@@ -611,103 +600,10 @@ public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, I
return method.call(context, self, superClass, name, arg0, arg1, arg2, block);
}

public static RubyArray ensureRubyArray(IRubyObject value) {
return ensureRubyArray(value.getRuntime(), value);
}

public static RubyArray ensureRubyArray(Ruby runtime, IRubyObject value) {
return value instanceof RubyArray ? (RubyArray)value : RubyArray.newArray(runtime, value);
}

public static IRubyObject nullToNil(IRubyObject value, ThreadContext context) {
return value != null ? value : context.nil;
}

public static IRubyObject nullToNil(IRubyObject value, Ruby runtime) {
return value != null ? value : runtime.getNil();
}

public static IRubyObject nullToNil(IRubyObject value, IRubyObject nil) {
return value != null ? value : nil;
}

public static RubyClass prepareSuperClass(Ruby runtime, IRubyObject rubyClass) {
RubyClass.checkInheritable(rubyClass); // use the same logic as in EvaluationState
return (RubyClass)rubyClass;
}

public static RubyModule prepareClassNamespace(ThreadContext context, StaticScope scope, IRubyObject rubyModule) {
if (rubyModule == null || rubyModule.isNil()) {
rubyModule = scope.getModule();

if (rubyModule == null) {
throw context.runtime.newTypeError("no outer class/module");
}
}

if (rubyModule instanceof RubyModule) {
return (RubyModule)rubyModule;
} else {
throw context.runtime.newTypeError(rubyModule + " is not a class/module");
}
}

public static void handleArgumentSizes(ThreadContext context, Ruby runtime, int given, int required, int opt, int rest) {
if (opt == 0) {
if (rest < 0) {
// no opt, no rest, exact match
if (given != required) {
throw runtime.newArgumentError("wrong number of arguments (" + given + " for " + required + ")");
}
} else {
// only rest, must be at least required
if (given < required) {
throw runtime.newArgumentError("wrong number of arguments (" + given + " for " + required + ")");
}
}
} else {
if (rest < 0) {
// opt but no rest, must be at least required and no more than required + opt
if (given < required) {
throw runtime.newArgumentError("wrong number of arguments (" + given + " for " + required + ")");
} else if (given > (required + opt)) {
throw runtime.newArgumentError("wrong number of arguments (" + given + " for " + (required + opt) + ")");
}
} else {
// opt and rest, must be at least required
if (given < required) {
throw runtime.newArgumentError("wrong number of arguments (" + given + " for " + required + ")");
}
}
}
}

public static String getLocalJumpTypeOrRethrow(RaiseException re) {
RubyException exception = re.getException();
Ruby runtime = exception.getRuntime();
if (runtime.getLocalJumpError().isInstance(exception)) {
RubyLocalJumpError jumpError = (RubyLocalJumpError)re.getException();

IRubyObject reason = jumpError.reason();

return reason.asJavaString();
}

throw re;
}

public static IRubyObject unwrapLocalJumpErrorValue(RaiseException re) {
return ((RubyLocalJumpError)re.getException()).exit_value();
}

public static IRubyObject processBlockArgument(Ruby runtime, Block block) {
if (!block.isGiven()) {
return runtime.getNil();
}

return processGivenBlock(block, runtime);
}

private static IRubyObject processGivenBlock(Block block, Ruby runtime) {
RubyProc blockArg = block.getProcObject();

@@ -754,21 +650,10 @@ private static Block getBlockFromProc(Block currentBlock, IRubyObject proc) {
return ((RubyProc) proc).getBlock();
}

public static Block getBlockFromBlockPassBody(IRubyObject proc, Block currentBlock) {
return getBlockFromBlockPassBody(proc.getRuntime(), proc, currentBlock);

}

public static IRubyObject backref(ThreadContext context) {
return RubyRegexp.getBackRef(context);
}

public static IRubyObject backrefLastMatch(ThreadContext context) {
IRubyObject backref = context.getBackRef();

return RubyRegexp.last_match(backref);
}

public static IRubyObject backrefMatchPre(ThreadContext context) {
IRubyObject backref = context.getBackRef();

Original file line number Diff line number Diff line change
@@ -381,9 +381,7 @@ public final void initMethodCache(int size) {
}

public final IRubyObject getConstant(ThreadContext context, StaticScope scope, String name, int index) {
IRubyObject value = getValue(context, scope, name, index);
// We can callsite cache const_missing if we want
return value != null ? value : scope.getModule().callMethod(context, "const_missing", context.runtime.fastNewSymbol(name));
throw new UnsupportedOperationException();
}

public final IRubyObject getConstantDefined(ThreadContext context, StaticScope scope, String name, int index) {