本文整理汇总了C++中VariableDeclaration类的典型用法代码示例。如果您正苦于以下问题:C++ VariableDeclaration类的具体用法?C++ VariableDeclaration怎么用?C++ VariableDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VariableDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Ast
void DeclarationBuilder::visitAliasStatement(Ast *node)
{
Ast *right = new Ast(node->tree->r, node->context);
QualifiedIdentifier id = QualifiedIdentifier(QString(right->tree->name));
const RangeInRevision &range = editorFindRange(right, right);
DeclarationPointer decl = getDeclaration(id, range, DUContextPointer(currentContext()));
if (is_global_var(node->tree->l) && is_global_var(right->tree)) {
DUChainWriteLocker wlock;
// If the global variable on the right is not declared, declare it as nil
if (!decl) {
AbstractType::Ptr type = topContext()->findDeclarations(QualifiedIdentifier("NilClass")).first()->abstractType();
VariableDeclaration *vDecl = openDefinition<VariableDeclaration>(id, range);
vDecl->setVariableKind(right->tree);
vDecl->setKind(Declaration::Instance);
vDecl->setType(type);
eventuallyAssignInternalContext();
DeclarationBuilderBase::closeDeclaration();
decl = vDecl;
}
node->tree = node->tree->l;
QualifiedIdentifier aid = getIdentifier(node);
AbstractType::Ptr type = decl->abstractType();
declareVariable(aid, type, node);
} else if (decl && decl->isFunctionDeclaration()) {
DUChainWriteLocker wlock;
MethodDeclaration *md = dynamic_cast<MethodDeclaration *>(decl.data());
node->tree = node->tree->l;
const RangeInRevision & arange = editorFindRange(node, node);
QualifiedIdentifier aid = getIdentifier(node);
aliasMethodDeclaration(aid, arange, md);
} else
appendProblem(node->tree, i18n("undefined method `%1'", id.toString()));
}
示例2: getSize
size_t UnionDeclaration::getSize() const {
size_t sz = 0;
VariableDeclaration *vd;
for(int i = 0; i < members.size(); i++){
vd = members[i]->variableDeclaration();
if(vd->getType()->getSize() > sz)
sz = vd->getType()->getSize();
}
return sz;
}
示例3:
Statement *TypeCompiler::visit(VariableStatement *statement)
{
for (unsigned int i = 0; i < statement->declarations->size(); i++)
{
VariableDeclaration *d = statement->declarations->at(i);
d->visitExpression(this);
}
return statement;
}
示例4: CREATE_PARSER
void ParserTest::parsePositioning()
{
CREATE_PARSER(par);
VariableDeclaration var;
par >> var;
QFETCH(int, start);
QCOMPARE(var.startPos(), start);
QFETCH(int, end);
QCOMPARE(var.endPos(), end);
}
示例5: writeLine
bool ASTPrinter::visit(VariableDeclaration const& _node)
{
writeLine("VariableDeclaration \"" + _node.name() + "\"");
*m_ostream << indentation() << (
_node.annotation().type ?
string(" Type: ") + _node.annotation().type->toString() :
string(" Type unknown.")
) << "\n";
printSourcePart(_node);
return goDeeper();
}
示例6: getAlign
size_t UserTypeDeclaration::getAlign() const {
size_t align = 0;
VariableDeclaration *vd;
for(int i = 0; i < members.size(); i++){
vd = members[i]->variableDeclaration();
assert(vd && "expected variable decl, found something else");
if(vd->getType()->getAlign() > align)
align = vd->getType()->getAlign();
}
if(align == 0) return 1; // TODO: empty struct, bad!
return align; //TODO: handle packed
}
示例7: editorFindRange
void DeclarationBuilder::visitExprMax(ExprMaxAst* node)
{
if (node->var)
{
SimpleRange range = editorFindRange(node->var, node->var);
VariableDeclaration *dec = openDeclaration<VariableDeclaration>(identifierForNode(node->var), range);
dec->setKind(Declaration::Instance);
eventuallyAssignInternalContext();
closeDeclaration();
}
else
{
DeclarationBuilderBase::visitExprMax(node);
}
}
示例8: addAndInitializeVariable
void CompilerContext::addAndInitializeVariable(VariableDeclaration const& _declaration)
{
addVariable(_declaration);
unsigned const size = _declaration.getType()->getSizeOnStack();
for (unsigned i = 0; i < size; ++i)
*this << u256(0);
m_asm.adjustDeposit(-size);
}
示例9: uniformLocation
const GLuint Program::uniformLocation(const VariableDeclaration& u) const
{
auto it = handles_.uniforms.find(u);
if(it == handles_.uniforms.end()) {
std::cerr << u.name() << std::endl;
throw Exception("unknown uniform");
} else {
return it->second;
}
}
示例10: visit
bool Compiler::visit(VariableDeclaration const& _variableDeclaration)
{
solAssert(_variableDeclaration.isStateVariable(), "Compiler visit to non-state variable declaration.");
CompilerContext::LocationSetter locationSetter(m_context, _variableDeclaration);
m_context.startFunction(_variableDeclaration);
m_breakTags.clear();
m_continueTags.clear();
ExpressionCompiler(m_context, m_optimize).appendStateVariableAccessor(_variableDeclaration);
return false;
}
示例11:
StackVariable::StackVariable(CompilerContext& _compilerContext, VariableDeclaration const& _declaration):
LValue(_compilerContext, _declaration.annotation().type.get()),
m_baseStackOffset(m_context.baseStackOffsetOfVariable(_declaration)),
m_size(m_dataType->sizeOnStack())
{
}
示例12: writeLine
bool ASTPrinter::visit(VariableDeclaration const& _node)
{
writeLine("VariableDeclaration \"" + _node.getName() + "\"");
printSourcePart(_node);
return goDeeper();
}
示例13: appendStackVariableInitialisation
void Compiler::appendStackVariableInitialisation(VariableDeclaration const& _variable)
{
CompilerContext::LocationSetter location(m_context, _variable);
m_context.addVariable(_variable);
CompilerUtils(m_context).pushZeroValue(*_variable.getType());
}
示例14: addStateVariable
void CompilerContext::addStateVariable(VariableDeclaration const& _declaration)
{
m_stateVariables[&_declaration] = m_stateVariablesSize;
m_stateVariablesSize += _declaration.getType()->getStorageSize();
}
示例15: addVariable
void CompilerContext::addVariable(VariableDeclaration const& _declaration)
{
m_localVariables[&_declaration] = m_localVariablesSize;
m_localVariablesSize += _declaration.getType()->getSizeOnStack();
}