本文整理汇总了C#中ThisReferenceExpression类的典型用法代码示例。如果您正苦于以下问题:C# ThisReferenceExpression类的具体用法?C# ThisReferenceExpression怎么用?C# ThisReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ThisReferenceExpression类属于命名空间,在下文中一共展示了ThisReferenceExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitThisReferenceExpression
public override void VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression)
{
base.VisitThisReferenceExpression(thisReferenceExpression);
var memberReference = thisReferenceExpression.Parent as MemberReferenceExpression;
if (memberReference == null) {
return;
}
var state = ctx.GetResolverStateAfter(thisReferenceExpression);
var wholeResult = ctx.Resolve(memberReference);
IMember member = GetMember(wholeResult);
if (member == null) {
return;
}
var result = state.LookupSimpleNameOrTypeName(memberReference.MemberName, EmptyList<IType>.Instance, SimpleNameLookupMode.Expression);
bool isRedundant;
if (result is MemberResolveResult) {
isRedundant = ((MemberResolveResult)result).Member.Region.Equals(member.Region);
} else if (result is MethodGroupResolveResult) {
isRedundant = ((MethodGroupResolveResult)result).Methods.Any(m => m.Region.Equals(member.Region));
} else {
return;
}
if (isRedundant) {
AddIssue(thisReferenceExpression.StartLocation, memberReference.MemberNameToken.StartLocation, ctx.TranslateString("Remove redundant 'this.'"), script => {
script.Replace(memberReference, RefactoringAstHelper.RemoveTarget(memberReference));
}
);
}
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:34,代码来源:RedundantThisIssue.cs
示例2: GetActions
public override IEnumerable<CodeAction> GetActions(RefactoringContext context)
{
var property = context.GetNode<PropertyDeclaration> ();
if (property == null || !property.NameToken.Contains(context.Location))
yield break;
if (!IsNotImplemented (context, property.Getter.Body) ||
!IsNotImplemented (context, property.Setter.Body)) {
yield break;
}
yield return new CodeAction(context.TranslateString("Implement property"), script => {
string backingStoreName = context.GetNameProposal (property.Name);
// create field
var backingStore = new FieldDeclaration ();
if (property.Modifiers.HasFlag (Modifiers.Static))
backingStore.Modifiers |= Modifiers.Static;
if (property.Setter.IsNull)
backingStore.Modifiers |= Modifiers.Readonly;
backingStore.ReturnType = property.ReturnType.Clone ();
var initializer = new VariableInitializer (backingStoreName);
backingStore.Variables.Add (initializer);
// create new property & implement the get/set bodies
var newProperty = (PropertyDeclaration)property.Clone ();
Expression id1;
if (backingStoreName == "value")
id1 = new ThisReferenceExpression().Member("value");
else
id1 = new IdentifierExpression (backingStoreName);
Expression id2 = id1.Clone();
newProperty.Getter.Body = new BlockStatement () {
new ReturnStatement (id1)
};
if (!property.Setter.IsNull) {
newProperty.Setter.Body = new BlockStatement () {
new AssignmentExpression (id2, AssignmentOperatorType.Assign, new IdentifierExpression ("value"))
};
}
script.Replace (property, newProperty);
script.InsertBefore (property, backingStore);
if (!property.Setter.IsNull)
script.Link (initializer, id1, id2);
else
script.Link (initializer, id1);
}, property.NameToken);
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:52,代码来源:ImplementNotImplementedProperty.cs
示例3: GetActions
public IEnumerable<CodeAction> GetActions(RefactoringContext context)
{
var property = context.GetNode<PropertyDeclaration>();
if (!(property != null &&
!property.Getter.IsNull && !property.Setter.IsNull && // automatic properties always need getter & setter
property.Getter.Body.IsNull &&
property.Setter.Body.IsNull)) {
yield break;
}
yield return new CodeAction(context.TranslateString("Create backing store"), script => {
string backingStoreName = context.GetNameProposal (property.Name);
// create field
var backingStore = new FieldDeclaration ();
if (property.Modifiers.HasFlag (Modifiers.Static))
backingStore.Modifiers |= Modifiers.Static;
backingStore.ReturnType = property.ReturnType.Clone ();
var initializer = new VariableInitializer (backingStoreName);
backingStore.Variables.Add (initializer);
// create new property & implement the get/set bodies
var newProperty = (PropertyDeclaration)property.Clone ();
Expression id1;
if (backingStoreName == "value")
id1 = new ThisReferenceExpression().Member("value");
else
id1 = new IdentifierExpression (backingStoreName);
Expression id2 = id1.Clone();
newProperty.Getter.Body = new BlockStatement () {
new ReturnStatement (id1)
};
newProperty.Setter.Body = new BlockStatement () {
new AssignmentExpression (id2, AssignmentOperatorType.Assign, new IdentifierExpression ("value"))
};
script.Replace (property, newProperty);
script.InsertBefore (property, backingStore);
script.Link (initializer, id1, id2);
});
}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:42,代码来源:CreateBackingStoreAction.cs
示例4: VisitThisReferenceExpression
public abstract StringBuilder VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, int data);
开发者ID:hach-que,项目名称:SLSharp,代码行数:1,代码来源:VisitorBase.Abstract.cs
示例5: TrackedVisitThisReferenceExpression
public virtual object TrackedVisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data) {
return base.VisitThisReferenceExpression(thisReferenceExpression, data);
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:3,代码来源:NodeTrackingAstVisitor.cs
示例6: Visit
public override object Visit (This thisExpression)
{
var result = new ThisReferenceExpression ();
result.Location = Convert (thisExpression.Location);
return result;
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:6,代码来源:CSharpParser.cs
示例7: TransformByteCode
//.........这里部分代码省略.........
case ILCode.Ldc_R8:
case ILCode.Ldc_Decimal:
return new Ast.PrimitiveExpression(operand);
case ILCode.Ldfld:
if (arg1 is DirectionExpression)
arg1 = ((DirectionExpression)arg1).Expression.Detach();
return arg1.Member(((FieldReference) operand).Name).WithAnnotation(operand);
case ILCode.Ldsfld:
return AstBuilder.ConvertType(((FieldReference)operand).DeclaringType)
.Member(((FieldReference)operand).Name).WithAnnotation(operand);
case ILCode.Stfld:
if (arg1 is DirectionExpression)
arg1 = ((DirectionExpression)arg1).Expression.Detach();
return new AssignmentExpression(arg1.Member(((FieldReference) operand).Name).WithAnnotation(operand), arg2);
case ILCode.Stsfld:
return new AssignmentExpression(
AstBuilder.ConvertType(((FieldReference)operand).DeclaringType)
.Member(((FieldReference)operand).Name).WithAnnotation(operand),
arg1);
case ILCode.Ldflda:
if (arg1 is DirectionExpression)
arg1 = ((DirectionExpression)arg1).Expression.Detach();
return MakeRef(arg1.Member(((FieldReference) operand).Name).WithAnnotation(operand));
case ILCode.Ldsflda:
return MakeRef(
AstBuilder.ConvertType(((FieldReference)operand).DeclaringType)
.Member(((FieldReference)operand).Name).WithAnnotation(operand));
case ILCode.Ldloc: {
ILVariable v = (ILVariable)operand;
if (!v.IsParameter)
localVariablesToDefine.Add((ILVariable)operand);
Expression expr;
if (v.IsParameter && v.OriginalParameter.Index < 0)
expr = new ThisReferenceExpression();
else
expr = new Ast.IdentifierExpression(((ILVariable)operand).Name).WithAnnotation(operand);
return v.IsParameter && v.Type is ByReferenceType ? MakeRef(expr) : expr;
}
case ILCode.Ldloca: {
ILVariable v = (ILVariable)operand;
if (v.IsParameter && v.OriginalParameter.Index < 0)
return MakeRef(new ThisReferenceExpression());
if (!v.IsParameter)
localVariablesToDefine.Add((ILVariable)operand);
return MakeRef(new Ast.IdentifierExpression(((ILVariable)operand).Name).WithAnnotation(operand));
}
case ILCode.Ldnull: return new Ast.NullReferenceExpression();
case ILCode.Ldstr: return new Ast.PrimitiveExpression(operand);
case ILCode.Ldtoken:
if (operand is Cecil.TypeReference) {
return new Ast.TypeOfExpression { Type = operandAsTypeRef }.Member("TypeHandle");
} else {
return InlineAssembly(byteCode, args);
}
case ILCode.Leave: return new GotoStatement() { Label = ((ILLabel)operand).Name };
case ILCode.Localloc:
{
PointerType ptrType = byteCode.InferredType as PointerType;
TypeReference type;
if (ptrType != null) {
type = ptrType.ElementType;
} else {
type = typeSystem.Byte;
}
return new StackAllocExpression {
Type = AstBuilder.ConvertType(type),
开发者ID:JustasB,项目名称:cudafy,代码行数:67,代码来源:AstMethodBodyBuilder.cs
示例8: TransformByteCode
//.........这里部分代码省略.........
case ILCode.Ldc_I4: return AstBuilder.MakePrimitive((int)operand, byteCode.InferredType);
case ILCode.Ldc_I8: return AstBuilder.MakePrimitive((long)operand, byteCode.InferredType);
case ILCode.Ldc_R4:
case ILCode.Ldc_R8:
case ILCode.Ldc_Decimal:
return new Ast.PrimitiveExpression(operand);
case ILCode.Ldfld:
if (arg1 is DirectionExpression)
arg1 = ((DirectionExpression)arg1).Expression.Detach();
return arg1.Member(((FieldReference) operand).Name).WithAnnotation(operand);
case ILCode.Ldsfld:
return AstBuilder.ConvertType(((FieldReference)operand).DeclaringType)
.Member(((FieldReference)operand).Name).WithAnnotation(operand);
case ILCode.Stfld:
if (arg1 is DirectionExpression)
arg1 = ((DirectionExpression)arg1).Expression.Detach();
return new AssignmentExpression(arg1.Member(((FieldReference) operand).Name).WithAnnotation(operand), arg2);
case ILCode.Stsfld:
return new AssignmentExpression(
AstBuilder.ConvertType(((FieldReference)operand).DeclaringType)
.Member(((FieldReference)operand).Name).WithAnnotation(operand),
arg1);
case ILCode.Ldflda: return MakeRef(arg1.Member(((FieldReference) operand).Name).WithAnnotation(operand));
case ILCode.Ldsflda:
return MakeRef(
AstBuilder.ConvertType(((FieldReference)operand).DeclaringType)
.Member(((FieldReference)operand).Name).WithAnnotation(operand));
case ILCode.Ldloc: {
ILVariable v = (ILVariable)operand;
if (!v.IsParameter)
localVariablesToDefine.Add((ILVariable)operand);
Expression expr;
if (v.IsParameter && v.OriginalParameter.Index < 0)
expr = new ThisReferenceExpression();
else
expr = new Ast.IdentifierExpression(((ILVariable)operand).Name).WithAnnotation(operand);
return v.IsParameter && v.Type is ByReferenceType ? MakeRef(expr) : expr;
}
case ILCode.Ldloca: {
ILVariable v = (ILVariable)operand;
if (v.IsParameter && v.OriginalParameter.Index < 0)
return MakeRef(new ThisReferenceExpression());
if (!v.IsParameter)
localVariablesToDefine.Add((ILVariable)operand);
return MakeRef(new Ast.IdentifierExpression(((ILVariable)operand).Name).WithAnnotation(operand));
}
case ILCode.Ldnull: return new Ast.NullReferenceExpression();
case ILCode.Ldstr: return new Ast.PrimitiveExpression(operand);
case ILCode.Ldtoken:
if (operand is Cecil.TypeReference) {
return new Ast.TypeOfExpression { Type = operandAsTypeRef }.Member("TypeHandle");
} else {
return InlineAssembly(byteCode, args);
}
case ILCode.Leave: return new GotoStatement() { Label = ((ILLabel)operand).Name };
case ILCode.Localloc:
{
PointerType ptrType = byteCode.InferredType as PointerType;
TypeReference type;
if (ptrType != null) {
type = ptrType.ElementType;
} else {
type = typeSystem.Byte;
}
return new StackAllocExpression {
Type = AstBuilder.ConvertType(type),
开发者ID:dsrbecky,项目名称:ILSpy,代码行数:67,代码来源:AstMethodBodyBuilder.cs
示例9: VisitThisReferenceExpression
public void VisitThisReferenceExpression(ThisReferenceExpression expression)
{
Formatter.StartNode(expression);
Formatter.WriteKeyword("this");
Formatter.EndNode();
}
开发者ID:JerreS,项目名称:AbstractCode,代码行数:6,代码来源:CSharpAstWriter.cs
示例10: VisitThisReferenceExpression
public virtual object VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data) {
Debug.Assert((thisReferenceExpression != null));
return null;
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:4,代码来源:AbstractASTVisitor.cs
示例11: VisitThisReferenceExpression
public void VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression)
{
JsonObject expression = CreateJsonExpression(thisReferenceExpression);
Push(expression);
}
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:5,代码来源:AstCsToJson.cs
示例12: VisitThisReferenceExpression
public void VisitThisReferenceExpression(ThisReferenceExpression node)
{
VisitChildren(node);
}
开发者ID:evanw,项目名称:minisharp,代码行数:4,代码来源:Lower.cs
示例13: VisitThisReferenceExpression
public virtual object VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data) {
throw new global::System.NotImplementedException("ThisReferenceExpression");
}
开发者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: VisitThisReferenceExpression
public sealed override object VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data) {
BeginVisit(thisReferenceExpression);
object result = TrackedVisitThisReferenceExpression(thisReferenceExpression, data);
EndVisit(thisReferenceExpression);
return result;
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:6,代码来源:NodeTrackingAstVisitor.cs
示例16: Visit
public override object Visit(ThisReferenceExpression thisReferenceExpression, object data)
{
if (resolver.CallingClass == null) {
return null;
}
return new ReturnType(resolver.CallingClass.FullyQualifiedName);
}
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:7,代码来源:TypeVisitor.cs
示例17: ThisReferenceBlock
public ThisReferenceBlock(IEmitter emitter, ThisReferenceExpression thisReferenceExpression)
: base(emitter, thisReferenceExpression)
{
this.Emitter = emitter;
this.ThisReferenceExpression = thisReferenceExpression;
}
开发者ID:txdv,项目名称:Builder,代码行数:6,代码来源:ThisReferenceBlock.cs
示例18: TransformByteCode
//.........这里部分代码省略.........
case ILCode.Ldc_R8:
case ILCode.Ldc_Decimal:
return new Ast.PrimitiveExpression(operand);
case ILCode.Ldfld:
if (arg1 is DirectionExpression)
arg1 = ((DirectionExpression)arg1).Expression.Detach();
return arg1.Member(((IField) operand).Name, operand).WithAnnotation(operand);
case ILCode.Ldsfld:
return AstBuilder.ConvertType(((IField)operand).DeclaringType)
.Member(((IField)operand).Name, operand).WithAnnotation(operand);
case ILCode.Stfld:
if (arg1 is DirectionExpression)
arg1 = ((DirectionExpression)arg1).Expression.Detach();
return new AssignmentExpression(arg1.Member(((IField) operand).Name, operand).WithAnnotation(operand), arg2);
case ILCode.Stsfld:
return new AssignmentExpression(
AstBuilder.ConvertType(((IField)operand).DeclaringType)
.Member(((IField)operand).Name, operand).WithAnnotation(operand),
arg1);
case ILCode.Ldflda:
if (arg1 is DirectionExpression)
arg1 = ((DirectionExpression)arg1).Expression.Detach();
return MakeRef(arg1.Member(((IField) operand).Name, operand).WithAnnotation(operand));
case ILCode.Ldsflda:
return MakeRef(
AstBuilder.ConvertType(((IField)operand).DeclaringType)
.Member(((IField)operand).Name, operand).WithAnnotation(operand));
case ILCode.Ldloc: {
ILVariable v = (ILVariable)operand;
if (!v.IsParameter)
localVariablesToDefine.Add((ILVariable)operand);
Expression expr;
if (v.IsParameter && v.OriginalParameter.IsHiddenThisParameter)
expr = new ThisReferenceExpression().WithAnnotation(methodDef.DeclaringType);
else
expr = Ast.IdentifierExpression.Create(((ILVariable)operand).Name, ((ILVariable)operand).IsParameter ? TextTokenType.Parameter : TextTokenType.Local).WithAnnotation(operand);
return v.IsParameter && v.Type is ByRefSig ? MakeRef(expr) : expr;
}
case ILCode.Ldloca: {
ILVariable v = (ILVariable)operand;
if (v.IsParameter && v.OriginalParameter.IsHiddenThisParameter)
return MakeRef(new ThisReferenceExpression().WithAnnotation(methodDef.DeclaringType));
if (!v.IsParameter)
localVariablesToDefine.Add((ILVariable)operand);
return MakeRef(Ast.IdentifierExpression.Create(((ILVariable)operand).Name, ((ILVariable)operand).IsParameter ? TextTokenType.Parameter : TextTokenType.Local).WithAnnotation(operand));
}
case ILCode.Ldnull: return new Ast.NullReferenceExpression();
case ILCode.Ldstr: return new Ast.PrimitiveExpression(operand);
case ILCode.Ldtoken:
if (operand is ITypeDefOrRef) {
var th = Create_SystemType_get_TypeHandle();
return AstBuilder.CreateTypeOfExpression((ITypeDefOrRef)operand).Member("TypeHandle", TextTokenType.InstanceProperty).WithAnnotation(th);
} else {
Expression referencedEntity;
string loadName;
string handleName;
if (operand is IField && ((IField)operand).FieldSig != null) {
loadName = "fieldof";
handleName = "FieldHandle";
IField fr = (IField)operand;
referencedEntity = AstBuilder.ConvertType(fr.DeclaringType).Member(fr.Name, fr).WithAnnotation(fr);
} else if (operand is IMethod) {
loadName = "methodof";
handleName = "MethodHandle";
IMethod mr = (IMethod)operand;
var methodParameters = mr.MethodSig.GetParameters().Select(p => new TypeReferenceExpression(AstBuilder.ConvertType(p)));
开发者ID:nakijun,项目名称:dnSpy,代码行数:67,代码来源:AstMethodBodyBuilder.cs
示例19: PrimaryExpr
//.........这里部分代码省略.........
#line 1912 "cs.ATG"
val = "System.UInt32";
break;
}
case 117: {
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(
开发者ID:mgagne-atman,项目名称:Projects,代码行数:67,代码来源:Parser.cs
示例20: VisitThisReferenceExpression
public override void VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression)
{
UsesNonStaticMember = true;
base.VisitThisReferenceExpression(thisReferenceExpression);
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:5,代码来源:StaticVisitor.cs
注:本文中的ThisReferenceExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论