>>>>> "LT" == Leopold Toetsch <[EMAIL PROTECTED]> writes:
LT> Ilya Martynov <[EMAIL PROTECTED]> wrote:
>> Hello all,
>> 1) First question is how to tell if variadic function recieved 11 or
>> 12 or more params (for simplicity let's suppose that we use only
>> pmc parameters).
>> According calling conventions (pdd03) first 11 params end up in P5-P15
>> registers and leftover goes into array in P3. The problem is that
>> there is no indication (unless I'm missing something) if function was
>> called with more than 11 params other than register P3 being
>> initialized with some array PMC. But it may be as well that function
>> was called with just 11 params and P3 contains some array by accident
>> (it could be for example some array from previous sub call).
LT> 11 arguments passed: P5..P15, P3 is NULL (is_null P3 ...)
LT> 12 arguments passed: P5..P15, Ix = P3, Ix := 1
LT> But I'm not sure if P3 actually is cleared (rather not :)
It is not.
.sub _main
P3 = new .PerlArray
# call with 11 parameters
_foo($P1, $P2, $P3, $P4, $P5, $P6, $P7, $P8, $P9, $P10, $P11)
end
.end
.sub _foo
isnull P3, p3_is_null
print "P3 is not NULL\n"
goto return
p3_is_null:
print "P3 is NULL\n"
return:
.end
Prints 'P3 is not NULL'
>> 2) Second question if there is an op to access registers by their
>> number (it is quite troublesome to write code to retrieve
>> parameters in variadic function from P5-P15 registeres without such
>> op).
LT> You are probably looking for C<foldup>. s. t/op/calling.t
Thanks, I'll take a look.
>> 3) Not really a question but a feature request for IMCC to provide
>> some support for variadic functions to avoid writing same code
>> again and again to read parameters of variadic function from either
>> P5-P15 registers or from array in P3 register as necessary. Not
>> sure about syntax though. It could look for example like this:
LT> C<foldup> again.
LT> leo
--
Ilya Martynov, [EMAIL PROTECTED]
CTO IPonWEB (UK) Ltd
Quality Perl Programming and Unix Support
UK managed @ offshore prices - http://www.iponweb.net
Personal website - http://martynov.org