本文整理汇总了C#中InternalLocal类的典型用法代码示例。如果您正苦于以下问题:C# InternalLocal类的具体用法?C# InternalLocal怎么用?C# InternalLocal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InternalLocal类属于命名空间,在下文中一共展示了InternalLocal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeclareLocal
protected virtual IEntity DeclareLocal(Node sourceNode, string name, IType localType, bool privateScope)
{
ClearResolutionCacheFor(name);
var local = new Local(name, privateScope);
local.LexicalInfo = sourceNode.LexicalInfo;
var entity = new InternalLocal(local, localType);
local.Entity = entity;
CurrentMethod.Locals.Add(local);
return entity;
}
示例2: CloneOrAssignToTemp
Expression CloneOrAssignToTemp(InternalLocal temp, Expression operand)
{
return null == temp
? operand.CloneNode()
: CodeBuilder.CreateAssignment(
CodeBuilder.CreateReference(temp),
operand.CloneNode());
}
示例3: AddInternalFieldFor
private void AddInternalFieldFor(InternalLocal entity)
{
Field field = _enumerator.AddInternalField(UniqueName(entity.Name), entity.Type);
_mapping[entity] = field.Entity;
}
示例4: IsExceptionHandlerVariable
private bool IsExceptionHandlerVariable(InternalLocal local)
{
Declaration originalDeclaration = local.OriginalDeclaration;
if (originalDeclaration == null) return false;
return originalDeclaration.ParentNode is ExceptionHandler;
}
示例5: CreateReference
public ReferenceExpression CreateReference(InternalLocal local)
{
return CreateLocalReference(local.Name, local);
}
示例6: ImplementByRefICallableCall
void ImplementByRefICallableCall(
Method call,
InternalCallableType type,
ClassDefinition node,
CallableSignature signature,
int byRefCount)
{
MethodInvocationExpression mie = CreateInvokeInvocation(type);
IParameter[] parameters = signature.Parameters;
ReferenceExpression args = CodeBuilder.CreateReference(call.Parameters[0]);
InternalLocal[] temporaries = new InternalLocal[byRefCount];
int byRefIndex = 0;
for (int i=0; i<parameters.Length; ++i)
{
SlicingExpression slice = CodeBuilder.CreateSlicing(args.CloneNode(), i);
IParameter parameter = parameters[i];
if (parameter.IsByRef)
{
IType tempType = parameter.Type;
if (tempType.IsByRef)
{
tempType = tempType.ElementType;
}
temporaries[byRefIndex] = CodeBuilder.DeclareLocal(call,
"__temp_" + parameter.Name,
tempType);
call.Body.Add(
CodeBuilder.CreateAssignment(
CodeBuilder.CreateReference(temporaries[byRefIndex]),
CodeBuilder.CreateCast(
tempType,
slice)));
mie.Arguments.Add(
CodeBuilder.CreateReference(
temporaries[byRefIndex]));
++byRefIndex;
}
else
{
mie.Arguments.Add(slice);
}
}
if (TypeSystemServices.VoidType == signature.ReturnType)
{
call.Body.Add(mie);
PropagateByRefParameterChanges(call, parameters, temporaries);
}
else
{
InternalLocal invokeReturnValue = CodeBuilder.DeclareLocal(call,
"__returnValue", signature.ReturnType);
call.Body.Add(
CodeBuilder.CreateAssignment(
CodeBuilder.CreateReference(invokeReturnValue),
mie));
PropagateByRefParameterChanges(call, parameters, temporaries);
call.Body.Add(
new ReturnStatement(
CodeBuilder.CreateReference(invokeReturnValue)));
}
}
示例7: LoadIndirectLocal
void LoadIndirectLocal(InternalLocal local)
{
LoadLocal(local);
IType et = local.Type.ElementType;
PopType();
PushType(et);
OpCode code = GetLoadRefParamCode(et);
if (code == OpCodes.Ldobj)
_il.Emit(code, GetSystemType(et));
else
_il.Emit(code);
}
示例8: CreateInitValueType
public Expression CreateInitValueType(LexicalInfo li, InternalLocal local)
{
return CreateInitValueType(li, CreateReference(local));
}
示例9: EmitAssignment
void EmitAssignment(InternalLocal tag, IType typeOnStack)
{
// todo: assignment result must be type on the left in the
// case of casting
LocalBuilder local = tag.LocalBuilder;
EmitCastIfNeeded(tag.Type, typeOnStack);
_il.Emit(OpCodes.Stloc, local);
}
示例10: EmitIndirectAssignment
void EmitIndirectAssignment(InternalLocal tag, IType typeOnStack)
{
IType et = tag.Type.ElementType;
EmitCastIfNeeded(et, typeOnStack);
OpCode code = GetStoreRefParamCode(et);
if (code == OpCodes.Stobj)
_il.Emit(code, GetSystemType(et));
else
_il.Emit(code);
}
示例11: EmitIndirectAssignment
void EmitIndirectAssignment(InternalLocal local, IType typeOnStack)
{
var elementType = local.Type.ElementType;
EmitCastIfNeeded(elementType, typeOnStack);
var code = GetStoreRefParamCode(elementType);
if (code == OpCodes.Stobj)
_il.Emit(code, GetSystemType(elementType));
else
_il.Emit(code);
}
示例12: CreateReference
private ReferenceExpression CreateReference(InternalLocal enteredLoop)
{
return CodeBuilder().CreateReference(enteredLoop);
}
示例13: CreateSideEffectAwareSlicingOperation
private Expression CreateSideEffectAwareSlicingOperation(LexicalInfo lexicalInfo, BinaryOperatorType binaryOperator, SlicingExpression lvalue, Expression rvalue, InternalLocal returnValue)
{
MethodInvocationExpression eval = CodeBuilder.CreateEvalInvocation(lexicalInfo);
if (HasSideEffect(lvalue.Target))
{
InternalLocal temp = AddInitializedTempLocal(eval, lvalue.Target);
lvalue.Target = CodeBuilder.CreateReference(temp);
}
foreach (Slice slice in lvalue.Indices)
{
Expression index = slice.Begin;
if (HasSideEffect(index))
{
InternalLocal temp = AddInitializedTempLocal(eval, index);
slice.Begin = CodeBuilder.CreateReference(temp);
}
}
BinaryExpression addition = CodeBuilder.CreateBoundBinaryExpression(
GetExpressionType(lvalue),
binaryOperator,
CloneOrAssignToTemp(returnValue, lvalue),
rvalue);
Expression expansion = CodeBuilder.CreateAssignment(
lvalue.CloneNode(),
addition);
// Resolve operator overloads if any
BindArithmeticOperator(addition);
if (eval.Arguments.Count > 0 || null != returnValue)
{
eval.Arguments.Add(expansion);
if (null != returnValue)
{
eval.Arguments.Add(CodeBuilder.CreateReference(returnValue));
}
BindExpressionType(eval, GetExpressionType(lvalue));
expansion = eval;
}
return expansion;
}
示例14: LoadLocal
void LoadLocal(InternalLocal local)
{
LoadLocal(local, false);
}
示例15: CreateDefaultInitializer
public Expression CreateDefaultInitializer(LexicalInfo li, InternalLocal local)
{
return CreateDefaultInitializer(li, CreateReference(local), local.Type);
}