view gen/dvalue.cpp @ 983:6e68054cfc20

Fix out-ouf-source build for runtime as well. To build out-of-source, follow these steps: # [[Insert LLVM build instructions here]] mkdir my_build_dir cd my_build_dir svn co http://svn.dsource.org/projects/tango/trunk tango ccmake <PATH_TO_SOURCE> # (Regular ccmake stuff, press 'c' a few times followed by 'g') make make runtime # add `PWD`/bin to PATH closes #213
author Frits van Bommel <fvbommel wxs.nl>
date Thu, 19 Feb 2009 11:01:34 +0100
parents 30b42a283c8e
children 3cf0066e6faf
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;
}

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

Type*& DLRValue::getLType()
{
    if (DLRValue* lr = lvalue->isLRValue())
    {
        return lr->getLType();
    }
    else
    {
        return lvalue->getType();
    }
}