本文整理汇总了C++中VariableSymbol::storage方法的典型用法代码示例。如果您正苦于以下问题:C++ VariableSymbol::storage方法的具体用法?C++ VariableSymbol::storage怎么用?C++ VariableSymbol::storage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VariableSymbol
的用法示例。
在下文中一共展示了VariableSymbol::storage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void
SemanticAnalysis::visitNameProxy(NameProxy *proxy)
{
Symbol *sym = proxy->sym();
VariableSymbol *var = sym->asVariable();
// If we see that a symbol is a function literal, then we bypass the scope
// chain operations entirely and hardcode the function literal.
if (sym->isFunction()) {
assert(sym->scope()->kind() == Scope::Global);
hir_ = new (pool_) HFunction(proxy, sym->asFunction());
return;
}
if (value_context_ == kLValue) {
// Egads! We're being asked to construct an l-value instead of an r-value.
*outp_ = LValue(var);
return;
}
Scope *in = sym->scope();
switch (in->kind()) {
case Scope::Global:
hir_ = new (pool_) HGlobal(proxy, var);
return;
case Scope::Function:
{
assert(var->storage() == VariableSymbol::Arg);
// Since we're in an r-value context, we need to strip the reference type.
Type *type = var->type();
if (type->isReference())
type = type->toReference()->contained();
hir_ = new (pool_) HLocal(proxy, type, var);
return;
}
default:
assert(in->kind() == Scope::Block);
assert(var->storage() == VariableSymbol::Local);
hir_ = new (pool_) HLocal(proxy, var->type(), var);
return;
}
}