本文整理汇总了C#中CodeGen.GetNamedLocal方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.GetNamedLocal方法的具体用法?C# CodeGen.GetNamedLocal怎么用?C# CodeGen.GetNamedLocal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGen
的用法示例。
在下文中一共展示了CodeGen.GetNamedLocal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSlot
internal Slot CreateSlot(CodeGen cg)
{
switch (_kind) {
case VariableKind.Local:
if (_storage == null) {
// Fall back on a runtime lookup if this variable does not have storage associated with it
// (e.g. if the variable belongs to a block in interpreted mode).
return new LocalNamedFrameSlot(cg.ContextSlot, _name);
} else {
return CreateSlotForVariable(cg);
}
case VariableKind.Parameter:
if (_lift) {
if (_storage == null) {
return new LocalNamedFrameSlot(cg.ContextSlot, _name);
} else {
return CreateSlotForVariable(cg);
}
} else {
//Debug.Assert(cg.Allocator.ActiveScope == _block);
return MarkLocal(GetArgumentSlot(cg));
}
case VariableKind.Global:
if (_storage == null) {
return new NamedFrameSlot(cg.ContextSlot, _name);
} else {
// Globals are accessed via context slot
return _storage.CreateSlot(cg.ContextSlot);
}
case VariableKind.Temporary:
return cg.GetNamedLocal(_type, SymbolTable.IdToString(_name));
case VariableKind.GeneratorTemporary:
if (!cg.IsGenerator) {
goto case VariableKind.Temporary;
}
// Allocate in environment if emitting generator.
// This must be done here for now because the environment
// allocation, which is generally done in Allocate(),
// is done in the context of the outer generator codegen,
// which is not marked IsGenerator so the generator temps
// would go onto CLR stack rather than environment.
// TODO: Fix this once we have lifetime analysis in place.
_storage = _block.EnvironmentFactory.MakeEnvironmentReference(_name, _type);
return CreateSlotForVariable(cg);
}
Debug.Assert(false, "Unexpected variable kind: " + _kind.ToString());
return null;
}
示例2: CreateEnvironmentSlot
public override EnvironmentSlot CreateEnvironmentSlot(CodeGen cg)
{
return new ClassEnvironmentSlot(cg.GetNamedLocal(StorageType, "$environment"), StorageType);
}
示例3: EmitConditionalBranches
// Emits the switch as if stmts
private void EmitConditionalBranches(CodeGen cg, Label[] labels)
{
Slot testValueSlot = cg.GetNamedLocal(typeof(int), "switchTestValue");
testValueSlot.EmitSet(cg);
// For all the "cases" create their conditional branches
for (int i = 0; i < _cases.Count; i++) {
// Not default case emit the condition
if (!_cases[i].IsDefault) {
// Test for equality of case value and the test expression
cg.EmitInt(_cases[i].Value);
testValueSlot.EmitGet(cg);
cg.Emit(OpCodes.Beq, labels[i]);
}
}
}