Пример #1
0
bool OutputDeclaration(TIntermDeclaration* node, TIntermTraverser* it)
{
    TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
    TInfoSink& out = oit->infoSink;

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);

    TVariable* v = node->getVariable();

    if (v->getType().getBasicType() == EbtInvariant) {
        out.debug << "redeclare '" << v->getName() << "' as invariant";
    } else if (v->getType().getBasicType() != EbtStruct) {
        out.debug << "declare '" << v->getName() << "' (" <<
                  v->getType().getCompleteString() <<
                  ") [id: " << v->getUniqueId() << "]";
    } else {
        out.debug << "declare '" << v->getName() << "' (" <<
                  v->getType().getCompleteString() << " '" <<
                  v->getType().getTypeName() << "') [id: " <<
                  v->getUniqueId() << "]";
    }

    out.debug << " {" << node->isFirst() << "}";
    OutputDebugText(out, node);
    out.debug << "\n";

#if DEBUG_CHANGEABLE == 1
    OutputChangeableText(oit->infoSink, node, oit->depth, 0);
#endif

    return true;
}
Пример #2
0
TIntermDeclaration* ir_grow_declaration(TIntermDeclaration* declaration, TSymbol* symbol, TIntermTyped* initializer, TInfoSink& infoSink)
{
	TVariable* var = static_cast<TVariable*>(symbol);
	TIntermSymbol* sym = ir_add_symbol(var->getUniqueId(), var->getName(), var->getType(), var->getType().getLine());
	sym->setGlobal(symbol->isGlobal());
	
	return ir_grow_declaration(declaration, sym, initializer, infoSink);
}
Пример #3
0
//
// Do semantic checking for a variable declaration that has no initializer,
// and update the symbol table.
//
// Returns true if there was an error.
//
bool TParseContext::nonInitErrorCheck(int line, TString& identifier, TPublicType& type)
{
    if (reservedErrorCheck(line, identifier))
        recover();

    TVariable* variable = new TVariable(&identifier, TType(type));

    if (! symbolTable.insert(*variable)) {
        error(line, "redefinition", variable->getName().c_str(), "");
        delete variable;
        return true;
    }

    if (voidErrorCheck(line, identifier, type))
        return true;

    return false;
}