dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pnet-developers] Dynamic Typing in IL for scripting languages?


From: Rhys Weatherley
Subject: Re: [Pnet-developers] Dynamic Typing in IL for scripting languages?
Date: Fri, 28 Mar 2003 08:08:36 +1000
User-agent: KMail/1.4.3

On Friday 28 March 2003 07:58 am, minddog wrote:

> I'm thinking about Parrot Assembly for this project instead. [...]

If you are going to be generating IL assembly code directly rather than 
writing GHP in C#, then you have some other options besides reflection.  You 
can use the "isinst" instruction to check the type of an object inline within 
the code and then take different actions based upon what it reports.

For example, if you need to convert a value into a string, first use "isinst" 
to see if it already is a string.  If it is, continue on immediately. 
Otherwise, call a helper method to do the conversion for the hard case.  This 
will reduce the amount of overhead in the common case where the programmer 
has already supplied a value of the correct type.  In actual IL:

    <push the object you wish to convert onto the stack>
    isinst System.String
    dup
    brtrue L1
    pop
    call class System.String GHP.Convert::ToString(class System.Object)
L1:

Similarly for operators: check for int*int and double*double, and bail out if 
it is some other kind of multiplication.

Cheers,

Rhys.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]