本文整理汇总了C++中gc::asVariablePattern方法的典型用法代码示例。如果您正苦于以下问题:C++ gc::asVariablePattern方法的具体用法?C++ gc::asVariablePattern怎么用?C++ gc::asVariablePattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gc
的用法示例。
在下文中一共展示了gc::asVariablePattern方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compileParamField
void ExprCompiler::compileParamField(PatternCompiler& compiler,
gc<Pattern> param, int slot)
{
VariablePattern* variable = param->asVariablePattern();
if (variable != NULL)
{
// It's a variable, so compile its inner pattern. We don't worry about
// the variable itself because the calling convention ensures its value
// is already in the right slot.
compiler.compile(variable->pattern(), slot);
// If we closed over the parameter, then we don't want in a local slot,
// we want it in the upvar, so create it and copy the value up.
if (*variable->name() != "_" &&
variable->resolved()->scope() == NAME_CLOSURE)
{
write(variable->pos(),
OP_SET_UPVAR, variable->resolved()->index(), slot, 1);
}
}
else
{
// Not a variable, so just compile it normally.
compiler.compile(param, slot);
}
}
示例2: resolveParam
void Resolver::resolveParam(gc<Pattern> param)
{
VariablePattern* variable = param->asVariablePattern();
if (variable != NULL)
{
// It's a variable, so resolve its inner pattern.
if (!variable->pattern().isNull())
{
scope_->resolve(*variable->pattern());
}
}
else
{
// Not a variable, so just resolve it normally.
scope_->resolve(*param);
}
}
示例3: makeParamSlot
void Resolver::makeParamSlot(gc<Pattern> param)
{
VariablePattern* variable = param->asVariablePattern();
if (variable != NULL && *variable->name() != "_")
{
// It's a variable, so create a named local for it and resolve the
// variable.
variable->setResolved(makeLocal(param->pos(), variable->name()));
// Note that we do *not* resolve the variable's inner pattern here. We
// do that after all param slots are resolved so that we can ensure the
// param slots are contiguous.
}
else
{
// We don't have a variable for this parameter, but the argument
// will still be on the stack, so make an unnamed slot for it.
makeLocal(param->pos(), String::format("(%d)", unnamedSlotId_++));
}
}
示例4: declareVariables
void Compiler::declareVariables(gc<Pattern> pattern, Module* module)
{
RecordPattern* record = pattern->asRecordPattern();
if (record != NULL)
{
for (int i = 0; i < record->fields().count(); i++)
{
declareVariables(record->fields()[i].value, module);
}
return;
}
VariablePattern* variable = pattern->asVariablePattern();
if (variable != NULL)
{
declareVariable(variable->pos(), variable->name(), module);
if (!variable->pattern().isNull())
{
declareVariables(variable->pattern(), module);
}
}
}