本文整理汇总了C#中AssignmentStatement类的典型用法代码示例。如果您正苦于以下问题:C# AssignmentStatement类的具体用法?C# AssignmentStatement怎么用?C# AssignmentStatement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AssignmentStatement类属于命名空间,在下文中一共展示了AssignmentStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitAssignmentStatement
public override Statement VisitAssignmentStatement(AssignmentStatement assignment)
{
MemberBinding binding = assignment.Target as MemberBinding;
if (binding != null)
{
Expression target = VisitExpression(binding.TargetObject);
Field boundMember = (Field) binding.BoundMember;
Expression source = VisitExpression(assignment.Source);
if (!boundMember.IsStatic && !boundMember.DeclaringType.IsValueType && boundMember.DeclaringType.Contract != null && boundMember.DeclaringType.Contract.FramePropertyGetter != null && boundMember != boundMember.DeclaringType.Contract.FrameField)
{
Local targetLocal = new Local(boundMember.DeclaringType);
Statement evaluateTarget = new AssignmentStatement(targetLocal, target, assignment.SourceContext);
Local sourceLocal = new Local(boundMember.Type);
Statement evaluateSource = new AssignmentStatement(sourceLocal, source, assignment.SourceContext);
Expression guard = new MethodCall(new MemberBinding(targetLocal, boundMember.DeclaringType.Contract.FramePropertyGetter), null, NodeType.Call, SystemTypes.Guard);
Statement check = new ExpressionStatement(new MethodCall(new MemberBinding(guard, SystemTypes.Guard.GetMethod(Identifier.For("CheckIsWriting"))), null, NodeType.Call, SystemTypes.Void));
Statement stfld = new AssignmentStatement(new MemberBinding(targetLocal, boundMember), sourceLocal, assignment.SourceContext);
return new Block(new StatementList(new Statement[] {evaluateTarget, evaluateSource, check, stfld}));
}
else
{
binding.TargetObject = target;
assignment.Source = source;
return assignment;
}
}
else
{
return base.VisitAssignmentStatement(assignment);
}
}
示例2: VisitAssignmentStatement
public override Statement VisitAssignmentStatement(AssignmentStatement assignment)
{
if (assignment == null) return null;
assignment.Source = this.VisitExpression(assignment.Source);
assignment.Target = this.VisitTargetExpression(assignment.Target);
return assignment;
}
示例3: ParseAssignmentStatement
public AssignmentStatement ParseAssignmentStatement(MemoryLocation destination)
{
AssignmentStatement result = new AssignmentStatement(destination);
Scanner.ConsumeOperatorToken(Token.Types.ASSIGN);
result.Expression = ParseExpression();
return result;
}
示例4: VisitAssignmentStatement
public override Statement VisitAssignmentStatement(AssignmentStatement assignment)
{
Expression source = this.VisitExpression(assignment.Source);
System.Diagnostics.Debug.Assert(source != null, "VisitExpression must return non-null if passed non-null");
assignment.Source = source;
Expression target = this.VisitTargetExpression(assignment.Target);
System.Diagnostics.Debug.Assert(target != null, "VisitExpression must return non-null if passed non-null");
assignment.Target = target;
return assignment;
}
示例5: VisitAssignmentStatement
public override void VisitAssignmentStatement(AssignmentStatement assignment)
{
base.VisitAssignmentStatement(assignment);
if (assignment == null)
{
return;
}
var targetLocal = assignment.Target as Local;
if (targetLocal != null)
{
this.assignmented[targetLocal] = assignment.Source;
}
}
示例6: CheckAssignment
private void CheckAssignment(AssignmentStatement assignmentStatement, string targetName, HandleContext context)
{
ISymbolTable symbolTable = context.SymbolTable;
Fragment targetFragmentType = symbolTable.GetFragmentType (targetName);
Fragment sourceFragmentType = symbolTable.InferFragmentType (assignmentStatement.Source);
if (targetFragmentType != sourceFragmentType)
{
symbolTable.MakeUnsafe (targetName);
}
else
{
SetPreConditionForIndexerObject (assignmentStatement, targetName, sourceFragmentType, context);
}
}
示例7: GetAssignedDelegateMethod
private Method GetAssignedDelegateMethod(AssignmentStatement assignmentStatement)
{
Construct construct = (Construct) assignmentStatement.Source;
var expression = construct.Operands[1];
MemberBinding methodBinding;
if (expression is UnaryExpression)
methodBinding = (MemberBinding) ((UnaryExpression) expression).Operand;
else if (expression is BinaryExpression)
//vb.net generates binaryExpressions instead of unary
methodBinding = (MemberBinding) ((BinaryExpression) expression).Operand2;
else
throw new InvalidOperationException ("Could not fetch member binding from delegate statement.");
return (Method) methodBinding.BoundMember;
}
示例8: InferArrayFragment
private void InferArrayFragment(AssignmentStatement assignmentStatement, string targetName, HandleContext context)
{
ISymbolTable symbolTable = context.SymbolTable;
Fragment targetFragmentType = symbolTable.InferFragmentType (assignmentStatement.Source);
if (context.ArrayFragmentTypeDefined[targetName] == false)
{
symbolTable.MakeSafe(targetName, targetFragmentType);
context.ArrayFragmentTypeDefined[targetName] = true;
}
else if (symbolTable.GetFragmentType(targetName) == Fragment.CreateLiteral())
{
symbolTable.MakeSafe(targetName, targetFragmentType);
}
else if (symbolTable.GetFragmentType(targetName) != targetFragmentType && targetFragmentType != Fragment.CreateLiteral())
{
symbolTable.MakeUnsafe(targetName);
}
}
示例9: VisitAssignmentStatement
public override void VisitAssignmentStatement(AssignmentStatement assignment)
{
base.VisitAssignmentStatement(assignment);
if (assignment == null)
{
return;
}
var targetLocal = assignment.Target as Local;
if (targetLocal == null)
{
return;
}
var sourceLiteral = assignment.Source as Literal;
this.localsOfLiteral[targetLocal] = sourceLiteral;
}
示例10: VisitMemberBinding
public override Expression VisitMemberBinding(MemberBinding binding)
{
Member boundMember = binding.BoundMember;
if (boundMember is Field && !boundMember.IsStatic && boundMember.DeclaringType != null && boundMember.DeclaringType.Contract != null && boundMember.DeclaringType.Contract.FramePropertyGetter != null && boundMember != boundMember.DeclaringType.Contract.FrameField)
{
Expression target = VisitExpression(binding.TargetObject);
// Since we do not visit member bindings of assignment statements, we know/guess that this is a ldfld.
Local targetLocal = new Local(boundMember.DeclaringType);
Statement evaluateTarget = new AssignmentStatement(targetLocal, target, binding.SourceContext);
Expression guard = new MethodCall(new MemberBinding(targetLocal, boundMember.DeclaringType.Contract.FramePropertyGetter), null, NodeType.Call, SystemTypes.Guard);
Statement check = new ExpressionStatement(new MethodCall(new MemberBinding(guard, SystemTypes.Guard.GetMethod(Identifier.For("CheckIsReading"))), null, NodeType.Call, SystemTypes.Void));
Statement ldfld = new ExpressionStatement(new MemberBinding(targetLocal, boundMember, binding.SourceContext));
return new BlockExpression(new Block(new StatementList(new Statement[] {evaluateTarget, check, ldfld})), binding.Type);
}
else
{
return base.VisitMemberBinding(binding);
}
}
示例11: VisitAssignmentStatement
public override void VisitAssignmentStatement(AssignmentStatement assignment)
{
this.statements.Add(assignment);
base.VisitAssignmentStatement(assignment);
if (assignment != null)
{
var local = assignment.Target as Local;
if (local != null &&
!Microsoft.FxCop.Sdk.RuleUtilities.IsCompilerGenerated(local))
{
this.locals.Remove(local);
if (!this.initedLocals.Add(local) &&
!this.locals.Contains(local))
{
this.Violate(assignment);
}
this.locals.Clear();
}
}
}
示例12: VisitAssignmentStatement
public override Statement VisitAssignmentStatement(AssignmentStatement assignment) {
if (assignment == null) return null;
if (this.TypeInVariableContext(assignment.Source as Literal))
return null;
if (this.insideMethodContract || this.insideAssertOrAssume || this.insideInvariant) {
this.HandleError(assignment, Error.SideEffectsNotAllowedInContracts);
return null;
}
Composition comp = assignment.Target as Composition;
if (comp != null) {
comp.Expression = this.VisitTargetExpression(comp.Expression);
if (comp.Expression == null) return null;
} else {
bool savedMayReferenceThisAndBase = this.MayReferenceThisAndBase;
MemberBinding mb = assignment.Target as MemberBinding;
if (assignment.Operator == NodeType.Nop
&& mb != null
&& (mb.TargetObject is ImplicitThis || mb.TargetObject is This)) {
this.MayReferenceThisAndBase = true;
}
assignment.Target = this.VisitTargetExpression(assignment.Target);
this.MayReferenceThisAndBase = savedMayReferenceThisAndBase;
if (assignment.Target == null) return null;
}
TypeNode t = assignment.Target.Type;
if (t == null) assignment.Target.Type = t = SystemTypes.Object;
Expression source = this.VisitExpression(assignment.Source);
if (source == null) return null;
Reference rt = t as Reference;
NodeType oper = assignment.Operator;
if (rt != null && oper != NodeType.CopyReference) t = rt.ElementType;
if (oper != NodeType.Nop && oper != NodeType.CopyReference) {
this.CheckForGetAccessor(assignment.Target);
LRExpression e = new LRExpression(assignment.Target);
assignment.Target = e;
if (assignment.OperatorOverload == null) {
BinaryExpression be = new BinaryExpression(e, source, assignment.Operator, t, assignment.SourceContext);
if (assignment.UnifiedType != t && assignment.UnifiedType != null) be.Type = assignment.UnifiedType;
Expression pop = new Expression(NodeType.Pop, be.Type);
Pointer pt = t as Pointer;
if (pt != null && (assignment.Operator == NodeType.Add || assignment.Operator == NodeType.Sub)) {
if (pt.ElementType != SystemTypes.Int8 && pt.ElementType != SystemTypes.UInt8) {
UnaryExpression sizeOf = new UnaryExpression(new Literal(pt.ElementType, SystemTypes.Type), NodeType.Sizeof, SystemTypes.UInt32);
Expression elemSize = PureEvaluator.EvalUnaryExpression((Literal)sizeOf.Operand, sizeOf);
if (elemSize == null) elemSize = sizeOf;
TypeNode offsetType = SystemTypes.Int32;
if (source.Type != null && source.Type.IsPrimitiveInteger) offsetType = source.Type;
BinaryExpression offset = new BinaryExpression(source, elemSize, NodeType.Mul, offsetType, source.SourceContext);
Literal offsetLit = PureEvaluator.TryEvalBinaryExpression(source as Literal, elemSize as Literal, offset, this.typeSystem);
if (offsetLit == null) {
if (offsetType == SystemTypes.Int32)
offset.Operand1 = new UnaryExpression(source, NodeType.Conv_I);
else
offset.Operand2 = this.typeSystem.ExplicitCoercion(elemSize, offsetType, this.TypeViewer);
source = offset;
} else
source = offsetLit;
}
source = this.typeSystem.ExplicitCoercion(source, pt, this.TypeViewer);
be.Operand2 = source;
assignment.Source = be;
return assignment;
}
source = this.CoerceBinaryExpressionOperands(be, pop, source);
if (source == null) return null;
if (source == pop)
source = e;
else if (!(source is Literal)) {
be.Operand1 = e;
}
}
assignment.Operator = NodeType.Nop;
if (!t.IsPrimitiveNumeric && t != SystemTypes.Char && t != SystemTypes.Boolean && assignment.OperatorOverload == null &&
(assignment.UnifiedType == null || !assignment.UnifiedType.IsPrimitiveNumeric) &&
oper != NodeType.AddEventHandler && oper != NodeType.RemoveEventHandler &&
!(t is DelegateNode && (source.NodeType == NodeType.Add || source.NodeType == NodeType.Sub)) && !(t is EnumNode)) {
this.HandleError(assignment, Error.BadBinaryOps,
this.GetOperatorSymbol(oper), this.GetTypeName(t), this.GetTypeName(assignment.Source.Type));
return null;
}
if (assignment.OperatorOverload != null) {
if (assignment.OperatorOverload.Parameters == null || assignment.OperatorOverload.Parameters.Count < 2) {
Debug.Assert(false); return null;
}
source = this.typeSystem.ImplicitCoercion(source, assignment.OperatorOverload.Parameters[1].Type, this.TypeViewer);
ExpressionList arguments = new ExpressionList(e, source);
source = new MethodCall(new MemberBinding(null, assignment.OperatorOverload), arguments, NodeType.Call, assignment.OperatorOverload.ReturnType);
assignment.OperatorOverload = null;
}
}
assignment.Source = this.typeSystem.ImplicitCoercion(source, t, this.TypeViewer);
return assignment;
}
示例13: VisitAssignmentStatement
public override Statement VisitAssignmentStatement(AssignmentStatement assignment){
if (assignment == null) return null;
if (assignment.Operator == NodeType.Add || assignment.Operator == NodeType.Sub){
Expression t = this.VisitExpression(assignment.Target);
DelegateNode dt = TypeNode.StripModifiers(t.Type) as DelegateNode;
MemberBinding mb = t as MemberBinding;
if (dt != null && mb != null){
Event e = mb.BoundMember as Event;
if (e != null){
//There is no backing field for this event, use the add or remove accessor
ExpressionList arguments = new ExpressionList(1);
Expression src = this.VisitExpression(assignment.Source);
if (src is MemberBinding && ((MemberBinding)src).BoundMember is Method)
src = this.VisitExpression(new Construct(new MemberBinding(null, e.HandlerType), new ExpressionList(assignment.Source)));
arguments.Add(src);
Method adderOrRemover = assignment.Operator == NodeType.Add ? e.HandlerAdder : e.HandlerRemover;
adderOrRemover.ObsoleteAttribute = e.ObsoleteAttribute;
mb.BoundMember = adderOrRemover;
MethodCall mc = new MethodCall(mb, arguments, NodeType.Call);
if (!(mb.TargetObject is Base) && e.HandlerAdder.IsVirtualAndNotDeclaredInStruct)
mc.NodeType = NodeType.Callvirt;
mc.Type = SystemTypes.Void;
mc.SourceContext = assignment.SourceContext;
Construct c1 = src as Construct;
if (c1 != null && c1.Type == null)
c1.Type = t.Type;
Identifier id = src as Identifier;
if (id != null && id.Type == null && t.Type != null && t.Type.IsAssignableTo(SystemTypes.Enum))
id.Type = t.Type;
return new ExpressionStatement(mc);
}else if (mb.BoundMember.DeclaringType != this.currentType && (mb.BoundMember is Field && ((Field)mb.BoundMember).IsPrivate)){
Expression src = this.VisitExpression(assignment.Source);
if (src is MemberBinding && ((MemberBinding)src).BoundMember is Method)
src = this.VisitExpression(new Construct(new MemberBinding(null, dt), new ExpressionList(assignment.Source)));
BinaryExpression bExpr = new BinaryExpression(assignment.Target, src, NodeType.AddEventHandler);
bExpr.SourceContext = assignment.SourceContext;
if (assignment.Operator != NodeType.Add) bExpr.NodeType = NodeType.RemoveEventHandler;
bExpr.Type = SystemTypes.Void;
Construct c1 = src as Construct;
if (c1 != null && c1.Type == null)
c1.Type = t.Type;
Identifier id = src as Identifier;
if (id != null && id.Type == null && t.Type != null && t.Type.IsAssignableTo(SystemTypes.Enum))
id.Type = t.Type;
return new ExpressionStatement(this.VisitExpression(bExpr), assignment.SourceContext);
}
}
}
Expression opnd1 = assignment.Target = this.VisitTargetExpression(assignment.Target);
TypeNode opnd1Type = opnd1 == null ? null : TypeNode.StripModifiers(opnd1.Type);
Expression opnd2;
if (opnd1 != null && opnd1Type is DelegateNode) {
TemplateInstance ti = assignment.Source as TemplateInstance;
if (ti != null && !ti.IsMethodTemplate){
ti.IsMethodTemplate = true;
opnd2 = assignment.Source = this.VisitExpression(new Construct(new MemberBinding(null, opnd1Type), new ExpressionList(assignment.Source)));
}else{
Expression source = assignment.Source;
AnonymousNestedFunction anonFunc = source as AnonymousNestedFunction;
if (anonFunc != null) this.FillInImplicitType(anonFunc, (DelegateNode)opnd1Type);
opnd2 = assignment.Source = this.VisitExpression(assignment.Source);
MemberBinding mb = opnd2 as MemberBinding;
if (mb != null && mb.BoundMember is Method)
opnd2 = assignment.Source = this.VisitExpression(new Construct(new MemberBinding(null, opnd1Type), new ExpressionList(source)));
}
}else{
opnd2 = assignment.Source = this.VisitExpression(assignment.Source);
}
if (assignment.Operator == NodeType.Add && opnd1 != null && opnd2 != null){
TypeNode t1 = this.typeSystem.Unwrap(opnd1.Type);
TypeNode t2 = this.typeSystem.Unwrap(opnd2.Type);
if (t1 == SystemTypes.String){
if (t2 == SystemTypes.String || this.typeSystem.ImplicitCoercionFromTo(t2, SystemTypes.String, this.TypeViewer))
assignment.OperatorOverload = Runtime.StringConcatStrings;
else
assignment.OperatorOverload = Runtime.StringConcatObjects;
return assignment;
}
}
if (assignment.Operator != NodeType.Nop){
BinaryExpression binExpr = new BinaryExpression(assignment.Target, assignment.Source, assignment.Operator);
assignment.OperatorOverload = this.GetBinaryOperatorOverload(binExpr);
if (assignment.OperatorOverload == null && opnd1 != null){
TypeNode t1 = this.typeSystem.Unwrap(opnd1.Type);
if (t1 != null && !t1.IsPrimitiveNumeric && t1 != SystemTypes.Char && !(t1 is EnumNode)){
Literal lit2 = opnd2 as Literal;
if (lit2 != null && lit2.Type != null) {
TypeNode t2 = this.typeSystem.UnifiedType(lit2, t1, this.TypeViewer);
if (t1 != t2 && t2 != SystemTypes.Object) assignment.UnifiedType = t2;
}
}
}
}
if (assignment != null && assignment.Target != null) {
TypeNode type = assignment.Target.Type;
Construct c = assignment.Source as Construct;
if (c != null && c.Type == null)
c.Type = type;
Identifier id = assignment.Source as Identifier;
if (id != null && id.Type == null && type != null && type.IsAssignableTo(SystemTypes.Enum))
//.........这里部分代码省略.........
示例14: Walk
// AssignmentStatement
public override bool Walk(AssignmentStatement node) { return false; }
示例15: PushExprTransformer
/// <summary>
/// Replace an implicit Push with an assignment to the appropriate stack variable.
/// </summary>
protected override Statement PushExprTransformer(ExpressionStatement expr_stat, int depth)
{
Statement new_stat = new AssignmentStatement(get_stack_var(depth, expr_stat.Expression, ref expr_stat.SourceContext), expr_stat.Expression);
new_stat.SourceContext = expr_stat.SourceContext;
return new_stat;
}