Skip to content

Built-in primitives do not use proper error codes #162

@LinqLover

Description

@LinqLover

Forgive me if this statement is not true in its generality, but I found at least a couple of occurrences. For example, the perform primitives do not emit proper error codes at the moment such as #'bad number of arguments' or #'bad argument'. This is inconsistent with the OSVM and the image-side simulator and, if I did not overlook anything, the last reason after my recent PRs that keeps all the ContextTests from going green.

Would this be desired? Would this pattern be the right approach?

    primitivePerform: function(argCount) {
        var selector = this.stackValue(argCount-1);
        var rcvr = this.stackValue(argCount);
        var trueArgCount = argCount - 1;
        var entry = this.findSelectorInClass(selector, trueArgCount, this.getClass(rcvr), argCount);
        if (entry.selector === selector) {
            // selector has been found, rearrange stack
-             if (entry.argCount !== trueArgCount)
+             if (entry.argCount !== trueArgCount) {
+               this.vm.primFailCode = Squeak.PrimErrBadNumArgs;
                return false;
+             }
        var stack = this.activeContext.pointers; // slide eveything down...
            var selectorIndex = this.sp - trueArgCount;
        this.arrayCopy(stack, selectorIndex+1, stack, selectorIndex, trueArgCount);
        this.sp--; // adjust sp accordingly
        } else {
            // stack has already been arranged for #doesNotUnderstand:/#cannotInterpret:
            rcvr = this.stackValue(entry.argCount);
        }
        this.executeNewMethod(rcvr, entry.method, entry.argCount, entry.primIndex, entry.mClass, selector);
        return true;
    },

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions