view tests/mini/calls1.d @ 920:545f54041d91

Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :) Fixed align N; in asm blocks. Fixed inreg parameter passing on x86 for ref/out params. Removed support for lazy initialization of function local static variables, I have no idea why I ever implemented this, it's not in the D spec, and DMD doesn't support it :P Some of the global variable related changes might cause minor regressions, but they should be easily fixable.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 03 Feb 2009 08:54:57 +0100
parents 1bb99290e03a
children
line wrap: on
line source

module calls1;
import tango.core.Vararg;
extern(C) int printf(char*, ...);
void main()
{
    {int a = byVal1(3);}
    {int a = void; byRef1(a);}
    {char[] c = void; refType(c);}
    {char[] c = void; refTypeByRef(c);}
    {S s = void; structByVal(s);}
    {S s = void; structByRef(s);}
    {S s = void; structByPtr(&s);}
    {printf("c-varargs %d %d %d\n", 1,2,3);}
    {int i=3; float f=24.7; dvararg(i,f);}
    {char[] s = "hello"; dvarargRefTy(s);}
    {char[] ss = "hello world!"; dvarargRefTy(ss);}
}

int byVal1(int a)
{
    return a;
}

void byRef1(ref int a)
{
    a = 3;
}

void refType(char[] s)
{
}

void refTypeByRef(ref char[] s)
{
}

struct S
{
    float f;
    double d;
    long l;
    byte b;
}

void structByVal(S s)
{
}

void structByRef(ref S s)
{
}

void structByPtr(S* s)
{
}

void dvararg(...)
{
    printf("%d %.1f\n", va_arg!(int)(_argptr), va_arg!(float)(_argptr));
}

void dvarargRefTy(...)
{
    char[] s = va_arg!(char[])(_argptr);
    printf("%.*s\n", s.length, s.ptr);
}