Skip to content

Commit

Permalink
Fix bug in performWithArgumentsInSuperclass primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
charig committed Dec 3, 2015
1 parent c48222b commit f8fff7b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package som.primitives.reflection;

import som.interpreter.SArguments;
import som.interpreter.nodes.nary.QuaternaryExpressionNode;
import som.vmobjects.SArray;
import som.vmobjects.SClass;
import som.vmobjects.SInvokable;
import som.vmobjects.SSymbol;
Expand All @@ -25,10 +27,10 @@ public PerformWithArgumentsInSuperclassPrim() {
@Specialization
public final Object doSAbstractObject(final VirtualFrame frame,
final Object receiver, final SSymbol selector,
final Object[] argArr, final SClass clazz) {
final SArray argsArr, final SClass clazz) {
CompilerAsserts.neverPartOfCompilation("PerformWithArgumentsInSuperclassPrim.doSAbstractObject()");
SInvokable invokable = clazz.lookupInvokable(selector);
return call.call(frame, invokable.getCallTarget(), mergeReceiverWithArguments(receiver, argArr));
return call.call(frame, invokable.getCallTarget(), SArguments.createSArguments(SArguments.getEnvironment(frame), SArguments.getExecutionLevel(frame), mergeReceiverWithArguments(receiver, argsArr.toJavaArray())));
}

// TODO: remove duplicated code, also in symbol dispatch, ideally removing by optimizing this implementation...
Expand Down
10 changes: 10 additions & 0 deletions src/som/vmobjects/SArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ public boolean[] getBooleanStorage(final ValueProfile storageType) {
assert type == ArrayType.BOOLEAN;
return (boolean[]) storage;
}

public Object[] toJavaArray(){
if (this.getType() == ArrayType.PARTIAL_EMPTY) {
return this
.getPartiallyEmptyStorage(ValueProfile.createClassProfile())
.getStorage();
} else {
return this.getObjectStorage(ValueProfile.createClassProfile());
}
}

/**
* Creates and empty array, using the EMPTY strategy.
Expand Down

0 comments on commit f8fff7b

Please sign in to comment.