本文整理汇总了C#中Mono.CSharp.New类的典型用法代码示例。如果您正苦于以下问题:C# New类的具体用法?C# New怎么用?C# New使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
New类属于Mono.CSharp命名空间,在下文中一共展示了New类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EmitStoreyInstantiation
//
// Initializes all hoisted variables
//
public void EmitStoreyInstantiation (EmitContext ec, ExplicitBlock block)
{
// There can be only one instance variable for each storey type
if (Instance != null)
throw new InternalErrorException ();
//
// Create an instance of this storey
//
ResolveContext rc = new ResolveContext (ec.MemberContext);
rc.CurrentBlock = block;
var storey_type_expr = CreateStoreyTypeExpression (ec);
var source = new New (storey_type_expr, null, Location).Resolve (rc);
//
// When the current context is async (or iterator) lift local storey
// instantiation to the currect storey
//
if (ec.CurrentAnonymousMethod is StateMachineInitializer && (block.HasYield || block.HasAwait)) {
//
// Unfortunately, normal capture mechanism could not be used because we are
// too late in the pipeline and standart assign cannot be used either due to
// recursive nature of GetStoreyInstanceExpression
//
var field = ec.CurrentAnonymousMethod.Storey.AddCompilerGeneratedField (
LocalVariable.GetCompilerGeneratedName (block), storey_type_expr, true);
field.Define ();
field.Emit ();
var fexpr = new FieldExpr (field, Location);
fexpr.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, Location);
fexpr.EmitAssign (ec, source, false, false);
Instance = fexpr;
} else {
var local = TemporaryVariableReference.Create (source.Type, block, Location);
if (source.Type.IsStruct) {
local.LocalInfo.CreateBuilder (ec);
} else {
local.EmitAssign (ec, source);
}
Instance = local;
}
EmitHoistedFieldsInitialization (rc, ec);
// TODO: Implement properly
//SymbolWriter.DefineScopeVariable (ID, Instance.Builder);
}
开发者ID:rabink,项目名称:mono,代码行数:54,代码来源:anonymous.cs
示例2: Visit
public override object Visit(New newExpression)
{
var result = new ObjectCreateExpression();
var location = LocationsBag.GetLocations(newExpression);
result.AddChild(new CSharpTokenNode(Convert(newExpression.Location), ObjectCreateExpression.NewKeywordRole), ObjectCreateExpression.NewKeywordRole);
if (newExpression.TypeRequested != null)
result.AddChild(ConvertToType(newExpression.TypeRequested), Roles.Type);
if (location != null)
result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
AddArguments(result, newExpression.Arguments);
if (location != null && location.Count > 1)
result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar);
return result;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:17,代码来源:CSharpParser.cs
示例3: Visit
public override object Visit (New newExpression)
{
var result = new ObjectCreateExpression ();
var location = LocationsBag.GetLocations (newExpression);
result.AddChild (new CSharpTokenNode (Convert (newExpression.Location), "new".Length), ObjectCreateExpression.Roles.Keyword);
if (newExpression.NewType != null)
result.AddChild ((INode)newExpression.NewType.Accept (this), ObjectCreateExpression.Roles.ReturnType);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ObjectCreateExpression.Roles.LPar);
AddArguments (result, location, newExpression.NewArguments);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ObjectCreateExpression.Roles.RPar);
// TODO: Collection initializer ?
return result;
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:20,代码来源:CSharpParser.cs
示例4: case_495
void case_495()
#line 3609 "cs-parser.jay"
{
if (yyVals[0+yyTop] != null) {
if (lang_version <= LanguageVersion.ISO_2)
FeatureIsNotAvailable (GetLocation (yyVals[-5+yyTop]), "object initializers");
yyVal = new NewInitialize ((FullNamedExpression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop]));
} else {
yyVal = new New ((FullNamedExpression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], GetLocation (yyVals[-5+yyTop]));
}
lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:14,代码来源:cs-parser.cs
示例5: case_501
void case_501()
#line 3661 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
/* It can be any of new expression, create the most common one*/
yyVal = new New ((FullNamedExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:7,代码来源:cs-parser.cs
示例6: Visit
public virtual object Visit (New newExpression)
{
return null;
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:visit.cs
示例7: EmitStoreyInstantiation
//
// Initializes all hoisted variables
//
public void EmitStoreyInstantiation (EmitContext ec)
{
// There can be only one instance variable for each storey type
if (Instance != null)
throw new InternalErrorException ();
SymbolWriter.OpenCompilerGeneratedBlock (ec);
//
// Create an instance of a storey
//
var storey_type_expr = CreateStoreyTypeExpression (ec);
ResolveContext rc = new ResolveContext (ec.MemberContext);
Expression e = new New (storey_type_expr, null, Location).Resolve (rc);
e.Emit (ec);
Instance = new LocalTemporary (storey_type_expr.Type);
Instance.Store (ec);
EmitHoistedFieldsInitialization (ec);
SymbolWriter.DefineScopeVariable (ID, Instance.Builder);
SymbolWriter.CloseCompilerGeneratedBlock (ec);
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:28,代码来源:anonymous.cs
示例8: EmitStoreyInstantiation
//
// Initializes all hoisted variables
//
public void EmitStoreyInstantiation (EmitContext ec)
{
// There can be only one instance variable for each storey type
if (Instance != null)
throw new InternalErrorException ();
SymbolWriter.OpenCompilerGeneratedBlock (ec.ig);
//
// Create an instance of storey type
//
Expression storey_type_expr;
if (is_generic) {
//
// Use current method type parameter (MVAR) for top level storey only. All
// nested storeys use class type parameter (VAR)
//
TypeParameter[] tparams = ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.Storey != null ?
ec.CurrentAnonymousMethod.Storey.TypeParameters :
ec.CurrentTypeParameters;
TypeArguments targs = new TypeArguments ();
if (tparams.Length < CountTypeParameters) {
TypeParameter[] parent_tparams = ec.MemberContext.CurrentTypeDefinition.TypeParameters;
for (int i = 0; i < parent_tparams.Length; ++i)
targs.Add (new TypeParameterExpr (parent_tparams[i], Location));
}
for (int i = 0; i < tparams.Length; ++i)
targs.Add (new TypeParameterExpr (tparams[i], Location));
storey_type_expr = new GenericTypeExpr (TypeBuilder, targs, Location);
} else {
storey_type_expr = new TypeExpression (TypeBuilder, Location);
}
ResolveContext rc = new ResolveContext (this);
Expression e = new New (storey_type_expr, null, Location).Resolve (rc);
e.Emit (ec);
Instance = new LocalTemporary (storey_type_expr.Type);
Instance.Store (ec);
EmitHoistedFieldsInitialization (ec);
SymbolWriter.DefineScopeVariable (ID, Instance.Builder);
SymbolWriter.CloseCompilerGeneratedBlock (ec.ig);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:52,代码来源:anonymous.cs
示例9: yyparse
//.........这里部分代码省略.........
break;
case 484:
#line 3383 "cs-parser.jay"
{
yyVal = new BaseIndexerAccess ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
}
break;
case 485:
#line 3387 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
yyVal = new BaseAccess (null, GetLocation (yyVals[0+yyTop]));
}
break;
case 486:
#line 3395 "cs-parser.jay"
{
yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop]));
}
break;
case 487:
#line 3402 "cs-parser.jay"
{
yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop]));
}
break;
case 488:
#line 3409 "cs-parser.jay"
{
if (yyVals[0+yyTop] != null) {
if (RootContext.Version <= LanguageVersion.ISO_2)
Report.FeatureIsNotAvailable (GetLocation (yyVals[-4+yyTop]), "object initializers");
yyVal = new NewInitialize ((Expression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
}
else
yyVal = new New ((Expression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], GetLocation (yyVals[-4+yyTop]));
}
break;
case 489:
#line 3420 "cs-parser.jay"
{
if (RootContext.Version <= LanguageVersion.ISO_2)
Report.FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "collection initializers");
yyVal = new NewInitialize ((Expression) yyVals[-1+yyTop], null, (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
}
break;
case 490:
#line 3432 "cs-parser.jay"
{
yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], (List<Expression>) yyVals[-3+yyTop], (string) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop]));
}
break;
case 491:
#line 3436 "cs-parser.jay"
{
if (yyVals[0+yyTop] == null)
Report.Error (1586, GetLocation (yyVals[-2+yyTop]), "Array creation must have array size or array initializer");
yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-2+yyTop], (string) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));
}
break;
case 492:
#line 3443 "cs-parser.jay"
{
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs
示例10: EmitNew
public void EmitNew (EmitContext ec, New source, bool leave_copy)
{
if (!source.Emit (ec, this)) {
if (leave_copy)
throw new NotImplementedException ();
return;
}
throw new NotImplementedException ();
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:11,代码来源:expression.cs
示例11: CheckComImport
//
// Checks whether the type is an interface that has the
// [ComImport, CoClass] attributes and must be treated
// specially
//
public Expression CheckComImport (ResolveContext ec)
{
if (!type.IsInterface)
return null;
//
// Turn the call into:
// (the-interface-stated) (new class-referenced-in-coclassattribute ())
//
Type real_class = AttributeTester.GetCoClassAttribute (type);
if (real_class == null)
return null;
New proxy = new New (new TypeExpression (real_class, loc), Arguments, loc);
Cast cast = new Cast (new TypeExpression (type, loc), proxy, loc);
return cast.Resolve (ec);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:22,代码来源:expression.cs
示例12: case_493
void case_493()
{
Error_SyntaxError (yyToken);
/* It can be any of new expression, create the most common one*/
yyVal = new New ((FullNamedExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop]));
}
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:6,代码来源:cs-parser.cs
示例13: yyparse
//.........这里部分代码省略.........
case 505:
#line 3739 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new ElementAccess (new BaseThis (GetLocation (yyVals[-3+yyTop])), (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
}
break;
case 506:
#line 3744 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
Error_SyntaxError (yyToken);
yyVal = new ElementAccess (null, null, GetLocation (yyVals[-1+yyTop]));
}
break;
case 507:
#line 3752 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop]));
}
break;
case 508:
#line 3759 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop]));
}
break;
case 509:
#line 3766 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
if (yyVals[0+yyTop] != null) {
if (lang_version <= LanguageVersion.ISO_2)
FeatureIsNotAvailable (GetLocation (yyVals[-5+yyTop]), "object initializers");
yyVal = new NewInitialize ((FullNamedExpression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop]));
} else {
yyVal = new New ((FullNamedExpression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], GetLocation (yyVals[-5+yyTop]));
}
lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
}
break;
case 510:
#line 3779 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
if (lang_version <= LanguageVersion.ISO_2)
FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "collection initializers");
yyVal = new NewInitialize ((FullNamedExpression) yyVals[-1+yyTop], null, (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));
}
break;
case 511:
#line 3791 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], (List<Expression>) yyVals[-3+yyTop],
new ComposedTypeSpecifier (((List<Expression>) yyVals[-3+yyTop]).Count, GetLocation (yyVals[-4+yyTop])) {
Next = (ComposedTypeSpecifier) yyVals[-1+yyTop]
}, (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]));
}
break;
case 512:
#line 3799 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
if (yyVals[0+yyTop] == null)
report.Error (1586, GetLocation (yyVals[-3+yyTop]), "Array creation must have array size or array initializer");
开发者ID:runefs,项目名称:Marvin,代码行数:66,代码来源:cs-parser.cs
示例14: case_493
void case_493()
#line 3383 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
if (yyVals[0+yyTop] != null) {
if (lang_version <= LanguageVersion.ISO_2)
FeatureIsNotAvailable (GetLocation (yyVals[-5+yyTop]), "object initializers");
yyVal = new NewInitialize ((FullNamedExpression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop]));
} else {
yyVal = new New ((FullNamedExpression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], GetLocation (yyVals[-5+yyTop]));
}
lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
}
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:14,代码来源:cs-parser.cs
注:本文中的Mono.CSharp.New类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论