本文整理汇总了C#中BaseReferenceExpression类的典型用法代码示例。如果您正苦于以下问题:C# BaseReferenceExpression类的具体用法?C# BaseReferenceExpression怎么用?C# BaseReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BaseReferenceExpression类属于命名空间,在下文中一共展示了BaseReferenceExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Complete
public override void Complete(CompletionContext context)
{
if (declarationBegin > context.StartOffset) {
base.Complete(context);
return;
}
TypeSystemAstBuilder b = new TypeSystemAstBuilder(contextAtCaret);
b.ShowTypeParameterConstraints = false;
b.GenerateBody = true;
var entityDeclaration = b.ConvertEntity(this.Entity);
entityDeclaration.Modifiers &= ~(Modifiers.Virtual | Modifiers.Abstract);
entityDeclaration.Modifiers |= Modifiers.Override;
if (!this.Entity.IsAbstract) {
// modify body to call the base method
if (this.Entity.SymbolKind == SymbolKind.Method) {
var baseCall = new BaseReferenceExpression().Invoke(this.Entity.Name, ParametersToExpressions(this.Entity));
var body = entityDeclaration.GetChildByRole(Roles.Body);
body.Statements.Clear();
if (((IMethod)this.Entity).ReturnType.IsKnownType(KnownTypeCode.Void))
body.Statements.Add(new ExpressionStatement(baseCall));
else
body.Statements.Add(new ReturnStatement(baseCall));
} else if (this.Entity.SymbolKind == SymbolKind.Indexer || this.Entity.SymbolKind == SymbolKind.Property) {
Expression baseCall;
if (this.Entity.SymbolKind == SymbolKind.Indexer)
baseCall = new BaseReferenceExpression().Indexer(ParametersToExpressions(this.Entity));
else
baseCall = new BaseReferenceExpression().Member(this.Entity.Name);
var getterBody = entityDeclaration.GetChildByRole(PropertyDeclaration.GetterRole).Body;
if (!getterBody.IsNull) {
getterBody.Statements.Clear();
getterBody.Add(new ReturnStatement(baseCall.Clone()));
}
var setterBody = entityDeclaration.GetChildByRole(PropertyDeclaration.SetterRole).Body;
if (!setterBody.IsNull) {
setterBody.Statements.Clear();
setterBody.Add(new AssignmentExpression(baseCall.Clone(), new IdentifierExpression("value")));
}
}
}
var document = context.Editor.Document;
StringWriter w = new StringWriter();
var formattingOptions = FormattingOptionsFactory.CreateSharpDevelop();
var segmentDict = SegmentTrackingOutputFormatter.WriteNode(w, entityDeclaration, formattingOptions, context.Editor.Options);
using (document.OpenUndoGroup()) {
string newText = w.ToString().TrimEnd();
document.Replace(declarationBegin, context.EndOffset - declarationBegin, newText);
var throwStatement = entityDeclaration.Descendants.FirstOrDefault(n => n is ThrowStatement);
if (throwStatement != null) {
var segment = segmentDict[throwStatement];
context.Editor.Select(declarationBegin + segment.Offset, segment.Length);
}
CSharpFormatterHelper.Format(context.Editor, declarationBegin, newText.Length, formattingOptions);
}
}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:60,代码来源:OverrideCompletionData.cs
示例2: VisitObjectCreateExpression
public override object VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data)
{
if (objectCreateExpression.Arguments.Count() == 2) {
Expression obj = objectCreateExpression.Arguments.First();
Expression func = objectCreateExpression.Arguments.Last();
Annotation annotation = func.Annotation<Annotation>();
if (annotation != null) {
IdentifierExpression methodIdent = (IdentifierExpression)((InvocationExpression)func).Arguments.Single();
MethodReference method = methodIdent.Annotation<MethodReference>();
if (method != null) {
if (HandleAnonymousMethod(objectCreateExpression, obj, method))
return null;
// Perform the transformation to "new Action(obj.func)".
obj.Remove();
methodIdent.Remove();
if (!annotation.IsVirtual && obj is ThisReferenceExpression) {
// maybe it's getting the pointer of a base method?
if (method.DeclaringType != context.CurrentType) {
obj = new BaseReferenceExpression();
}
}
if (!annotation.IsVirtual && obj is NullReferenceExpression && !method.HasThis) {
// We're loading a static method.
// However it is possible to load extension methods with an instance, so we compare the number of arguments:
bool isExtensionMethod = false;
TypeReference delegateType = objectCreateExpression.Type.Annotation<TypeReference>();
if (delegateType != null) {
TypeDefinition delegateTypeDef = delegateType.Resolve();
if (delegateTypeDef != null) {
MethodDefinition invokeMethod = delegateTypeDef.Methods.FirstOrDefault(m => m.Name == "Invoke");
if (invokeMethod != null) {
isExtensionMethod = (invokeMethod.Parameters.Count + 1 == method.Parameters.Count);
}
}
}
if (!isExtensionMethod) {
obj = new TypeReferenceExpression { Type = AstBuilder.ConvertType(method.DeclaringType) };
}
}
// now transform the identifier into a member reference
MemberReferenceExpression mre = new MemberReferenceExpression();
mre.Target = obj;
mre.MemberName = methodIdent.Identifier;
methodIdent.TypeArguments.MoveTo(mre.TypeArguments);
mre.AddAnnotation(method);
objectCreateExpression.Arguments.Clear();
objectCreateExpression.Arguments.Add(mre);
return null;
}
}
}
return base.VisitObjectCreateExpression(objectCreateExpression, data);
}
开发者ID:stgwilli,项目名称:ILSpy,代码行数:53,代码来源:DelegateConstruction.cs
示例3: Visit
public override object Visit(BaseReferenceExpression baseReferenceExpression, object data)
{
// Console.WriteLine("Visiting base");
if (resolver.CallingClass == null) {
return null;
}
IClass baseClass = resolver.BaseClass(resolver.CallingClass);
if (baseClass == null) {
// Console.WriteLine("Base Class not found");
return null;
}
// Console.WriteLine("Base Class: " + baseClass.FullyQualifiedName);
return new ReturnType(baseClass.FullyQualifiedName);
}
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:14,代码来源:TypeVisitor.cs
示例4: VisitBaseReferenceExpression
public sealed override object VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) {
BeginVisit(baseReferenceExpression);
object result = TrackedVisitBaseReferenceExpression(baseReferenceExpression, data);
EndVisit(baseReferenceExpression);
return result;
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:6,代码来源:NodeTrackingAstVisitor.cs
示例5: VisitBaseReferenceExpression
public void VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression)
{
StartNode(baseReferenceExpression);
WriteKeyword("base", baseReferenceExpression.Role);
EndNode(baseReferenceExpression);
}
开发者ID:x-strong,项目名称:ILSpy,代码行数:6,代码来源:CSharpOutputVisitor.cs
示例6: VisitBaseReferenceExpression
public virtual void VisitBaseReferenceExpression (BaseReferenceExpression baseReferenceExpression)
{
VisitChildren (baseReferenceExpression);
}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs
示例7: VisitBaseReferenceExpression
public override void VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression)
{
UsesNonStaticMember = true;
base.VisitBaseReferenceExpression(baseReferenceExpression);
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:5,代码来源:StaticVisitor.cs
示例8: TransformCall
static AstNode TransformCall(bool isVirtual, object operand, MethodDefinition methodDef, List<Ast.Expression> args)
{
Cecil.MethodReference cecilMethod = ((MethodReference)operand);
Ast.Expression target;
List<Ast.Expression> methodArgs = new List<Ast.Expression>(args);
if (cecilMethod.HasThis) {
target = methodArgs[0];
methodArgs.RemoveAt(0);
// Unpack any DirectionExpression that is used as target for the call
// (calling methods on value types implicitly passes the first argument by reference)
if (target is DirectionExpression) {
target = ((DirectionExpression)target).Expression;
target.Remove(); // detach from DirectionExpression
}
} else {
target = new TypeReferenceExpression { Type = AstBuilder.ConvertType(cecilMethod.DeclaringType) };
}
if (target is ThisReferenceExpression && !isVirtual) {
// a non-virtual call on "this" might be a "base"-call.
if (cecilMethod.DeclaringType != methodDef.DeclaringType) {
// If we're not calling a method in the current class; we must be calling one in the base class.
target = new BaseReferenceExpression();
}
}
// Resolve the method to figure out whether it is an accessor:
Cecil.MethodDefinition cecilMethodDef = cecilMethod.Resolve();
if (cecilMethodDef != null) {
if (cecilMethodDef.IsGetter && methodArgs.Count == 0) {
foreach (var prop in cecilMethodDef.DeclaringType.Properties) {
if (prop.GetMethod == cecilMethodDef)
return target.Member(prop.Name).WithAnnotation(prop);
}
} else if (cecilMethodDef.IsSetter && methodArgs.Count == 1) {
foreach (var prop in cecilMethodDef.DeclaringType.Properties) {
if (prop.SetMethod == cecilMethodDef)
return new Ast.AssignmentExpression(target.Member(prop.Name).WithAnnotation(prop), methodArgs[0]);
}
} else if (cecilMethodDef.IsAddOn && methodArgs.Count == 1) {
foreach (var ev in cecilMethodDef.DeclaringType.Events) {
if (ev.AddMethod == cecilMethodDef) {
return new Ast.AssignmentExpression {
Left = target.Member(ev.Name).WithAnnotation(ev),
Operator = AssignmentOperatorType.Add,
Right = methodArgs[0]
};
}
}
} else if (cecilMethodDef.IsRemoveOn && methodArgs.Count == 1) {
foreach (var ev in cecilMethodDef.DeclaringType.Events) {
if (ev.RemoveMethod == cecilMethodDef) {
return new Ast.AssignmentExpression {
Left = target.Member(ev.Name).WithAnnotation(ev),
Operator = AssignmentOperatorType.Subtract,
Right = methodArgs[0]
};
}
}
}
}
// Default invocation
return target.Invoke(cecilMethod.Name, ConvertTypeArguments(cecilMethod), methodArgs).WithAnnotation(cecilMethod);
}
开发者ID:petr-k,项目名称:ILSpy,代码行数:64,代码来源:AstMethodBodyBuilder.cs
示例9: PrimaryExpr
//.........这里部分代码省略.........
lexer.NextToken();
#line 1913 "cs.ATG"
val = "System.UInt64";
break;
}
case 120: {
lexer.NextToken();
#line 1914 "cs.ATG"
val = "System.UInt16";
break;
}
case 123: {
lexer.NextToken();
#line 1915 "cs.ATG"
val = "System.Void";
break;
}
}
#line 1917 "cs.ATG"
pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation };
} else if (la.kind == 111) {
lexer.NextToken();
#line 1920 "cs.ATG"
pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation;
} else if (la.kind == 51) {
lexer.NextToken();
#line 1922 "cs.ATG"
pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation;
} else if (la.kind == 89) {
NewExpression(
#line 1925 "cs.ATG"
out pexpr);
} else if (la.kind == 115) {
lexer.NextToken();
Expect(20);
if (
#line 1929 "cs.ATG"
NotVoidPointer()) {
Expect(123);
#line 1929 "cs.ATG"
type = new TypeReference("System.Void", true);
} else if (StartOf(10)) {
TypeWithRestriction(
#line 1930 "cs.ATG"
out type, true, true);
} else SynErr(208);
Expect(21);
#line 1932 "cs.ATG"
pexpr = new TypeOfExpression(type);
} else if (la.kind == 63) {
lexer.NextToken();
Expect(20);
Type(
#line 1934 "cs.ATG"
out type);
Expect(21);
#line 1934 "cs.ATG"
开发者ID:mgagne-atman,项目名称:Projects,代码行数:67,代码来源:Parser.cs
示例10: VisitBaseReferenceExpression
public virtual object VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) {
Debug.Assert((baseReferenceExpression != null));
return null;
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:4,代码来源:AbstractASTVisitor.cs
示例11: VisitBaseReferenceExpression
public void VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression)
{
JsonObject expression = CreateJsonExpression(baseReferenceExpression);
Push(expression);
}
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:5,代码来源:AstCsToJson.cs
示例12: VisitBaseReferenceExpression
public void VisitBaseReferenceExpression(BaseReferenceExpression node)
{
VisitChildren(node);
}
开发者ID:evanw,项目名称:minisharp,代码行数:4,代码来源:Lower.cs
示例13: VisitBaseReferenceExpression
public virtual object VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) {
throw new global::System.NotImplementedException("BaseReferenceExpression");
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:3,代码来源:NotImplementedAstVisitor.cs
示例14: PrimaryExpr
private void PrimaryExpr(out Expression pexpr)
{
TypeReference typeReference = null;
List<TypeReference> types = null;
Expression expression;
bool flag = false;
pexpr = null;
if (this.la.kind == 0x70)
{
base.lexer.NextToken();
pexpr = new PrimitiveExpression(true, "true");
}
else if (this.la.kind == 0x47)
{
base.lexer.NextToken();
pexpr = new PrimitiveExpression(false, "false");
}
else if (this.la.kind == 0x59)
{
base.lexer.NextToken();
pexpr = new PrimitiveExpression(null, "null");
}
else if (this.la.kind == 2)
{
base.lexer.NextToken();
pexpr = new PrimitiveExpression(this.t.literalValue, this.t.val);
}
else if ((this.la.kind == 1) && (this.Peek(1).kind == 10))
{
base.Expect(1);
typeReference = new TypeReference(this.t.val);
base.Expect(10);
pexpr = new TypeReferenceExpression(typeReference);
base.Expect(1);
if (typeReference.Type == "global")
{
typeReference.IsGlobal = true;
typeReference.Type = this.t.val ?? "?";
}
else
{
typeReference.Type = typeReference.Type + "." + (this.t.val ?? "?");
}
}
else if (this.la.kind == 1)
{
base.lexer.NextToken();
pexpr = new IdentifierExpression(this.t.val);
}
else if (this.la.kind == 20)
{
base.lexer.NextToken();
this.Expr(out expression);
base.Expect(0x15);
pexpr = new ParenthesizedExpression(expression);
}
else if (!this.StartOf(0x1a))
{
if (this.la.kind == 110)
{
base.lexer.NextToken();
pexpr = new ThisReferenceExpression();
}
else if (this.la.kind == 50)
{
base.lexer.NextToken();
Expression targetObject = new BaseReferenceExpression();
if (this.la.kind == 15)
{
base.lexer.NextToken();
base.Expect(1);
targetObject = new FieldReferenceExpression(targetObject, this.t.val);
}
else if (this.la.kind == 0x12)
{
base.lexer.NextToken();
this.Expr(out expression);
List<Expression> indices = new List<Expression>();
if (expression != null)
{
indices.Add(expression);
}
while (this.la.kind == 14)
{
base.lexer.NextToken();
this.Expr(out expression);
if (expression != null)
{
indices.Add(expression);
}
}
base.Expect(0x13);
targetObject = new IndexerExpression(targetObject, indices);
}
else
{
base.SynErr(0xb3);
}
pexpr = targetObject;
}
//.........这里部分代码省略.........
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:101,代码来源:Parser.cs
示例15: TrackedVisitBaseReferenceExpression
public virtual object TrackedVisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) {
return base.VisitBaseReferenceExpression(baseReferenceExpression, data);
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:3,代码来源:NodeTrackingAstVisitor.cs
示例16: VisitBaseReferenceExpression
public void VisitBaseReferenceExpression(BaseReferenceExpression expression)
{
Formatter.StartNode(expression);
Formatter.WriteKeyword("base");
Formatter.EndNode();
}
开发者ID:JerreS,项目名称:AbstractCode,代码行数:6,代码来源:CSharpAstWriter.cs
示例17: BaseReferenceBlock
public BaseReferenceBlock(IEmitter emitter, BaseReferenceExpression baseReferenceExpression)
: base(emitter, baseReferenceExpression)
{
this.Emitter = emitter;
this.BaseReferenceExpression = baseReferenceExpression;
}
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:6,代码来源:BaseReferenceBlock.cs
示例18: Complete
public override void Complete(ICSharpCode.AvalonEdit.Editing.TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
{
if (declarationBegin > completionSegment.Offset)
{
base.Complete(textArea, completionSegment, insertionRequestEventArgs);
return;
}
TypeSystemAstBuilder b = new TypeSystemAstBuilder(new CSharpResolver(contextAtCaret));
b.ShowTypeParameterConstraints = false;
b.GenerateBody = true;
var entityDeclaration = b.ConvertEntity(this.Entity);
entityDeclaration.Modifiers &= ~(Modifiers.Virtual | Modifiers.Abstract);
entityDeclaration.Modifiers |= Modifiers.Override;
if (!this.Entity.IsAbstract)
{
// modify body to call the base method
if (this.Entity.EntityType == EntityType.Method)
{
var baseCall = new BaseReferenceExpression().Invoke(this.Entity.Name, ParametersToExpressions(this.Entity));
var body = entityDeclaration.GetChildByRole(Roles.Body);
body.Statements.Clear();
if (((IMethod)this.Entity).ReturnType.IsKnownType(KnownTypeCode.Void))
body.Statements.Add(new ExpressionStatement(baseCall));
else
body.Statements.Add(new ReturnStatement(baseCall));
}
else if (this.Entity.EntityType == EntityType.Indexer || this.Entity.EntityType == EntityType.Property)
{
Expression baseCall;
if (this.Entity.EntityType == EntityType.Indexer)
baseCall = new BaseReferenceExpression().Indexer(ParametersToExpressions(this.Entity));
else
baseCall = new BaseReferenceExpression().Member(this.Entity.Name);
var getterBody = entityDeclaration.GetChildByRole(PropertyDeclaration.GetterRole).Body;
if (!getterBody.IsNull)
{
getterBody.Statements.Clear();
getterBody.Add(new ReturnStatement(baseCall.Clone()));
}
var setterBody = entityDeclaration.GetChildByRole(PropertyDeclaration.SetterRole).Body;
if (!setterBody.IsNull)
{
setterBody.Statements.Clear();
setterBody.Add(new AssignmentExpression(baseCall.Clone(), new IdentifierExpression("value")));
}
}
}
var document = textArea.Document;
StringWriter w = new StringWriter();
var formattingOptions = FormattingOptionsFactory.CreateSharpDevelop();
var segmentDict = SegmentTrackingOutputFormatter.WriteNode(w, entityDeclaration, formattingOptions, textArea.Options);
string newText = w.ToString().TrimEnd();
document.Replace(declarationBegin, completionSegment.EndOffset - declarationBegin, newText);
var throwStatement = entityDeclaration.Descendants.FirstOrDefault(n => n is ThrowStatement);
if (throwStatement != null)
{
var segment = segmentDict[throwStatement];
textArea.Selection = new RectangleSelection(textArea, new TextViewPosition(textArea.Document.GetLocation(declarationBegin + segment.Offset)), new TextViewPosition(textArea.Document.GetLocation(declarationBegin + segment.Offset + segment.Length)));
}
//format the inserted code nicely
var formatter = new CSharpFormatter(formattingOptions);
formatter.AddFormattingRegion(new DomRegion(document.GetLocation(declarationBegin), document.GetLocation(declarationBegin + newText.Length)));
var syntaxTree = new CSharpParser().Parse(document);
formatter.AnalyzeFormatting(document, syntaxTree).ApplyChanges();
}
开发者ID:nguyenkien,项目名称:NRefactory-Completion-Sample,代码行数:70,代码来源:OverrideCompletionData.cs
示例19: TransformCall
static AstNode TransformCall(bool isVirtual, object operand, MethodDefinition methodDef, List<Ast.Expression> args)
{
Cecil.MethodReference cecilMethod = ((MethodReference)operand);
Ast.Expression target;
List<Ast.Expression> methodArgs = new List<Ast.Expression>(args);
if (cecilMethod.HasThis) {
target = methodArgs[0];
methodArgs.RemoveAt(0);
// Unpack any DirectionExpression that is used as target for the call
// (calling methods on value types implicitly passes the first argument by reference)
if (target is DirectionExpression) {
target = ((DirectionExpression)target).Expression;
target.Remove(); // detach from DirectionExpression
}
} else {
target = new TypeReferenceExpression { Type = AstBuilder.ConvertType(cecilMethod.DeclaringType) };
}
if (target is ThisReferenceExpression && !isVirtual) {
// a non-virtual call on "this" might be a "base"-call.
if (cecilMethod.DeclaringType != methodDef.DeclaringType) {
// If we're not calling a method in the current class; we must be calling one in the base class.
target = new BaseReferenceExpression();
}
}
if (cecilMethod.Name == "Get" && cecilMethod.DeclaringType is ArrayType && methodArgs.Count > 1) {
return target.Indexer(methodArgs);
} else if (cecilMethod.Name == "Set" && cecilMethod.DeclaringType is ArrayType && methodArgs.Count > 2) {
return new AssignmentExpression(target.Indexer(methodArgs.GetRange(0, methodArgs.Count - 1)), methodArgs.Last());
}
// Resolve the method to figure out whether it is an accessor:
Cecil.MethodDefinition cecilMethodDef = cecilMethod.Resolve();
if (cecilMethodDef != null) {
if (cecilMethodDef.IsGetter && methodArgs.Count == 0) {
foreach (var prop in cecilMethodDef.DeclaringType.Properties) {
if (prop.GetMethod == cecilMethodDef)
return target.Member(prop.Name).WithAnnotation(prop);
}
} else if (cecilMethodDef.IsGetter) { // with parameters
PropertyDefinition indexer = GetIndexer(cecilMethodDef);
if (indexer != null)
return target.Indexer(methodArgs).WithAnnotation(indexer);
} else if (cecilMethodDef.IsSetter && methodArgs.Count == 1) {
foreach (var prop in cecilMethodDef.DeclaringType.Properties) {
if (prop.SetMethod == cecilMethodDef)
return new Ast.AssignmentExpression(target.Member(prop.Name).WithAnnotation(prop), methodArgs[0]);
}
} else if (cecilMethodDef.IsSetter && methodArgs.Count > 1) {
PropertyDefinition indexer = GetIndexer(cecilMethodDef);
if (indexer != null)
return new AssignmentExpression(
target.Indexer(methodArgs.GetRange(0, methodArgs.Count - 1)).WithAnnotation(indexer),
methodArgs[methodArgs.Count - 1]
);
} else if (cecilMethodDef.IsAddOn && methodArgs.Count == 1) {
foreach (var ev in cecilMethodDef.DeclaringType.Events) {
if (ev.AddMethod == cecilMethodDef) {
return new Ast.AssignmentExpression {
Left = target.Member(ev.Name).WithAnnotation(ev),
Operator = AssignmentOperatorType.Add,
Right = methodArgs[0]
};
}
}
} else if (cecilMethodDef.IsRemoveOn && methodArgs.Count == 1) {
foreach (var ev in cecilMethodDef.DeclaringType.Events) {
if (ev.RemoveMethod == cecilMethodDef) {
return new Ast.AssignmentExpression {
Left = target.Member(ev.Name).WithAnnotation(ev),
Operator = AssignmentOperatorType.Subtract,
Right = methodArgs[0]
};
}
}
}
}
// If the method has multiple signatures and an null argument is present, then we must cast the null to the correct type. This only needs to be done
// when the parameter number being passed a null has different types.
if (methodArgs.Exists(arg => arg is NullReferenceExpression))
{
var sameNames = cecilMethodDef.DeclaringType.Methods.Where(m => m.Name == cecilMethodDef.Name && m.Parameters.Count == cecilMethodDef.Parameters.Count).ToList();
if (sameNames.Count > 1)
{
for (int i = cecilMethod.Parameters.Count - 1; 0 <= i; --i)
{
var arg = methodArgs[i] as NullReferenceExpression;
if (arg != null)
{
if (sameNames.Count != sameNames.Count(m => m.Parameters[i].ParameterType.FullName == cecilMethodDef.Parameters[i].ParameterType.FullName))
methodArgs[i] = arg.CastTo(AstBuilder.ConvertType(cecilMethod.Parameters[i].ParameterType));
}
}
}
}
// Default invocation
//.........这里部分代码省略.........
开发者ID:richardschneider,项目名称:ILSpy,代码行数:101,代码来源:AstMethodBodyBuilder.cs
示例20: SimpleNonInvocationExpression
//.........这里部分代码省略.........
#line 1674 "VBNET.ATG"
string val = String.Empty;
if (StartOf(11)) {
PrimitiveTypeName(
#line 1675 "VBNET.ATG"
out val);
} else if (la.kind == 154) {
lexer.NextToken();
#line 1675 "VBNET.ATG"
val = "System.Object";
} else SynErr(257);
#line 1676 "VBNET.ATG"
pexpr = new TypeReferenceExpression(new TypeReference(val, true));
break;
}
case 139: {
lexer.NextToken();
#line 1677 "VBNET.ATG"
pexpr = new ThisReferenceExpression();
break;
}
case 144: case 145: {
#line 1678 "VBNET.ATG"
Expression retExpr = null;
if (la.kind == 144) {
lexer.NextToken();
#line 1679 "VBNET.ATG"
retExpr = new BaseReferenceExpression();
} else if (la.kind == 145) {
lexer.NextToken();
#line 1680 "VBNET.ATG"
retExpr = new ClassReferenceExpression();
} else SynErr(258);
Expect(16);
IdentifierOrKeyword(
#line 1682 "VBNET.ATG"
out name);
#line 1682 "VBNET.ATG"
pexpr = new MemberReferenceExpression(retExpr, name);
break;
}
case 117: {
lexer.NextToken();
Expect(16);
Identifier();
#line 1684 "VBNET.ATG"
type = new TypeReference(t.val ?? "");
#line 1686 "VBNET.ATG"
type.IsGlobal = true;
#line 1687 "VBNET.ATG"
pexpr = new TypeReferenceExpression(type);
break;
}
case 148: {
ObjectCreateExpression(
开发者ID:mgagne-atman,项目名称:Projects,代码行数:67,代码来源:Parser.cs
注:本文中的BaseReferenceExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论