示例#1
0
void
SymbolTreeBuilder::visit(ConstantNode& node)
{
    node.setScope(currentScope());
    // check module if a constant that matches this value is available
    if (!node.constantValue().valueFitsInByteCode())
    {
        ModuleConstant* mod_constant = _parserState->module.constant(node.constantValue());
        if (!mod_constant)
        {
            _parserState->module.addConstant(new ModuleConstant(node.constantValue()));
        }
    }

    Symbol* tmp_sym = _curScope->declareTemporarySymbol(node.constantType());
    YAL_ASSERT(tmp_sym);
    _curStatment->addSymbolToScope(tmp_sym);
    _expResult = ExpressionResult(node.constantType(), tmp_sym);
    node.setNodeType(_expResult.type);
    node.setExpressionResult(_expResult);
}