本文整理汇总了C#中ExpressionSyntax.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ExpressionSyntax.GetType方法的具体用法?C# ExpressionSyntax.GetType怎么用?C# ExpressionSyntax.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionSyntax
的用法示例。
在下文中一共展示了ExpressionSyntax.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resolve
public override FlatOperand Resolve(ExpressionSyntax expression, ArgumentListSyntax argumentList, TypeInfo result_type, SymbolInfo si, FlatOperand into_lvalue, Function function, List<FlatStatement> instructions)
{
FlatOperand fop_subject;
if (expression is IdentifierNameSyntax)
{
// typeof this
fop_subject = FlatOperand.ThisRef(FlatValue.FromType(result_type.ConvertedType));
}
else if (expression is MemberAccessExpressionSyntax)
{
MemberAccessExpressionSyntax meas = (MemberAccessExpressionSyntax)expression;
fop_subject = function.ResolveExpression(meas.Expression, null, instructions);
}
else
{
throw new NotImplementedException("GetMetaTable on expression type " + expression.GetType().ToString());
}
if (into_lvalue == null)
{
FlatOperand fop_register = function.AllocateRegister("");
into_lvalue = fop_register.GetLValue(function, instructions);
}
instructions.Add(FlatStatement.GETMETATABLE(into_lvalue, fop_subject));
return into_lvalue.AsRValue(FlatValue.Table());
}
示例2: ResolveExpression
/// <summary>
/// Resolves an expression into an r-value (where 0 is an l-value meaning register 0, register[0] is its r-value)
/// </summary>
/// <param name="node">the expression to resolve</param>
/// <param name="into_lvalue">Either an existing l-value, or null to auto-generate where necessary</param>
/// <param name="instructions">the set of instructions to generate any new instructions into</param>
/// <returns>An r-value with the result</returns>
public FlatOperand ResolveExpression(ExpressionSyntax node, FlatOperand into_lvalue, List<FlatStatement> instructions)
{
TypeInfo result_type = Model.GetTypeInfo(node);
// resultant type of the expression
#if IMPLICIT_CONVERSION_HAS_A_REPLACEMENT_then_i_dont_know_what_it_is
if (!result_type.ImplicitConversion.IsIdentity && !result_type.ImplicitConversion.IsImplicit)
{
throw new NotImplementedException("type conversion");
}
#endif
if (node is PredefinedTypeSyntax)
{
/*
// Summary:
// SyntaxToken which represents the keyword corresponding to the predefined
// type.
public SyntaxToken Keyword { get; }*/
PredefinedTypeSyntax pts = (PredefinedTypeSyntax)node;
SymbolInfo si = Model.GetSymbolInfo(node);
switch (si.Symbol.Kind)
{
case SymbolKind.NamedType:
{
FlatOperand fop_type = Resolve((ITypeSymbol)si.Symbol, into_lvalue, instructions);
return fop_type;
}
}
}
if (node is ParenthesizedExpressionSyntax)
{
ParenthesizedExpressionSyntax pes = (ParenthesizedExpressionSyntax)node;
return ResolveExpression(pes.Expression, into_lvalue, instructions);
}
if (node is PostfixUnaryExpressionSyntax)
{
return ResolveExpression((PostfixUnaryExpressionSyntax)node, result_type, into_lvalue, instructions);
}
if (node is PrefixUnaryExpressionSyntax)
{
PrefixUnaryExpressionSyntax pues = (PrefixUnaryExpressionSyntax)node;
FlatOperand right = ResolveExpression(pues.Operand, into_lvalue, instructions);
#if NEGATE_EXPRESSION
switch (pues.CSharpKind())
{
case SyntaxKind.NegateExpression:
if (into_lvalue != null)
{
instructions.Add(FlatStatement.NEGATE(into_lvalue, right));
return into_lvalue.AsRValue(right.ImmediateValue);
}
FlatOperand left = this.AllocateRegister("");
into_lvalue = left.GetLValue(this, instructions);
instructions.Add(FlatStatement.NEGATE(into_lvalue, right));
return left;
}
#endif
throw new NotImplementedException("Prefix unary " + pues.CSharpKind().ToString());
}
if (node is BinaryExpressionSyntax)
{
BinaryExpressionSyntax bes = (BinaryExpressionSyntax)node;
return ResolveExpression(bes, result_type, into_lvalue, null, instructions);
}
if (node is LiteralExpressionSyntax)
{
LiteralExpressionSyntax les = (LiteralExpressionSyntax)node;
FlatValue val = FlatValue.FromLiteralToken(result_type.ConvertedType, les.Token);
FlatOperand right = FlatOperand.Immediate(val);
if (into_lvalue != null)
{
instructions.Add(FlatStatement.REFERENCE(into_lvalue,right));
return into_lvalue.AsRValue(val);
}
return right;
}
if (node is IdentifierNameSyntax)
{
IdentifierNameSyntax ins = (IdentifierNameSyntax)node;
return Resolve(ins, result_type, into_lvalue, instructions);
}
if (node is QualifiedNameSyntax)
{
QualifiedNameSyntax qns = (QualifiedNameSyntax)node;
return Resolve(qns, result_type, into_lvalue, instructions);
}
if (node is InvocationExpressionSyntax)
{
//.........这里部分代码省略.........
示例3: CompileExpression
public virtual void CompileExpression(ExpressionSyntax expression)
{
if (expression is BinaryExpressionSyntax) CompileBinaryExpression( (BinaryExpressionSyntax) expression);
else if (expression is MemberAccessExpressionSyntax) CompileMemberAccessExpression( (MemberAccessExpressionSyntax) expression);
else if (expression is IdentifierNameSyntax) CompileIdentifierName( (IdentifierNameSyntax) expression);
else if (expression is ElementAccessExpressionSyntax) CompileElementAccessExpression( (ElementAccessExpressionSyntax) expression);
else if (expression is InvocationExpressionSyntax) CompileInvocationExpression( (InvocationExpressionSyntax) expression);
else if (expression is CastExpressionSyntax) CompileCastExpression( (CastExpressionSyntax) expression);
else if (expression is ParenthesizedExpressionSyntax) CompileParenthesizedExpression( (ParenthesizedExpressionSyntax) expression);
else if (expression is TypeSyntax) CompileType( (TypeSyntax) expression);
else if (expression is LiteralExpressionSyntax) CompileLiteralExpression( (LiteralExpressionSyntax) expression);
else if (expression is ConditionalExpressionSyntax) CompileConditionalExpression( (ConditionalExpressionSyntax) expression);
else if (expression is ObjectCreationExpressionSyntax) CompileObjectCreationExpression((ObjectCreationExpressionSyntax)expression);
else if (expression is PrefixUnaryExpressionSyntax) CompilePrefixUnaryExpression( (PrefixUnaryExpressionSyntax) expression);
else Write("expression " + expression.GetType().Name);
}