本文整理汇总了C#中IndexerExpression类的典型用法代码示例。如果您正苦于以下问题:C# IndexerExpression类的具体用法?C# IndexerExpression怎么用?C# IndexerExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndexerExpression类属于命名空间,在下文中一共展示了IndexerExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitIndexerExpression
public override void VisitIndexerExpression(IndexerExpression indexerExpression)
{
base.VisitIndexerExpression(indexerExpression);
var localResolveResult = context.Resolve(indexerExpression.Target) as LocalResolveResult;
if (localResolveResult == null)
return;
var resolveResult = context.Resolve(indexerExpression);
if (localResolveResult == null)
return;
var parent = indexerExpression.Parent;
while (parent is ParenthesizedExpression)
parent = parent.Parent;
if (parent is DirectionExpression) {
// The only types which are indexable and where the indexing expression
// results in a variable is an actual array type
AddCriterion(localResolveResult.Variable, new IsArrayTypeCriterion());
} else if (resolveResult is ArrayAccessResolveResult) {
var arrayResolveResult = (ArrayAccessResolveResult)resolveResult;
var arrayType = arrayResolveResult.Array.Type as ArrayType;
if (arrayType != null) {
var parameterTypes = arrayResolveResult.Indexes.Select(index => index.Type);
var criterion = new SupportsIndexingCriterion(arrayType.ElementType, parameterTypes, CSharpConversions.Get(context.Compilation));
AddCriterion(localResolveResult.Variable, criterion);
}
} else if (resolveResult is CSharpInvocationResolveResult) {
var invocationResolveResult = (CSharpInvocationResolveResult)resolveResult;
var parameterTypes = invocationResolveResult.Arguments.Select(arg => arg.Type);
var criterion = new SupportsIndexingCriterion(invocationResolveResult.Member.ReturnType, parameterTypes, CSharpConversions.Get(context.Compilation));
AddCriterion(localResolveResult.Variable, criterion);
}
}
示例2: ArrayCreationInIndexer
public void ArrayCreationInIndexer()
{
Expression expr = new IndexerExpression {
Target = new ArrayCreateExpression {
Type = new PrimitiveType("int"),
Arguments = { new PrimitiveExpression(1) }
},
Arguments = { new PrimitiveExpression(0) }
};
Assert.AreEqual("(new int[1]) [0]", InsertRequired(expr));
Assert.AreEqual("(new int[1]) [0]", InsertReadable(expr));
}
示例3: ArgumentsInfo
public ArgumentsInfo(IEmitter emitter, IndexerExpression invocationExpression)
{
this.Emitter = emitter;
this.Expression = invocationExpression;
var arguments = invocationExpression.Arguments.ToList();
this.ResolveResult = emitter.Resolver.ResolveNode(invocationExpression, emitter) as InvocationResolveResult;
this.BuildArgumentsList(arguments);
if (this.ResolveResult != null)
{
this.BuildTypedArguments(invocationExpression.Target);
}
}
示例4: VisitIndexerExpression
public override void VisitIndexerExpression(IndexerExpression indexerExpression)
{
ForceSpacesBefore(indexerExpression.LBracketToken, policy.SpacesBeforeBrackets);
ForceSpacesAfter(indexerExpression.LBracketToken, policy.SpacesWithinBrackets);
if (!indexerExpression.Target.IsNull)
indexerExpression.Target.AcceptVisitor(this);
FormatArguments(indexerExpression);
}
示例5: VisitIndexerExpression
public override void VisitIndexerExpression(IndexerExpression indexerExpression)
{
ForceSpacesBefore(indexerExpression.LBracketToken, policy.SpacesBeforeBrackets);
ForceSpacesAfter(indexerExpression.LBracketToken, policy.SpacesWithinBrackets);
ForceSpacesBefore(indexerExpression.RBracketToken, policy.SpacesWithinBrackets);
FormatCommas(indexerExpression, policy.SpaceBeforeBracketComma, policy.SpaceAfterBracketComma);
base.VisitIndexerExpression(indexerExpression);
}
示例6: VisitIndexerExpression
public void VisitIndexerExpression(IndexerExpression indexerExpression)
{
StartNode(indexerExpression);
indexerExpression.Target.AcceptVisitor(this);
Space(policy.SpaceBeforeMethodCallParentheses);
WriteCommaSeparatedListInBrackets(indexerExpression.Arguments);
EndNode(indexerExpression);
}
示例7: VisitIndexerExpression
public override void VisitIndexerExpression (IndexerExpression indexerExpression)
{
base.VisitIndexerExpression (indexerExpression);
if (Match (indexerExpression.Target) && First == null) {
First = indexerExpression;
}
}
示例8: VisitIndexerExpression
public void VisitIndexerExpression(IndexerExpression indexerExpression)
{
JsonObject expression = CreateJsonExpression(indexerExpression);
expression.AddJsonValue("target", GenExpression(indexerExpression.Target));
expression.AddJsonValue("arguments", GetCommaSeparatedList(indexerExpression.Arguments));
Push(expression);
}
示例9: VisitIndexerExpression
public void VisitIndexerExpression(IndexerExpression indexExpr)
{
indexExpr.Target.AcceptWalker(this);
indexExpr.Arguments.AcceptWalker(this);
}
示例10: VisitIndexerExpression
public override StringBuilder VisitIndexerExpression(IndexerExpression indexerExpression, int data)
{
throw new NotImplementedException();
}
示例11: ArrayCreationWithInitializerInIndexer
public void ArrayCreationWithInitializerInIndexer()
{
Expression expr = new IndexerExpression {
Target = new ArrayCreateExpression {
Type = new PrimitiveType("int"),
Arguments = { new PrimitiveExpression(1) },
Initializer = new ArrayInitializerExpression {
Elements = { new PrimitiveExpression(42) }
}
},
Arguments = { new PrimitiveExpression(0) }
};
Assert.AreEqual("new int[1] { 42 } [0]", InsertRequired(expr));
Assert.AreEqual("(new int[1] { 42 }) [0]", InsertReadable(expr));
}
示例12: VisitIndexerExpression
public virtual void VisitIndexerExpression(IndexerExpression indexerExpression)
{
DebugExpression(indexerExpression);
StartNode(indexerExpression);
indexerExpression.Target.AcceptVisitor(this);
Space(policy.SpaceBeforeMethodCallParentheses);
WriteCommaSeparatedListInBrackets(indexerExpression.Arguments, CodeBracesRangeFlags.SquareBrackets);
EndNode(indexerExpression);
}
示例13: VisitIndexerExpression
public override void VisitIndexerExpression(IndexerExpression indexerExpression)
{
// nothing
}
示例14: PrimaryExpr
//.........这里部分代码省略.........
lexer.NextToken();
AnonymousMethodExpr(
#line 1938 "cs.ATG"
out expr);
#line 1938 "cs.ATG"
pexpr = expr;
} else SynErr(209);
#line 1940 "cs.ATG"
if (pexpr != null) {
if (pexpr.StartLocation.IsEmpty)
pexpr.StartLocation = startLocation;
if (pexpr.EndLocation.IsEmpty)
pexpr.EndLocation = t.EndLocation;
}
while (StartOf(36)) {
if (la.kind == 31 || la.kind == 32) {
#line 1948 "cs.ATG"
startLocation = la.Location;
if (la.kind == 31) {
lexer.NextToken();
#line 1950 "cs.ATG"
pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement);
} else if (la.kind == 32) {
lexer.NextToken();
#line 1951 "cs.ATG"
pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement);
} else SynErr(210);
} else if (la.kind == 47) {
PointerMemberAccess(
#line 1954 "cs.ATG"
out pexpr, pexpr);
} else if (la.kind == 15) {
MemberAccess(
#line 1955 "cs.ATG"
out pexpr, pexpr);
} else if (la.kind == 20) {
lexer.NextToken();
#line 1959 "cs.ATG"
List<Expression> parameters = new List<Expression>();
#line 1960 "cs.ATG"
pexpr = new InvocationExpression(pexpr, parameters);
if (StartOf(26)) {
Argument(
#line 1961 "cs.ATG"
out expr);
#line 1961 "cs.ATG"
SafeAdd(pexpr, parameters, expr);
while (la.kind == 14) {
lexer.NextToken();
Argument(
#line 1962 "cs.ATG"
out expr);
#line 1962 "cs.ATG"
SafeAdd(pexpr, parameters, expr);
}
}
Expect(21);
} else {
#line 1968 "cs.ATG"
List<Expression> indices = new List<Expression>();
pexpr = new IndexerExpression(pexpr, indices);
lexer.NextToken();
Expr(
#line 1971 "cs.ATG"
out expr);
#line 1971 "cs.ATG"
SafeAdd(pexpr, indices, expr);
while (la.kind == 14) {
lexer.NextToken();
Expr(
#line 1972 "cs.ATG"
out expr);
#line 1972 "cs.ATG"
SafeAdd(pexpr, indices, expr);
}
Expect(19);
#line 1975 "cs.ATG"
if (pexpr != null) {
pexpr.StartLocation = startLocation;
pexpr.EndLocation = t.EndLocation;
}
}
}
}
示例15: VisitIndexerExpression
public virtual object VisitIndexerExpression(IndexerExpression indexerExpression, object data) {
Debug.Assert((indexerExpression != null));
Debug.Assert((indexerExpression.TargetObject != null));
Debug.Assert((indexerExpression.Indexes != null));
indexerExpression.TargetObject.AcceptVisitor(this, data);
foreach (Expression o in indexerExpression.Indexes) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
return null;
}