Skip to content

Commit

Permalink
[1.9] Fix Method#parameters for AOT-compiled methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius authored and yokolet committed Jan 9, 2011
1 parent 9e73f72 commit 89857bd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
27 changes: 24 additions & 3 deletions src/org/jruby/internal/runtime/methods/CompiledMethod.java
Expand Up @@ -37,11 +37,13 @@
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.Block;
import org.jruby.runtime.MethodFactory;
import org.jruby.runtime.PositionAware;

public abstract class CompiledMethod extends JavaMethod implements Cloneable {
public abstract class CompiledMethod extends JavaMethod implements Cloneable, PositionAware {
protected Object $scriptObject;
protected ISourcePosition position;

public static class LazyCompiledMethod extends DynamicMethod implements Cloneable {
public static class LazyCompiledMethod extends DynamicMethod implements Cloneable, PositionAware {
private final String method;
private final Arity arity;
private final StaticScope scope;
Expand Down Expand Up @@ -198,13 +200,24 @@ public DynamicMethod dup() {
if (compiledMethod == null) initializeMethod();
return compiledMethod.dup();
}

public String getFile() {
if (compiledMethod == null) initializeMethod();
return position.getFile();
}

public int getLine() {
if (compiledMethod == null) initializeMethod();
return position.getStartLine();
}

}

protected CompiledMethod() {}

protected void init(RubyModule implementationClass, Arity arity, Visibility visibility, StaticScope staticScope, Object scriptObject, CallConfiguration callConfig) {
protected void init(RubyModule implementationClass, Arity arity, Visibility visibility, StaticScope staticScope, Object scriptObject, CallConfiguration callConfig, ISourcePosition position) {
this.$scriptObject = scriptObject;
this.position = position;
super.init(implementationClass, arity, visibility, staticScope, callConfig);
}

Expand Down Expand Up @@ -242,4 +255,12 @@ public DynamicMethod dup() {
public boolean isNative() {
return false;
}

public String getFile() {
return position.getFile();
}

public int getLine() {
return position.getStartLine();
}
}// SimpleInvocationMethod
Expand Up @@ -221,7 +221,7 @@ public DynamicMethod getCompiledMethod(
}

CompiledMethod compiledMethod = (CompiledMethod)generatedClass.newInstance();
compiledMethod.init(implementationClass, arity, visibility, scope, scriptObject, callConfig);
compiledMethod.init(implementationClass, arity, visibility, scope, scriptObject, callConfig, position);
return compiledMethod;
} catch(Exception e) {
e.printStackTrace();
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class ReflectedCompiledMethod extends CompiledMethod {
public ReflectedCompiledMethod(RubyModule implementationClass, Arity arity,
Visibility visibility, StaticScope staticScope, Object scriptObject, Method method, CallConfiguration callConfig, ISourcePosition position) {
super();
init(implementationClass, arity, visibility, staticScope, scriptObject, callConfig);
init(implementationClass, arity, visibility, staticScope, scriptObject, callConfig, position);

this.method = method;
this.position = position;
Expand Down

0 comments on commit 89857bd

Please sign in to comment.