applyprimitiveprocedure now uses argcount

This commit is contained in:
Danny Yoo 2011-04-08 23:57:38 -04:00
parent 29fa60d89e
commit 49d2fd4803
6 changed files with 9 additions and 9 deletions

View File

@ -360,8 +360,7 @@ EOF
(assemble-display-name (MakeCompiledProcedureShell-display-name op)))]
[(ApplyPrimitiveProcedure? op)
(format "MACHINE.proc(MACHINE, ~a)"
(ApplyPrimitiveProcedure-arity op))]
(format "MACHINE.proc(MACHINE, MACHINE.argcount)")]
[(GetControlStackLabel? op)
(format "MACHINE.control[MACHINE.control.length-1].label")]

View File

@ -825,7 +825,7 @@
(make-instruction-sequence
`(,(make-PerformStatement (make-CheckPrimitiveArity! (make-Reg 'argcount)))
,(make-AssignPrimOpStatement 'val
(make-ApplyPrimitiveProcedure number-of-arguments))
(make-ApplyPrimitiveProcedure))
,(make-PopEnvironment number-of-arguments 0)
,(make-AssignImmediateStatement target (make-Reg 'val))))
(LabelLinkage-label after-call)))))))

View File

@ -170,9 +170,9 @@
;; Applies the primitive procedure that's stored in the proc register, using
;; the arity number of values that are bound in the environment as arguments
;; the argcount number of values that are bound in the environment as arguments
;; to that primitive.
(define-struct: ApplyPrimitiveProcedure ([arity : Natural])
(define-struct: ApplyPrimitiveProcedure ()
#:transparent)

View File

@ -397,7 +397,7 @@
(let: ([prim : SlotValue (machine-proc m)]
[args : (Listof PrimitiveValue)
(map ensure-primitive-value (take (machine-env m)
(ApplyPrimitiveProcedure-arity op)))])
(ensure-natural (machine-argcount m))))])
(cond
[(primitive-proc? prim)
(target-updater! m (ensure-primitive-value

View File

@ -153,8 +153,8 @@
(make-Const 3))
(make-AssignImmediateStatement (make-EnvLexicalReference 1 #f)
(make-Const 4))
(make-AssignPrimOpStatement 'val
(make-ApplyPrimitiveProcedure 2))
(make-AssignImmediateStatement 'argcount (make-Const 2))
(make-AssignPrimOpStatement 'val (make-ApplyPrimitiveProcedure))
'done))
"7")

View File

@ -475,7 +475,8 @@
,(make-PushEnvironment 2 #f)
,(make-AssignImmediateStatement (make-EnvLexicalReference 0 #f) (make-Const 126389))
,(make-AssignImmediateStatement (make-EnvLexicalReference 1 #f) (make-Const 42))
,(make-AssignPrimOpStatement 'val (make-ApplyPrimitiveProcedure 2))
,(make-AssignImmediateStatement 'argcount (make-Const 2))
,(make-AssignPrimOpStatement 'val (make-ApplyPrimitiveProcedure))
after))])
(test (machine-val (run m))
(+ 126389 42))