-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix broken isValue check in CreateActorPrim (fixes #101)
Add proper exception and remove todo. Note, this change stops using the DSL for the IsValue node, because it was generating wrong code, and passing a `null` to isValue.execute*. Signed-off-by: Stefan Marr <git@stefan-marr.de>
- Loading branch information
Showing
2 changed files
with
19 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,45 @@ | ||
package som.primitives.actors; | ||
|
||
import com.oracle.truffle.api.dsl.GenerateNodeFactory; | ||
import com.oracle.truffle.api.dsl.NodeChild; | ||
import com.oracle.truffle.api.dsl.Specialization; | ||
import com.oracle.truffle.api.source.SourceSection; | ||
|
||
import som.interpreter.actors.Actor; | ||
import som.interpreter.actors.SFarReference; | ||
import som.interpreter.nodes.nary.BinaryComplexOperation; | ||
import som.primitives.ObjectPrims.IsValue; | ||
import som.primitives.ObjectPrimsFactory.IsValueFactory; | ||
import som.primitives.ObjectPrimsFactory.IsValueFactory.IsValueNodeGen; | ||
import som.primitives.Primitive; | ||
import som.primitives.actors.PromisePrims.IsActorModule; | ||
import som.vm.VmSettings; | ||
import som.vm.constants.KernelObj; | ||
import tools.concurrency.ActorExecutionTrace; | ||
|
||
|
||
@GenerateNodeFactory | ||
@Primitive(primitive = "actors:createFromValue:", selector = "createActorFromValue:", | ||
specializer = IsActorModule.class, extraChild = IsValueFactory.class) | ||
@NodeChild(value = "isValue", type = IsValue.class, executeWith = "receiver") | ||
specializer = IsActorModule.class) | ||
public abstract class CreateActorPrim extends BinaryComplexOperation { | ||
protected CreateActorPrim(final boolean eagWrap, final SourceSection source) { super(eagWrap, source); } | ||
@Child protected IsValue isValue; | ||
|
||
@Specialization(guards = "isValue") | ||
public final SFarReference createActor(final Object nil, final Object value, final boolean isValue) { | ||
protected CreateActorPrim(final boolean eagWrap, final SourceSection source) { | ||
super(eagWrap, source); | ||
isValue = IsValueNodeGen.createSubNode(); | ||
} | ||
|
||
@Specialization(guards = "isValue.executeEvaluated(argument)") | ||
public final SFarReference createActor(final Object receiver, final Object argument) { | ||
Actor actor = Actor.createActor(); | ||
SFarReference ref = new SFarReference(actor, value); | ||
SFarReference ref = new SFarReference(actor, argument); | ||
|
||
if (VmSettings.ACTOR_TRACING) { | ||
ActorExecutionTrace.actorCreation(ref); | ||
} | ||
return ref; | ||
} | ||
|
||
// TODO: add a proper error or something if it isn't a value... | ||
@Specialization(guards = "!isValue.executeEvaluated(argument)") | ||
public final Object throwNotAValueException(final Object receiver, final Object argument) { | ||
return KernelObj.signalException("signalNotAValueWith:", argument); | ||
} | ||
} |