view gen/dvalue.cpp @ 1177:a8b9fc41c34b

Fix #246 by running type->semantic() on parameters so tuples are expanded.
author Frits van Bommel <fvbommel wxs.nl>
date Sun, 29 Mar 2009 23:57:51 +0200
parents 3cf0066e6faf
children f5729209a1d4
line wrap: on
line source

#include "gen/llvm.h"

#include "gen/tollvm.h"
#include "gen/irstate.h"
#include "gen/logger.h"
#include "gen/dvalue.h"
#include "gen/llvmhelpers.h"

#include "declaration.h"

/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////

DVarValue::DVarValue(Type* t, VarDeclaration* vd, LLValue* llvmValue)
{
    var = vd;
    val = llvmValue;
    type = t;
}

DVarValue::DVarValue(Type* t, LLValue* llvmValue)
{
    var = 0;
    val = llvmValue;
    type = t;
}

LLValue* DVarValue::getLVal()
{
    assert(val);
    return val;
}

LLValue* DVarValue::getRVal()
{
    assert(val);
    Type* bt = type->toBasetype();
    if (DtoIsPassedByRef(bt))
        return val;
    return DtoLoad(val);
}

/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////

LLValue* DSliceValue::getRVal()
{
    assert(len);
    assert(ptr);
    return DtoAggrPair(len, ptr);
}

/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////

DFuncValue::DFuncValue(FuncDeclaration* fd, LLValue* v, LLValue* vt)
{
    func = fd;
    type = func->type;
    val = v;
    vthis = vt;
}

LLValue* DFuncValue::getRVal()
{
    assert(val);
    return val;
}

/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////

LLValue* DConstValue::getRVal()
{
    assert(c);
    return c;
}

/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////