本文整理汇总了C#中Mono.CSharp.SimpleAssign类的典型用法代码示例。如果您正苦于以下问题:C# SimpleAssign类的具体用法?C# SimpleAssign怎么用?C# SimpleAssign使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleAssign类属于Mono.CSharp命名空间,在下文中一共展示了SimpleAssign类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FallbackSetMember
public override DynamicMetaObject FallbackSetMember (DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
{
var ctx = DynamicContext.Create ();
var source = ctx.CreateCompilerExpression (argumentInfo [1], value);
var expr = ctx.CreateCompilerExpression (argumentInfo [0], target);
// Field assignment
expr = new Compiler.MemberAccess (expr, Name);
// Compound assignment under dynamic context does not convert result
// expression but when setting member type we need to do explicit
// conversion to ensure type match between member type and dynamic
// expression type
if ((flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0) {
expr = new Compiler.RuntimeExplicitAssign (expr, source);
} else {
expr = new Compiler.SimpleAssign (expr, source);
}
expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
binder.AddRestrictions (value);
return binder.Bind (ctx, callingContext);
}
开发者ID:jdecuyper,项目名称:mono,代码行数:27,代码来源:CSharpSetMemberBinder.cs
示例2: FallbackSetIndex
public override DynamicMetaObject FallbackSetIndex (DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
{
if (argumentInfo.Count != indexes.Length + 2) {
if (errorSuggestion == null)
throw new NotImplementedException ();
return errorSuggestion;
}
var ctx = DynamicContext.Create ();
var expr = ctx.CreateCompilerExpression (argumentInfo [0], target);
var args = ctx.CreateCompilerArguments (argumentInfo.Skip (1), indexes);
expr = new Compiler.ElementAccess (expr, args, Compiler.Location.Null);
var source = ctx.CreateCompilerExpression (argumentInfo [indexes.Length + 1], value);
// Same conversion as in SetMemberBinder
if ((flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0) {
expr = new Compiler.RuntimeExplicitAssign (expr, source);
} else {
expr = new Compiler.SimpleAssign (expr, source);
}
expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
if ((flags & CSharpBinderFlags.CheckedContext) != 0)
expr = new Compiler.CheckedExpr (expr, Compiler.Location.Null);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
binder.AddRestrictions (value);
binder.AddRestrictions (indexes);
return binder.Bind (ctx, callingContext);
}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:34,代码来源:CSharpSetIndexBinder.cs
示例3: FallbackSetMember
public override DynamicMetaObject FallbackSetMember (DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
{
var source = CSharpBinder.CreateCompilerExpression (argumentInfo [1], value);
var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
// Field assignment
expr = new Compiler.MemberAccess (expr, Name);
expr = new Compiler.SimpleAssign (expr, source);
expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
binder.AddRestrictions (value);
return binder.Bind (callingContext, target);
}
开发者ID:afaerber,项目名称:mono,代码行数:16,代码来源:CSharpSetMemberBinder.cs
示例4: FallbackSetIndex
public override DynamicMetaObject FallbackSetIndex (DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
{
if (argumentInfo.Count != indexes.Length + 2) {
if (errorSuggestion == null)
throw new NotImplementedException ();
return errorSuggestion;
}
var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
var args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), indexes);
expr = new Compiler.ElementAccess (expr, args, Compiler.Location.Null);
var source = CSharpBinder.CreateCompilerExpression (argumentInfo [indexes.Length + 1], value);
expr = new Compiler.SimpleAssign (expr, source);
expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
binder.AddRestrictions (value);
binder.AddRestrictions (indexes);
return binder.Bind (callingContext, target);
}
开发者ID:afaerber,项目名称:mono,代码行数:24,代码来源:CSharpSetIndexBinder.cs
示例5: EmitHoistedFieldsInitialization
void EmitHoistedFieldsInitialization (ResolveContext rc, EmitContext ec)
{
//
// Initialize all storey reference fields by using local or hoisted variables
//
if (used_parent_storeys != null) {
foreach (StoreyFieldPair sf in used_parent_storeys) {
//
// Get instance expression of storey field
//
Expression instace_expr = GetStoreyInstanceExpression (ec);
var fs = sf.Field.Spec;
if (TypeManager.IsGenericType (instace_expr.Type))
fs = MemberCache.GetMember (instace_expr.Type, fs);
FieldExpr f_set_expr = new FieldExpr (fs, Location);
f_set_expr.InstanceExpression = instace_expr;
SimpleAssign a = new SimpleAssign (f_set_expr, sf.Storey.GetStoreyInstanceExpression (ec));
if (a.Resolve (rc) != null)
a.EmitStatement (ec);
}
}
//
// Define hoisted `this' in top-level storey only
//
if (OriginalSourceBlock.Explicit.HasCapturedThis && !(Parent is AnonymousMethodStorey)) {
AddCapturedThisField (ec);
rc.CurrentBlock.AddScopeStatement (new ThisInitializer (hoisted_this));
}
//
// Setting currect anonymous method to null blocks any further variable hoisting
//
AnonymousExpression ae = ec.CurrentAnonymousMethod;
ec.CurrentAnonymousMethod = null;
if (hoisted_params != null) {
EmitHoistedParameters (ec, hoisted_params);
}
ec.CurrentAnonymousMethod = ae;
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:44,代码来源:anonymous.cs
示例6: Visit
public virtual object Visit (SimpleAssign simpleAssign)
{
return null;
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:visit.cs
示例7: ResolveInitializer
protected override Expression ResolveInitializer (BlockContext bc, LocalVariable li, Expression initializer)
{
Assign assign;
if (li.Type == InternalType.Dynamic) {
initializer = initializer.Resolve (bc);
if (initializer == null)
return null;
initializer = Convert.ImplicitConversionRequired (bc, initializer, TypeManager.idisposable_type, loc);
if (initializer == null)
return null;
var var = LocalVariable.CreateCompilerGenerated (TypeManager.idisposable_type, bc.CurrentBlock, loc);
assign = new SimpleAssign (var.CreateReferenceExpression (bc, loc), initializer, loc);
assign.ResolveStatement (bc);
dispose_call = CreateDisposeCall (bc, var);
dispose_call.Resolve (bc);
return assign;
}
if (li == Variable) {
CheckIDiposableConversion (bc, li, initializer);
dispose_call = CreateDisposeCall (bc, li);
dispose_call.Resolve (bc);
}
return base.ResolveInitializer (bc, li, initializer);
}
开发者ID:alisci01,项目名称:mono,代码行数:30,代码来源:statement.cs
示例8: EmitHoistingAssignment
public void EmitHoistingAssignment (EmitContext ec)
{
SimpleAssign a = new SimpleAssign (GetFieldExpression (ec), this_reference);
if (a.Resolve (ec) != null)
a.EmitStatement (ec);
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:6,代码来源:anonymous.cs
示例9: Visit
public override object Visit (SimpleAssign simpleAssign)
{
var result = new AssignmentExpression ();
result.AssignmentOperatorType = AssignmentOperatorType.Assign;
if (simpleAssign.Target != null)
result.AddChild ((INode)simpleAssign.Target.Accept (this), AssignmentExpression.LeftExpressionRole);
result.AddChild (new CSharpTokenNode (Convert (simpleAssign.Location), 1), AssignmentExpression.OperatorRole);
if (simpleAssign.Source != null) {
result.AddChild ((INode)simpleAssign.Source.Accept (this), AssignmentExpression.RightExpressionRole);
}
return result;
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:14,代码来源:CSharpParser.cs
示例10: Visit
public override object Visit(SimpleAssign simpleAssign)
{
var result = new AssignmentExpression();
result.Operator = AssignmentOperatorType.Assign;
if (simpleAssign.Target != null)
result.AddChild((Expression)simpleAssign.Target.Accept(this), AssignmentExpression.LeftRole);
var location = LocationsBag.GetLocations(simpleAssign);
if (location != null)
result.AddChild(new CSharpTokenNode(Convert(location [0]), AssignmentExpression.AssignRole), AssignmentExpression.AssignRole);
if (simpleAssign.Source != null) {
result.AddChild((Expression)simpleAssign.Source.Accept(this), AssignmentExpression.RightRole);
}
return result;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:15,代码来源:CSharpParser.cs
示例11: case_636
void case_636()
#line 4486 "cs-parser.jay"
{
yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:6,代码来源:cs-parser.cs
示例12: ResolveVariable
bool ResolveVariable (EmitContext ec)
{
ExpressionStatement a = new SimpleAssign (var, init, loc);
a = a.ResolveStatement (ec);
if (a == null)
return false;
assign = a;
if (TypeManager.ImplementsInterface (a.Type, TypeManager.idisposable_type)) {
converted_var = var;
return true;
}
Expression e = Convert.ImplicitConversionStandard (ec, a, TypeManager.idisposable_type, var.Location);
if (e == null) {
Error_IsNotConvertibleToIDisposable (var);
return false;
}
converted_var = e;
return true;
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:24,代码来源:statement.cs
示例13: case_593
void case_593()
{
yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:5,代码来源:cs-parser.cs
示例14: yyparse
//.........这里部分代码省略.........
}
break;
case 612:
#line 4352 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
if (lang_version < LanguageVersion.ISO_2)
FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "null coalescing operator");
yyVal = new Nullable.NullCoalescingOperator ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
}
break;
case 614:
#line 4363 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new Conditional (new BooleanExpression ((Expression) yyVals[-4+yyTop]), (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
break;
case 615:
#line 4371 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
var potentialRolePlayer = yyVals[0+yyTop] as Expression;
var memberExpression = yyVals[-2+yyTop] as MemberAccess;
var simpleNameForRole = memberExpression != null ? memberExpression.LeftExpression as SimpleName : yyVals[-2+yyTop] as SimpleName;
if(simpleNameForRole != null){
var role = FindField(simpleNameForRole.Name, GetLocation(yyVals[-2+yyTop]));
var isRole = role != null && role.IsRole;
if(current_method as Constructor != null){
/*might be assigning to a role*/
yyVal = new RoleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
} else if(isRole) {
report.Error (10000, GetLocation(potentialRolePlayer), "Roles can only be assigned to players in constructor");
} else{
yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
}
} else {
yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
}
}
break;
case 616:
#line 4391 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new CompoundAssign (
Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
}
break;
case 617:
#line 4396 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new CompoundAssign (
Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
}
break;
case 618:
#line 4401 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new CompoundAssign (
Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
}
break;
case 619:
#line 4406 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new CompoundAssign (
Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
开发者ID:runefs,项目名称:Marvin,代码行数:67,代码来源:cs-parser.cs
示例15: EmitHoistingAssignment
public void EmitHoistingAssignment (EmitContext ec)
{
SimpleAssign a = new SimpleAssign (GetFieldExpression (ec), new CompilerGeneratedThis (ec.CurrentType, field.Location));
if (a.Resolve (new ResolveContext (ec.MemberContext)) != null)
a.EmitStatement (ec);
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:6,代码来源:anonymous.cs
示例16: yyparse
//.........这里部分代码省略.........
break;
case 590:
#line 3980 "cs-parser.jay"
{
yyVal = new Binary (Binary.Operator.LogicalAnd,
(Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
}
break;
case 592:
#line 3989 "cs-parser.jay"
{
yyVal = new Binary (Binary.Operator.LogicalOr,
(Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
}
break;
case 594:
#line 3998 "cs-parser.jay"
{
if (RootContext.Version < LanguageVersion.ISO_2)
Report.FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "null coalescing operator");
yyVal = new Nullable.NullCoalescingOperator ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
}
break;
case 596:
#line 4009 "cs-parser.jay"
{
yyVal = new Conditional (new BooleanExpression ((Expression) yyVals[-4+yyTop]), (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 597:
#line 4016 "cs-parser.jay"
{
yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 598:
#line 4020 "cs-parser.jay"
{
yyVal = new CompoundAssign (
Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 599:
#line 4025 "cs-parser.jay"
{
yyVal = new CompoundAssign (
Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 600:
#line 4030 "cs-parser.jay"
{
yyVal = new CompoundAssign (
Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 601:
#line 4035 "cs-parser.jay"
{
yyVal = new CompoundAssign (
Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
}
break;
case 602:
#line 4040 "cs-parser.jay"
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs
示例17: CreateAutomaticProperty
void CreateAutomaticProperty ()
{
// Create backing field
Field field = new BackingField (this);
if (!field.Define ())
return;
Parent.PartialContainer.AddField (field);
FieldExpr fe = new FieldExpr (field, Location);
if ((field.ModFlags & Modifiers.STATIC) == 0)
fe.InstanceExpression = new CompilerGeneratedThis (fe.Type, Location);
// Create get block
Get.Block = new ToplevelBlock (Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location);
Return r = new Return (fe, Location);
Get.Block.AddStatement (r);
// Create set block
Set.Block = new ToplevelBlock (Compiler, Set.ParameterInfo, Location);
Assign a = new SimpleAssign (fe, new SimpleName ("value", Location));
Set.Block.AddStatement (new StatementExpression (a));
}
开发者ID:afaerber,项目名称:mono,代码行数:23,代码来源:property.cs
示例18: yyparse
//.........这里部分代码省略.........
case 581:
case_581();
break;
case 583:
case_583();
break;
case 584:
case_584();
break;
case 586:
case_586();
break;
case 588:
case_588();
break;
case 590:
case_590();
break;
case 592:
case_592();
break;
case 594:
case_594();
break;
case 596:
case_596();
break;
case 598:
case_598();
break;
case 599:
#line 4008 "cs-parser.jay"
{
yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
}
break;
case 600:
case_600();
break;
case 601:
case_601();
break;
case 602:
case_602();
break;
case 603:
case_603();
break;
case 604:
case_604();
break;
case 605:
case_605();
break;
case 606:
case_606();
break;
case 607:
case_607();
break;
case 608:
case_608();
break;
case 609:
case_609();
break;
开发者ID:Ein,项目名称:monodevelop,代码行数:67,代码来源:cs-parser.cs
示例19: CreateSetterArguments
protected override Arguments CreateSetterArguments (ResolveContext rc, Expression rhs)
{
//
// Indexer has arguments which complicates things as the setter and getter
// are called in two steps when unary mutator is used. We have to make a
// copy of all variable arguments to not duplicate any side effect.
//
// ++d[++arg, Foo ()]
//
if (!can_be_mutator)
return base.CreateSetterArguments (rc, rhs);
var setter_args = new Arguments (Arguments.Count + 1);
for (int i = 0; i < Arguments.Count; ++i) {
var expr = Arguments[i].Expr;
if (expr is Constant || expr is VariableReference || expr is This) {
setter_args.Add (Arguments [i]);
continue;
}
LocalVariable temp = LocalVariable.CreateCompilerGenerated (expr.Type, rc.CurrentBlock, loc);
expr = new SimpleAssign (temp.CreateReferenceExpression (rc, expr.Location), expr).Resolve (rc);
Arguments[i].Expr = temp.CreateReferenceExpression (rc, expr.Location).Resolve (rc);
setter_args.Add (Arguments [i].Clone (expr));
}
setter_args.Add (new Argument (rhs));
return setter_args;
}
开发者ID:caomw,项目名称:mono,代码行数:31,代码来源:dynamic.cs
示例20: CreateAutomaticProperty
void CreateAutomaticProperty ()
{
// Create backing field
backing_field = new BackingField (this, Initializer != null && Set == null);
if (!backing_field.Define ())
return;
if (Initializer != null) {
backing_field.Initializer = Initializer;
Parent.RegisterFieldForInitialization (backing_field, new FieldInitializer (backing_field, Initializer, Location));
backing_field.ModFlags |= Modifiers.READONLY;
}
Parent.PartialContainer.Members.Add (backing_field);
FieldExpr fe = new FieldExpr (backing_field, Location);
if ((backing_field.ModFlags & Modifiers.STATIC) == 0)
fe.InstanceExpression = new CompilerGeneratedThis (Parent.CurrentType, Location);
//
// Create get block but we careful with location to
// emit only single sequence point per accessor. This allow
// to set a breakpoint on it even with no user code
//
Get.Block = new ToplevelBlock (Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null);
Return r = new Return (fe, Get.Location);
Get.Block.AddStatement (r);
Get.ModFlags |= Modifiers.COMPILER_GENERATED;
// Create set block
if (Set != null) {
Set.Block = new ToplevelBlock (Compiler, Set.ParameterInfo, Location.Null);
Assign a = new SimpleAssign (fe, new SimpleName ("value", Location.Null), Location.Null);
Set.Block.AddStatement (new StatementExpression (a, Set.Location));
Set.ModFlags |= Modifiers.COMPILER_GENERATED;
}
}
开发者ID:frje,项目名称:SharpLang,代码行数:37,代码来源:property.cs
注:本文中的Mono.CSharp.SimpleAssign类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论