本文整理汇总了C#中LS2IL.FlatOperand.GetLValue方法的典型用法代码示例。如果您正苦于以下问题:C# FlatOperand.GetLValue方法的具体用法?C# FlatOperand.GetLValue怎么用?C# FlatOperand.GetLValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LS2IL.FlatOperand
的用法示例。
在下文中一共展示了FlatOperand.GetLValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resolve
public FlatOperand Resolve(FieldSymbol field, FlatOperand fop_type, FlatOperand into_lvalue, List<FlatStatement> instructions)
{
string field_name = field.Name;
TypeExtraInfo tei = Chunk.GetTypeExtraInfo(field.ContainingType);
if (tei == null)
{
throw new NotImplementedException("field of type without fields declarations? " + field.ContainingType.GetFullyQualifiedName());
}
if (into_lvalue == null)
{
into_lvalue = AllocateRegister("");
into_lvalue = into_lvalue.GetLValue(this, instructions);
}
int nTypeField;
int nField;
if (!field.IsStatic)
{
if (tei.FieldNames.TryGetValue(field_name, out nTypeField) && tei.ResolveRuntimeField(field_name, out nField))
{
FieldExtraInfo fei = tei.Fields[nTypeField];
instructions.Add(FlatStatement.RESOLVEFIELD(into_lvalue, fop_type, FlatOperand.Immediate(FlatValue.Int32(nField))));
return into_lvalue.AsRValue(FlatValue.FromType(field.Type));
}
}
else
{
// static field
instructions.Add(FlatStatement.RESOLVESTATICFIELD(into_lvalue, fop_type, FlatOperand.Immediate(FlatValue.String(field_name))));
return into_lvalue.AsRValue(FlatValue.FromType(field.Type));
}
throw new NotImplementedException("missing field from type " + field.ContainingType.GetFullyQualifiedName());
}
示例2: ResolveExpression
public FlatOperand ResolveExpression(PostfixUnaryExpressionSyntax pues, TypeInfo result_type, FlatOperand into_lvalue, List<FlatStatement> instructions)
{
if (into_lvalue == null)
{
into_lvalue = this.AllocateRegister("");
into_lvalue = into_lvalue.GetLValue(this, instructions);
}
SymbolInfo si = Model.GetSymbolInfo(pues.Operand);
FlatOperand fop_subject;
switch (si.Symbol.Kind)
{
/*
case SymbolKind.Field:
{
// need the parent object for the field
fop_subject = ResolveParentExpression(si, pues.Operand, null, instructions);
TypeSymbol typeSymbol;
FieldSymbol ps = (FieldSymbol)si.Symbol;
if (ps.IsStatic)
{
throw new NotImplementedException("static Field assignment");
}
typeSymbol = ps.Type;
int nField;
if (!GetRuntimeFieldNumber(ps, out nField))
{
throw new NotImplementedException("missing field " + ps.ToDisplayString());
}
FlatOperand fop_fieldnum = FlatOperand.LiteralInteger(nField);
FlatOperand fop_currentvalue = this.AllocateRegister("");
FlatOperand fop_currentlvalue = fop_currentvalue.GetLValue(this, instructions);
// DUPLICATE (to return) the current value of the field
// then increment and SETFIELD
instructions.Add(FlatStatement.GETFIELD(fop_currentlvalue, fop_subject, fop_fieldnum));
instructions.Add(FlatStatement.DUPLICATE(into_lvalue, fop_currentvalue));
switch (pues.Kind)
{
case SyntaxKind.PostIncrementExpression:
instructions.Add(FlatStatement.ADD(fop_currentlvalue, fop_currentvalue, FlatOperand.Immediate(FlatValue.Int8(1))));
break;
case SyntaxKind.PostDecrementExpression:
instructions.Add(FlatStatement.SUB(fop_currentlvalue, fop_currentvalue, FlatOperand.Immediate(FlatValue.Int8(1))));
break;
}
instructions.Add(FlatStatement.SETFIELD(fop_subject, fop_fieldnum, fop_currentvalue));
return into_lvalue.AsRValue(FlatValue.FromType(result_type.ConvertedType));
}
break;*/
case SymbolKind.Field:
{
fop_subject = ResolveParentExpression(si, pues.Operand, null, instructions);
FlatOperand fop_type = TypeOf(fop_subject, null, null, instructions);
FlatOperand fop_Field;
TypeSymbol typeSymbol;
{
FieldSymbol ps = (FieldSymbol)si.Symbol;
if (ps.IsStatic)
{
throw new NotImplementedException("static Field assignment");
}
typeSymbol = ps.Type;
fop_Field = Resolve(ps, fop_type, null, instructions);
}
FlatOperand fop_currentvalue = this.AllocateRegister("");
FlatOperand fop_currentlvalue = fop_currentvalue.GetLValue(this, instructions);
instructions.Add(FlatStatement.GETFIELD(fop_currentlvalue, fop_Field, fop_subject));
instructions.Add(FlatStatement.DUPLICATE(into_lvalue, fop_currentvalue));
switch (pues.Kind)
{
case SyntaxKind.PostIncrementExpression:
instructions.Add(FlatStatement.ADD(fop_currentlvalue, fop_currentvalue, FlatOperand.Immediate(FlatValue.Int32(1))));
break;
case SyntaxKind.PostDecrementExpression:
instructions.Add(FlatStatement.SUB(fop_currentlvalue, fop_currentvalue, FlatOperand.Immediate(FlatValue.Int32(1))));
break;
}
instructions.Add(FlatStatement.SETFIELD(fop_Field, fop_subject, fop_currentvalue));
return into_lvalue.AsRValue(FlatValue.FromType(result_type.ConvertedType));
}
break;
case SymbolKind.Property:
{
fop_subject = ResolveParentExpression(si, pues.Operand, null, instructions);
//.........这里部分代码省略.........
示例3: ResolveExpression
public FlatOperand ResolveExpression(PostfixUnaryExpressionSyntax pues, TypeInfo result_type, FlatOperand into_lvalue, List<FlatStatement> instructions)
{
if (into_lvalue == null)
{
into_lvalue = this.AllocateRegister("");
into_lvalue = into_lvalue.GetLValue(this, instructions);
}
SymbolInfo si = Model.GetSymbolInfo(pues.Operand);
FlatOperand fop_subject;
switch (si.Symbol.Kind)
{
case SymbolKind.Parameter:
{
IParameterSymbol ps = (IParameterSymbol)si.Symbol;
if (ps.RefKind == RefKind.None)
{
FlatOperand op = ResolveExpression(pues.Operand, null, instructions);
instructions.Add(FlatStatement.DUPLICATE(into_lvalue, op));
FlatOperand new_lvalue = op.GetLValue(this,instructions);
switch (pues.CSharpKind())
{
case SyntaxKind.PostIncrementExpression:
instructions.Add(FlatStatement.ADD(new_lvalue, op, FlatOperand.Immediate(FlatValue.Int32(1))));
instructions.Add(FlatStatement.ARRAYSET(FlatOperand.Inputs(), FlatOperand.Immediate(FlatValue.Int32(op.OperandIndex)), new_lvalue.AsRValue(FlatValue.FromType(result_type.ConvertedType))));
return into_lvalue.AsRValue(FlatValue.FromType(result_type.ConvertedType));
case SyntaxKind.PostDecrementExpression:
instructions.Add(FlatStatement.SUB(new_lvalue, op, FlatOperand.Immediate(FlatValue.Int32(1))));
instructions.Add(FlatStatement.ARRAYSET(FlatOperand.Inputs(), FlatOperand.Immediate(FlatValue.Int32(op.OperandIndex)), new_lvalue.AsRValue(FlatValue.FromType(result_type.ConvertedType))));
return into_lvalue.AsRValue(FlatValue.FromType(result_type.ConvertedType));
}
}
else
{
int numParam = 0;
FlatOperand fop_duplicate = ResolveParameter(pues.Operand, null, out numParam, instructions);
FlatOperand new_lvalue = fop_duplicate.GetLValue(this, instructions);
instructions.Add(FlatStatement.DUPLICATE(into_lvalue, fop_duplicate));
switch (pues.CSharpKind())
{
case SyntaxKind.PostIncrementExpression:
instructions.Add(FlatStatement.ADD(new_lvalue, fop_duplicate, FlatOperand.Immediate(FlatValue.Int32(1))));
instructions.Add(FlatStatement.REREFERENCE(FlatOperand.InputRef(numParam,fop_duplicate.ImmediateValue), fop_duplicate));
return into_lvalue.AsRValue(FlatValue.FromType(result_type.ConvertedType));
case SyntaxKind.PostDecrementExpression:
instructions.Add(FlatStatement.SUB(new_lvalue, fop_duplicate, FlatOperand.Immediate(FlatValue.Int32(1))));
instructions.Add(FlatStatement.REREFERENCE(FlatOperand.InputRef(numParam, fop_duplicate.ImmediateValue), fop_duplicate));
return into_lvalue.AsRValue(FlatValue.FromType(result_type.ConvertedType));
}
/*
FlatOperand fop_duplicate = AllocateRegister("local_" + op.ToString());
FlatOperand new_lvalue = fop_duplicate.GetLValue(this, instructions);
instructions.Add(FlatStatement.DEREFERENCE(new_lvalue, op));
instructions.Add(FlatStatement.DUPLICATE(into_lvalue, fop_duplicate));
switch (pues.CSharpKind())
{
case SyntaxKind.PostIncrementExpression:
instructions.Add(FlatStatement.ADD(new_lvalue, fop_duplicate, FlatOperand.Immediate(FlatValue.Int32(1))));
instructions.Add(FlatStatement.REREFERENCE(op, fop_duplicate));
return into_lvalue.AsRValue(FlatValue.FromType(result_type.ConvertedType));
case SyntaxKind.PostDecrementExpression:
instructions.Add(FlatStatement.SUB(new_lvalue, fop_duplicate, FlatOperand.Immediate(FlatValue.Int32(1))));
instructions.Add(FlatStatement.REREFERENCE(op, fop_duplicate));
return into_lvalue.AsRValue(FlatValue.FromType(result_type.ConvertedType));
}
* */
}
// reference
/*
if (node.CSharpKind() == SyntaxKind.SimpleAssignmentExpression)
{
FlatOperand fop_right = ResolveExpression(node.Right, into_lvalue, instructions);
instructions.Add(FlatStatement.REREFERENCE(fop_subject, fop_right));
return fop_right;
}
else
{
FlatOperand fop_right = ResolveExpression(node.Right, into_lvalue, instructions);
FlatOperand fop_duplicate = AllocateRegister("local_" + fop_subject.ToString());
FlatOperand lvalue_final = fop_duplicate.GetLValue(this, instructions);
instructions.Add(FlatStatement.DEREFERENCE(lvalue_final, fop_subject));
ResolveBinaryExpression(node.CSharpKind(), fop_duplicate, fop_right, lvalue_final, instructions);
instructions.Add(FlatStatement.REREFERENCE(fop_subject, fop_duplicate));
return fop_subject;
}
//.........这里部分代码省略.........