CxExpression

Description

abstract class Tinman.Core.Cx.Expressions.CxExpression

Abstract base for classes that represent a Code-X expression.

The ICxReference.Resolved property may return the following values:

CxExpression...     |Binary
                    |   |Call
                    |   |   |Cast
                    |   |   |   |Default
                    |   |   |   |   |If |Index
                    |   |   |   |   |   |   |Literal
                    |   |   |   |   |   |   |   |Member
                    |   |   |   |   |   |   |   |   |Name
Cx...               |   |   |   |   |   |   |   |   |   |New|Unary
--------------------+---+---+---+---+---+---+---+---+---+---+---
Declaration         | A |   | A | A | A | A | A | C | C | A | A
DeclarationDelegate |   | B |   |   |   |   |   |   |   |   |
Item                |   |   |   |   |   |   |   | D | D |   |
MemberConstructor   |   |   |   |   |   |   |   |   |   | B |
MemberMethod        |   | B |   |   |   |   |   |   |   |   |
MemberProperty      |   |   |   |   |   |   |   | E | E |   |
MethodGroup         |   |   |   |   |   |   |   | F | F |   |
NamespaceGroup      |   |   |   |   |   |   |   | G | G |   |
Parameter           |   |   |   |   |   |   |   |   | H |   |
TypeParameter       |   |   |   |   |   |   |   |   | I |   |
Variable            |   |   |   |   |   |   |   | J | J |   |

The cases A .. O are defined as follows:

  • Case A:
    The type declaration that results from resolving the expression type.

  • Case B:
    The method or delegate that is invoked by a call expression or the constructor that is called by an object creation expression.

  • Case C:
    The type declaration that is referred to by the name / member expression.

  • Case D:
    The enumeration item that is referred to by the name / member expression.

  • Case E:
    The property that is referred to by the name / member expression or, when inside of the property setter, by the special name expression value.

  • Case F:
    The method group that has the same name as indicated by the name / member expression.

  • Case G:
    The group of those namespaces that match the name / member expression in the context of the enclosing code unit.

  • Case H:
    The parameter of a constructor, delegate or method that is referred to by the name expression.

  • Case I:
    The type parameter of a class, delegate, interface, struct or method that is referred to by the name expression.

  • Case J:
    The variable of a constant or field member that is referred to by the name / member expression or the variable in a for loop, a catch block or a statement block that is referred to by the name expression.

There is no expression for explicitly wrapping another expression in braces, i.e. (expr). The necessity for braces may be queried with NeedsBraces.

Public / Constants

Precedence​Additive


public constant PrecedenceAdditive → (11:int32)

Precedence of additive binary expressions.

Precedence​Conditional


public constant PrecedenceConditional → (2:int32)

Precedence of ternary if expressions.

See also

CxExpressionIf

Precedence​Conditional​And


public constant PrecedenceConditionalAnd → (4:int32)

Precedence of conditional AND binary expressions.

Precedence​Conditional​Or


public constant PrecedenceConditionalOr → (3:int32)

Precedence of conditional OR binary expressions.

Precedence​Equality


public constant PrecedenceEquality → (8:int32)

Precedence of equality binary expressions.

Precedence​Logical​And


public constant PrecedenceLogicalAnd → (7:int32)

Precedence of logical AND binary expressions.

Precedence​Logical​Or


public constant PrecedenceLogicalOr → (5:int32)

Precedence of logical OR binary expressions.

Precedence​Logical​XOr


public constant PrecedenceLogicalXOr → (6:int32)

Precedence of logical XOR binary expressions.

Precedence​Multiplicative


public constant PrecedenceMultiplicative → (12:int32)

Precedence of multiplicative binary expressions.

Precedence​Primary


public constant PrecedencePrimary → (14:int32)

Precedence of primary expressions.

Precedence​Relational


public constant PrecedenceRelational → (9:int32)

Precedence of relational binary expressions.

Precedence​Shift


public constant PrecedenceShift → (10:int32)

Precedence of shift binary expressions.

Precedence​Unary


public constant PrecedenceUnary → (13:int32)

Precedence value of unary expressions.

Public / Constructors

From​Source


public static method FromSource → (1)

source in : string

[not-null]
The source code.

returns → CxExpression

The parsed expression.

Parses the given expression.

ValidatingException

If the syntax of source in is invalid.

See also

CxCodeUnit

Public / Methods

As​Statement


public method AsStatement → ()

returns → CxStatement

The wrapping statement.

Wraps this expression in a statement.

As​Statement​Return


public method AsStatementReturn → ()

returns → CxStatementReturn

The wrapping return statement.

Wraps this expression in a return statement.

As​Statement​Throw


public method AsStatementThrow → ()

returns → CxStatementThrow

The wrapping throw statement.

Wraps this expression in a throw statement.

Write​Source​Code​With​Braces


public method WriteSourceCodeWithBraces → (3)

writer in : SourceCodeWriter

[not-null]
The source code writer to use.

context in : Context

[not-null]
Context information.

precedence in : int32

[>=0]
The precedence of the surrounding expression or 0 if there is no surrounding expression. See Precedence.

Produces source code by feeding the given source code writer.

IOException

If an I/O error occurs while emitting source code to writer in.

Public / Attributes

Expression​Type


public attribute ExpressionType → (get)

value : CxType

[not-null]
The expression type or CxTypeSimple.Void iff unresolved.

Returns the type this expression evaluates to.

Needs​Braces


public attribute NeedsBraces → (get)

value : bool

true if this expression must be wrapped in braces,
false if braces are not necessary.

Does this expression need to be wrapped in braces?

Protected / Methods

Compute​Expression​Type


[Pure]
protected static method ComputeExpressionType → (1)

resolved in : CxNode

The resolved node, either a ICxTypeContainer or a CxDeclarationType.

returns → CxType

The resolved type or null.

Computes the expression type from the given resolved node.


protected abstract method ComputeExpressionType → ()

returns → CxType

The expression type or null iff not resolvable.

Computes the expression type.

This method is called from PsiNode.OnResolved.