From 0967fa02dc475877577be9644fa391c02f0f6ef8 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Mon, 16 Mar 2020 12:00:40 +0000 Subject: [PATCH] EmptyPrimitive sends now #error: [TODO: tests] TODO: need to test stack behavior needs unit test to check that it works Signed-off-by: Stefan Marr --- src/som/vmobjects/SPrimitive.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/som/vmobjects/SPrimitive.java b/src/som/vmobjects/SPrimitive.java index 21c1683..846b866 100644 --- a/src/som/vmobjects/SPrimitive.java +++ b/src/som/vmobjects/SPrimitive.java @@ -37,7 +37,7 @@ public boolean isPrimitive() { return true; } - public SPrimitive(String signatureString, final Universe universe) { + public SPrimitive(final String signatureString, final Universe universe) { signature = universe.symbolFor(signatureString); } @@ -52,7 +52,7 @@ public SClass getHolder() { } @Override - public void setHolder(SClass value) { + public void setHolder(final SClass value) { holder = value; } @@ -66,16 +66,24 @@ public SClass getSOMClass(final Universe universe) { return universe.primitiveClass; } - public static SPrimitive getEmptyPrimitive(java.lang.String signatureString, + public static SPrimitive getEmptyPrimitive(final java.lang.String signatureString, final Universe universe) { // Return an empty primitive with the given signature return (new SPrimitive(signatureString, universe) { @Override public void invoke(final Frame frame, final Interpreter interpreter) { - // Write a warning to the screen - Universe.println("Warning: undefined primitive " - + this.getSignature().getEmbeddedString() + " called"); + SAbstractObject receiver = null; + for (int i = 0; i < getSignature().getNumberOfSignatureArguments(); i++) { + receiver = frame.pop(); + } + + String msg = "Undefined primitive " + + receiver.getSOMClass(universe).getName().getEmbeddedString() + ">>#" + + this.getSignature().getEmbeddedString() + " called"; + send("error:", + new SAbstractObject[] {receiver, universe.newString(msg)}, + universe, interpreter); } @Override