本文整理汇总了C#中AssignmentStatement类的典型用法代码示例。如果您正苦于以下问题:C# AssignmentStatement类的具体用法?C# AssignmentStatement怎么用?C# AssignmentStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssignmentStatement类属于命名空间,在下文中一共展示了AssignmentStatement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:31,代码来源:GuardedFieldAccessInstrumenter.cs
示例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;
}
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:7,代码来源:Unstacker.cs
示例3: ParseAssignmentStatement
public AssignmentStatement ParseAssignmentStatement(MemoryLocation destination)
{
AssignmentStatement result = new AssignmentStatement(destination);
Scanner.ConsumeOperatorToken(Token.Types.ASSIGN);
result.Expression = ParseExpression();
return result;
}
开发者ID:benstopics,项目名称:compilers-6083,代码行数:9,代码来源:Parser.cs
示例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;
}
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:10,代码来源:EmptyVisitor.cs
示例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;
}
}
开发者ID:lavn0,项目名称:CodeAnalysis,代码行数:14,代码来源:LinqResultComparedByNull.cs
示例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);
}
}
开发者ID:rubicon-oss,项目名称:InjectionCop,代码行数:15,代码来源:IndexerAssignmentStatementHandler.cs
示例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;
}
开发者ID:rubicon-oss,项目名称:InjectionCop,代码行数:16,代码来源:DelegateAssignmentStatementHandler.cs
示例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);
}
}
开发者ID:rubicon-oss,项目名称:InjectionCop,代码行数:18,代码来源:IndexerAssignmentStatementHandler.cs
示例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;
}
开发者ID:lavn0,项目名称:CodeAnalysis,代码行数:18,代码来源:AsignedConstOnly.cs
示例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);
}
}
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:19,代码来源:GuardedFieldAccessInstrumenter.cs
示例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();
}
}
}
开发者ID:lavn0,项目名称:CodeAnalysis,代码行数:22,代码来源:UnusedReasign.cs
示例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;
}
开发者ID:hesam,项目名称:SketchSharp,代码行数:93,代码来源:Checker.cs
示例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))
//.........这里部分代码省略.........
开发者ID:dbremner,项目名称:specsharp,代码行数:101,代码来源:Resolver.cs
示例14: Walk
// AssignmentStatement
public override bool Walk(AssignmentStatement node) { return false; }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:2,代码来源:PythonWalker.Generated.cs
示例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;
}
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:9,代码来源:StackDepthAnalysis.cs
示例16: VisitAssignmentStatement
public override Statement VisitAssignmentStatement(AssignmentStatement assignment){
assignment = (AssignmentStatement)base.VisitAssignmentStatement(assignment);
if (assignment == null) return null;
Expression target = assignment.Target;
Expression source = assignment.Source;
TypeNode tType = target == null ? null : target.Type;
TypeNode sType = source == null ? null : source.Type;
if (tType != null && sType != null){
//^ assert target != null;
if (tType.IsValueType){
if (sType is Reference)
assignment.Source = new AddressDereference(source, tType);
else if (!sType.IsValueType && !(sType == CoreSystemTypes.Object && source is Literal && target.NodeType == NodeType.AddressDereference))
assignment.Source = new AddressDereference(new BinaryExpression(source, new MemberBinding(null, sType), NodeType.Unbox), sType);
}else{
if (sType.IsValueType){
if (!(tType is Reference))
assignment.Source = new BinaryExpression(source, new MemberBinding(null, sType), NodeType.Box, tType);
}
}
}
return assignment;
}
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:23,代码来源:Specializer.cs
示例17: VisitAssignmentStatement
public virtual void VisitAssignmentStatement (AssignmentStatement node)
{
if (node == null)
return;
VisitTargetExpression (node.Target);
VisitExpression (node.Source);
}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:NodeInspector.cs
示例18: VisitAssignmentStatement
public virtual Statement VisitAssignmentStatement (AssignmentStatement node)
{
if (node == null)
return node;
node.Target = VisitTargetExpression (node.Target);
node.Source = VisitExpression (node.Source);
return node;
}
开发者ID:carrie901,项目名称:mono,代码行数:9,代码来源:DefaultNodeVisitor.cs
示例19: VisitAssignmentStatement
protected internal override void VisitAssignmentStatement(AssignmentStatement statement)
{
_stm = Ssm.Stm.NewAsgnStm(((Ssm.Expr.VarExpr)GetTransformed(statement.AssignmentTarget)).Item, GetTransformed(statement.Expression));
}
开发者ID:cubeme,项目名称:safety-sharp,代码行数:4,代码来源:ModelTransformation.cs
示例20: PopExprTransformer
/// <summary>
/// Remove the Pop from a CciHelper statement "sequence" of the form "Pop expr".
/// </summary>
protected override Statement PopExprTransformer(ExpressionStatement expr_stat, int depth)
{
Expression real_expr = ((UnaryExpression) expr_stat.Expression).Operand;
Statement new_stat;
new_stat = new AssignmentStatement(get_stack_var(depth, expr_stat.Expression), real_expr);
real_expr.SourceContext = expr_stat.SourceContext;
new_stat.SourceContext = expr_stat.SourceContext;
return new_stat;
}
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:12,代码来源:StackDepthAnalysis.cs
注:本文中的AssignmentStatement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论