Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Variadic functions questions

Newsgroups: perl.perl6.internals
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.perl.org
Return-Path: <i...@iponweb.net>
Mailing-List: contact perl6-internals-h...@perl.org; run by ezmlm
Delivered-To: mailing list perl6-intern...@perl.org
Delivered-To: moderator for perl6-intern...@perl.org
Received: (qmail 34538 invoked by uid 76); 22 Mar 2004 09:45:10 -0000
Received: from x1.develooper.com (HELO x1.develooper.com) (63.251.223.170)
  by onion.perl.org (qpsmtpd/0.27.1) with SMTP; Mon, 22 Mar 2004 01:45:10 -0800
Received: (qmail 24156 invoked by uid 225); 22 Mar 2004 09:45:07 -0000
Delivered-To: perl6-intern...@perl.org
Received: (qmail 24152 invoked by alias); 22 Mar 2004 09:45:07 -0000
X-Spam-Status: No, hits=0.0 required=7.0
	tests=
X-Spam-Check-By: la.mx.develooper.com
Received: from ns.msk.net.ru (HELO tower.msk.net.ru) (195.96.66.209)
  by la.mx.develooper.com (qpsmtpd/0.27.1) with ESMTP; Mon, 22 Mar 2004 01:44:51 -0800
Received: from juil.iponweb.net (ap4.msk.net.ru [172.16.9.2])
	by tower.msk.net.ru (8.12.10/8.12.10/Free) with ESMTP id i2M9idZf002906
	for <perl6-intern...@perl.org>; Mon, 22 Mar 2004 12:44:40 +0300 (MSK)
Received: by juil.iponweb.net (Postfix, from userid 1000)
	id A9E5E170195; Mon, 22 Mar 2004 12:44:47 +0300 (MSK)
To: perl6-intern...@perl.org
Subject: Variadic functions questions
Date: Mon, 22 Mar 2004 12:44:47 +0300
Message-ID: <87zna9z04w.fsf@moto.localhost>
User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Approved: n...@nntp.perl.org
From: i...@iponweb.net (Ilya Martynov)


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).

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).

ops/set.ops has setp_ind op which allows to write to register by its
number but it seems there is no op to read register by its number.

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:

# calculates sum of all parameters
.sub _sum
        new $P1, .PerlInt
        $P1 = 0
        # generates code which sets $I1 to a number of parameters 
        $I1 = .param_num
loop:
        if $I1 == 0 goto return
        # retrieves a parameter by its number
        $P2 = .param($I1)
        add $P1, $P2
        dec $I1
        goto loop
return:
        .pcc_begin_return
        .return $P1
        .pcc_end_return
.end


-- 
Ilya Martynov,  i...@iponweb.net
CTO IPonWEB (UK) Ltd
Quality Perl Programming and Unix Support
UK managed @ offshore prices - http://www.iponweb.net
Personal website - http://martynov.org