本文整理汇总了C#中Mono.CSharp.NewInitialize类的典型用法代码示例。如果您正苦于以下问题:C# NewInitialize类的具体用法?C# NewInitialize怎么用?C# NewInitialize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NewInitialize类属于Mono.CSharp命名空间,在下文中一共展示了NewInitialize类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Visit
public override object Visit (NewInitialize newInitializeExpression)
{
var result = new ObjectCreateExpression ();
result.AddChild (new CSharpTokenNode (Convert (newInitializeExpression.Location), "new".Length), ObjectCreateExpression.Roles.Keyword);
if (newInitializeExpression.NewType != null)
result.AddChild ((INode)newInitializeExpression.NewType.Accept (this), ObjectCreateExpression.Roles.ReturnType);
var location = LocationsBag.GetLocations (newInitializeExpression);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ObjectCreateExpression.Roles.LPar);
AddArguments (result, location, newInitializeExpression.NewArguments);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ObjectCreateExpression.Roles.RPar);
return result;
}
示例2: case_496
void case_496()
#line 3622 "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]));
}
示例3: Visit
public override object Visit(NewInitialize newInitializeExpression)
{
var result = new ObjectCreateExpression();
result.AddChild(new CSharpTokenNode(Convert(newInitializeExpression.Location), ObjectCreateExpression.NewKeywordRole), ObjectCreateExpression.NewKeywordRole);
if (newInitializeExpression.TypeRequested != null)
result.AddChild(ConvertToType(newInitializeExpression.TypeRequested), Roles.Type);
var location = LocationsBag.GetLocations(newInitializeExpression);
if (location != null)
result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
AddArguments(result, newInitializeExpression.Arguments);
if (location != null && location.Count > 1)
result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar);
var init = ConvertCollectionOrObjectInitializers(newInitializeExpression.Initializers);
if (init != null)
result.AddChild(init, ObjectCreateExpression.InitializerRole);
return result;
}
示例4: Visit
public virtual object Visit (NewInitialize newInitializeExpression)
{
return null;
}
示例5: 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]));
}
示例6: 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"
{
示例7: ResolveStringSwitchMap
void ResolveStringSwitchMap (ResolveContext ec)
{
FullNamedExpression string_dictionary_type;
if (TypeManager.generic_ienumerable_type != null) {
MemberAccess system_collections_generic = new MemberAccess (new MemberAccess (
new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc), "Generic", loc);
string_dictionary_type = new MemberAccess (system_collections_generic, "Dictionary",
new TypeArguments (
new TypeExpression (TypeManager.string_type, loc),
new TypeExpression (TypeManager.int32_type, loc)), loc);
} else {
MemberAccess system_collections_generic = new MemberAccess (
new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc);
string_dictionary_type = new MemberAccess (system_collections_generic, "Hashtable", loc);
}
var ctype = ec.CurrentMemberDefinition.Parent.PartialContainer;
Field field = new Field (ctype, string_dictionary_type,
Modifiers.STATIC | Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED,
new MemberName (CompilerGeneratedClass.MakeName (null, "f", "switch$map", unique_counter++), loc), null);
if (!field.Define ())
return;
ctype.AddField (field);
var init = new List<Expression> ();
int counter = 0;
Elements.Clear ();
string value = null;
foreach (SwitchSection section in Sections) {
int last_count = init.Count;
foreach (SwitchLabel sl in section.Labels) {
if (sl.Label == null || sl.Converted == SwitchLabel.NullStringCase)
continue;
value = (string) sl.Converted;
var init_args = new List<Expression> (2);
init_args.Add (new StringLiteral (value, sl.Location));
init_args.Add (new IntConstant (counter, loc));
init.Add (new CollectionElementInitializer (init_args, loc));
}
//
// Don't add empty sections
//
if (last_count == init.Count)
continue;
Elements.Add (counter, section.Labels [0]);
++counter;
}
Arguments args = new Arguments (1);
args.Add (new Argument (new IntConstant (init.Count, loc)));
Expression initializer = new NewInitialize (string_dictionary_type, args,
new CollectionOrObjectInitializers (init, loc), loc);
switch_cache_field = new FieldExpr (field, loc);
string_dictionary = new SimpleAssign (switch_cache_field, initializer.Resolve (ec));
}
示例8: InitializerTargetExpression
public InitializerTargetExpression (NewInitialize newInstance)
{
this.type = newInstance.type;
this.loc = newInstance.loc;
this.eclass = newInstance.eclass;
this.new_instance = newInstance;
}
示例9: ResolveStringSwitchMap
void ResolveStringSwitchMap (EmitContext ec)
{
FullNamedExpression string_dictionary_type;
#if GMCS_SOURCE
MemberAccess system_collections_generic = new MemberAccess (new MemberAccess (
new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc), "Generic", loc);
string_dictionary_type = new MemberAccess (system_collections_generic, "Dictionary",
new TypeArguments (
new TypeExpression (TypeManager.string_type, loc),
new TypeExpression (TypeManager.int32_type, loc)), loc);
#else
MemberAccess system_collections_generic = new MemberAccess (
new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc);
string_dictionary_type = new MemberAccess (system_collections_generic, "Hashtable", loc);
#endif
Field field = new Field (ec.TypeContainer, string_dictionary_type,
Modifiers.STATIC | Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED,
new MemberName (CompilerGeneratedClass.MakeName (null, "f", "switch$map", unique_counter++), loc), null);
if (!field.Define ())
return;
ec.TypeContainer.PartialContainer.AddField (field);
ArrayList init = new ArrayList ();
int counter = 0;
Elements.Clear ();
string value = null;
foreach (SwitchSection section in Sections) {
foreach (SwitchLabel sl in section.Labels) {
if (sl.Label == null || sl.Converted == SwitchLabel.NullStringCase) {
value = null;
continue;
}
value = (string) sl.Converted;
ArrayList init_args = new ArrayList (2);
init_args.Add (new StringLiteral (value, sl.Location));
init_args.Add (new IntConstant (counter, loc));
init.Add (new CollectionElementInitializer (init_args, loc));
}
if (value == null)
continue;
Elements.Add (counter, section.Labels [0]);
++counter;
}
ArrayList args = new ArrayList (1);
args.Add (new Argument (new IntConstant (Sections.Count, loc)));
Expression initializer = new NewInitialize (string_dictionary_type, args,
new CollectionOrObjectInitializers (init, loc), loc);
switch_cache_field = new FieldExpr (field.FieldBuilder, loc);
string_dictionary = new SimpleAssign (switch_cache_field, initializer.Resolve (ec));
}
示例10: 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");
示例11: case_494
void case_494()
#line 3396 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\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]));
}
示例12: 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]));
}