override public void LeaveUnaryExpression(UnaryExpression node) { if (node.Operator == UnaryOperatorType.SafeAccess) { // target references should already be resolved, so just evaluate as existential var notnull = CodeBuilder.CreateNotNullTest(node.Operand); ReplaceCurrentNode(notnull); } }
public override void LeaveUnaryExpression(UnaryExpression node) { switch (node.Operator) { case UnaryOperatorType.LogicalNot: node.Operand = ExplicitBooleanContext(node.Operand); break; } }
public override void LeaveUnaryExpression(UnaryExpression node) { if (IsDuckTyped(node.Operand) && node.Operator == UnaryOperatorType.UnaryNegation) { BindDuck(node); } else { base.LeaveUnaryExpression(node); } }
public override void LeaveUnaryExpression(Boo.Lang.Compiler.Ast.UnaryExpression node) { switch (node.Operator) { case UnaryOperatorType.UnaryNegation: { LeaveUnaryNegation(node); break; } case UnaryOperatorType.OnesComplement: { LeaveOnesCompliment(node); break; } } }
public override void LeaveMethodInvocationExpression(MethodInvocationExpression node) { IEntityWithParameters parameters = node.get_Target().get_Entity() as IEntityWithParameters; if (parameters != null) { ExpressionCollection args = node.get_Arguments(); if (parameters.get_AcceptVarArgs() && UnityCallableResolutionServiceModule.IsArrayArgumentExplicitlyProvided(parameters.GetParameters(), args)) { UnaryExpression expression2; Expression expression = args.get_Item(-1); UnaryExpression expression1 = expression2 = new UnaryExpression(); expression2.set_Operator(7); expression2.set_Operand(expression); expression2.set_ExpressionType(this.GetExpressionType(expression)); args.ReplaceAt(-1, expression2); } } }
private void ProcessOperatorOverload(UnaryExpression node) { if (! ResolveOperator(node)) { InvalidOperatorForType(node); } }
private void LeaveUnaryNegation(UnaryExpression node) { if (IsPrimitiveNumber(node.Operand)) BindExpressionType(node, GetExpressionType(node.Operand)); else ProcessOperatorOverload(node); }
private void LeaveLogicalNot(UnaryExpression node) { BindExpressionType(node, TypeSystemServices.BoolType); }
void LeaveIncrementDecrement(UnaryExpression node) { if (AssertLValue(node.Operand)) { if (!IsValidIncrementDecrementOperand(node.Operand)) InvalidOperatorForType(node); else ExpandIncrementDecrement(node); } else Error(node); }
void InvalidOperatorForType(UnaryExpression node) { Error(node, CompilerErrorFactory.InvalidOperatorForType(node, GetUnaryOperatorText(node.Operator), GetExpressionType(node.Operand))); }
Expression ExpandIncrementDecrementArraySlicing(UnaryExpression node) { SlicingExpression slicing = (SlicingExpression)node.Operand; AssertIsNotComplexSlicing(slicing); Visit(slicing); return CreateSideEffectAwareSlicingOperation( node.LexicalInfo, GetEquivalentBinaryOperator(node.Operator), slicing, CodeBuilder.CreateIntegerLiteral(1), DeclareOldValueTempIfNeeded(node)); }
InternalLocal DeclareOldValueTempIfNeeded(UnaryExpression node) { return AstUtil.IsPostUnaryOperator(node.Operator) ? DeclareTempLocal(GetExpressionType(node.Operand)) : null; }
private void EmitLogicalNot(UnaryExpression node) { Expression operand = node.Operand; operand.Accept(this); IType typeOnStack = PopType(); bool notContext = true; if (IsBoolOrInt(typeOnStack)) { EmitIntNot(); } else if (EmitToBoolIfNeeded(operand, ref notContext)) { if (!notContext) //we are in a not context and emit to bool is also in a not context EmitIntNot();//so we do not need any not (false && false => true) } else { EmitGenericNot(); } PushBool(); }
void EmitIndirection(UnaryExpression node) { node.Operand.Accept(this); if (node.Operand.NodeType != NodeType.ReferenceExpression && node.ParentNode.NodeType != NodeType.MemberReferenceExpression) { //pointer arithmetic, need to load the address IType et = PeekTypeOnStack().ElementType; OpCode code = GetLoadRefParamCode(et); if (code == OpCodes.Ldobj) _il.Emit(code, GetSystemType(et)); else _il.Emit(code); PopType(); PushType(et); } }
void EmitBranch(bool branchOnTrue, UnaryExpression expression, Label label) { if (UnaryOperatorType.LogicalNot == expression.Operator) { EmitBranch(!branchOnTrue, expression.Operand, label); } else { EmitDefaultBranch(branchOnTrue, expression, label); } }
public override bool EnterUnaryExpression(UnaryExpression node) { if (AstUtil.IsPostUnaryOperator(node.Operator) && NodeType.ExpressionStatement == node.ParentNode.NodeType) { // nothing to do, a post operator inside a statement // behaves just like its equivalent pre operator node.Operator = GetRelatedPreOperator(node.Operator); } return true; }
private void EmitOnesComplement(UnaryExpression node) { node.Operand.Accept(this); _il.Emit(OpCodes.Not); }
void ExpandIncrementDecrement(UnaryExpression node) { var expansion = IsArraySlicing(node.Operand) ? ExpandIncrementDecrementArraySlicing(node) : ExpandSimpleIncrementDecrement(node); node.ParentNode.Replace(node, expansion); Visit(expansion); }
private void EmitUnaryNegation(UnaryExpression node) { IType operandType = GetExpressionType(node.Operand); if (!_checked || !TypeSystemServices.IsIntegerNumber(operandType)) { //a single/double unary negation never overflow node.Operand.Accept(this); _il.Emit(OpCodes.Neg); } else { _il.Emit(OpCodes.Ldc_I4_0); if (operandType == TypeSystemServices.LongType || operandType == TypeSystemServices.ULongType) _il.Emit(OpCodes.Conv_I8); node.Operand.Accept(this); _il.Emit(TypeSystemServices.IsSignedNumber(operandType) ? OpCodes.Sub_Ovf : OpCodes.Sub_Ovf_Un); if (operandType != TypeSystemServices.LongType && operandType != TypeSystemServices.ULongType) EmitCastIfNeeded(operandType, TypeSystemServices.IntType); } }
Expression ExpandSimpleIncrementDecrement(UnaryExpression node) { var oldValue = DeclareOldValueTempIfNeeded(node); var type = GetExpressionType(node.Operand); var addition = CodeBuilder.CreateBoundBinaryExpression( type, GetEquivalentBinaryOperator(node.Operator), CloneOrAssignToTemp(oldValue, node.Operand), CodeBuilder.CreateIntegerLiteral(1)); var assign = CodeBuilder.CreateAssignment( node.LexicalInfo, node.Operand, addition); // Resolve operator overloads if any BindArithmeticOperator(addition); return oldValue == null ? (Expression) assign : CodeBuilder.CreateEvalInvocation( node.LexicalInfo, assign, CodeBuilder.CreateReference(oldValue)); }
protected void exception_handler( TryStatement t ) //throws RecognitionException, TokenStreamException { IToken c = null; IToken x = null; IToken u = null; ExceptionHandler eh = null; TypeReference tr = null; Expression e = null; try { // for error handling c = LT(1); match(EXCEPT); { switch ( LA(1) ) { case ID: { x = LT(1); match(ID); break; } case AS: case IF: case UNLESS: case COLON: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } { switch ( LA(1) ) { case AS: { match(AS); tr=type_reference(); break; } case IF: case UNLESS: case COLON: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } { switch ( LA(1) ) { case IF: case UNLESS: { { switch ( LA(1) ) { case IF: { match(IF); break; } case UNLESS: { u = LT(1); match(UNLESS); break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } e=boolean_expression(); break; } case COLON: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } if (0==inputState.guessing) { eh = new ExceptionHandler(ToLexicalInfo(c)); eh.Declaration = new Declaration(); eh.Declaration.Type = tr; if (x != null) { eh.Declaration.LexicalInfo = ToLexicalInfo(x); eh.Declaration.Name = x.getText(); } else { eh.Declaration.Name = null; eh.Flags |= ExceptionHandlerFlags.Anonymous; } if (tr != null) { eh.Declaration.LexicalInfo = tr.LexicalInfo; } else if (x != null) { eh.Declaration.LexicalInfo = eh.LexicalInfo; } if(tr == null) { eh.Flags |= ExceptionHandlerFlags.Untyped; } if (e != null) { if(u != null) { UnaryExpression not = new UnaryExpression(ToLexicalInfo(u)); not.Operator = UnaryOperatorType.LogicalNot; not.Operand = e; e = not; } eh.FilterCondition = e; eh.Flags |= ExceptionHandlerFlags.Filter; } } compound_stmt(eh.Block); if (0==inputState.guessing) { t.ExceptionHandlers.Add(eh); } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex, "exception_handler"); recover(ex,tokenSet_106_); } else { throw ex; } } }
private void LeaveAddressOf(UnaryExpression node) { IType dataType = GetExpressionType(node.Operand); if (dataType.IsArray) //if array reference take address of first element { dataType = dataType.ElementType; node.Replace(node.Operand, new SlicingExpression(node.Operand, new IntegerLiteralExpression(0))); BindExpressionType(node.Operand, dataType); } if (TypeSystemServices.IsPointerCompatible(dataType)) { node.Entity = dataType.MakePointerType(); BindExpressionType(node, dataType.MakePointerType()); return; } BindExpressionType(node, TypeSystemServices.ErrorEntity); Error(CompilerErrorFactory.PointerIncompatibleType(node.Operand, dataType)); }
protected Expression not_expression() //throws RecognitionException, TokenStreamException { Expression e; IToken nt = null; e = null; try { // for error handling { switch ( LA(1) ) { case NOT: { { nt = LT(1); match(NOT); e=not_expression(); } break; } case ESEPARATOR: case CAST: case CHAR: case FALSE: case NULL: case SELF: case SUPER: case THEN: case TRUE: case TYPEOF: case TRIPLE_QUOTED_STRING: case LPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case SPLICE_BEGIN: case DOT: case LBRACE: case QQ_BEGIN: case SUBTRACT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { e=assignment_expression(); break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } if (0==inputState.guessing) { if (nt != null) { UnaryExpression ue = new UnaryExpression(ToLexicalInfo(nt)); ue.Operator = UnaryOperatorType.LogicalNot; ue.Operand = e; e = ue; } } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex, "not_expression"); recover(ex,tokenSet_107_); } else { throw ex; } } return e; }
private void LeaveIndirection(UnaryExpression node) { if (TypeSystemServices.IsError(node.Operand)) return; IType dataType = GetExpressionType(node.Operand).ElementType; if (null != dataType && TypeSystemServices.IsPointerCompatible(dataType)) { node.Entity = node.Operand.Entity; BindExpressionType(node, dataType); return; } BindExpressionType(node, TypeSystemServices.ErrorEntity); Error(CompilerErrorFactory.PointerIncompatibleType(node.Operand, dataType)); }
protected Expression unary_expression() //throws RecognitionException, TokenStreamException { Expression e; IToken sub = null; IToken inc = null; IToken dec = null; IToken oc = null; IToken explode = null; IToken postinc = null; IToken postdec = null; e = null; IToken op = null; UnaryOperatorType uOperator = UnaryOperatorType.None; try { // for error handling { bool synPredMatched545 = false; if (((LA(1)==SUBTRACT||LA(1)==LONG||LA(1)==INT) && (tokenSet_76_.member(LA(2))))) { int _m545 = mark(); synPredMatched545 = true; inputState.guessing++; try { { match(SUBTRACT); match(LONG); } } catch (RecognitionException) { synPredMatched545 = false; } rewind(_m545); inputState.guessing--; } if ( synPredMatched545 ) { { e=integer_literal(); } } else if ((tokenSet_124_.member(LA(1))) && (tokenSet_116_.member(LA(2)))) { { { switch ( LA(1) ) { case SUBTRACT: { sub = LT(1); match(SUBTRACT); if (0==inputState.guessing) { op = sub; uOperator = UnaryOperatorType.UnaryNegation; } break; } case INCREMENT: { inc = LT(1); match(INCREMENT); if (0==inputState.guessing) { op = inc; uOperator = UnaryOperatorType.Increment; } break; } case DECREMENT: { dec = LT(1); match(DECREMENT); if (0==inputState.guessing) { op = dec; uOperator = UnaryOperatorType.Decrement; } break; } case ONES_COMPLEMENT: { oc = LT(1); match(ONES_COMPLEMENT); if (0==inputState.guessing) { op = oc; uOperator = UnaryOperatorType.OnesComplement; } break; } case MULTIPLY: { explode = LT(1); match(MULTIPLY); if (0==inputState.guessing) { op = explode; uOperator = UnaryOperatorType.Explode; } break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } e=unary_expression(); } } else if ((tokenSet_37_.member(LA(1))) && (tokenSet_125_.member(LA(2)))) { { e=slicing_expression(); { if ((LA(1)==INCREMENT) && (tokenSet_76_.member(LA(2)))) { postinc = LT(1); match(INCREMENT); if (0==inputState.guessing) { op = postinc; uOperator = UnaryOperatorType.PostIncrement; } } else if ((LA(1)==DECREMENT) && (tokenSet_76_.member(LA(2)))) { postdec = LT(1); match(DECREMENT); if (0==inputState.guessing) { op = postdec; uOperator = UnaryOperatorType.PostDecrement; } } else if ((tokenSet_76_.member(LA(1))) && (tokenSet_15_.member(LA(2)))) { } else { throw new NoViableAltException(LT(1), getFilename()); } } } } else { throw new NoViableAltException(LT(1), getFilename()); } } if (0==inputState.guessing) { if (null != op) { UnaryExpression ue = new UnaryExpression(ToLexicalInfo(op)); ue.Operator = uOperator; ue.Operand = e; e = ue; } } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex, "unary_expression"); recover(ex,tokenSet_76_); } else { throw ex; } } return e; }
private void LeaveOnesComplement(UnaryExpression node) { if (IsPrimitiveOnesComplementOperand(node.Operand)) BindExpressionType(node, GetExpressionType(node.Operand)); else ProcessOperatorOverload(node); }
protected Expression safe_atom() //throws RecognitionException, TokenStreamException { Expression e; e = null; UnaryExpression ue = null; try { // for error handling e=atom(); { switch ( LA(1) ) { case NULLABLE_SUFFIX: { match(NULLABLE_SUFFIX); if (0==inputState.guessing) { ue = new UnaryExpression(e.LexicalInfo); ue.Operator = UnaryOperatorType.SafeAccess; ue.Operand = e; e = ue; } break; } case EOF: case DEDENT: case ESEPARATOR: case EOL: case ASSEMBLY_ATTRIBUTE_BEGIN: case MODULE_ATTRIBUTE_BEGIN: case ABSTRACT: case AND: case AS: case BREAK: case CONTINUE: case CALLABLE: case CAST: case CHAR: case CLASS: case CONSTRUCTOR: case DEF: case DESTRUCTOR: case DO: case ELSE: case ENUM: case EVENT: case FINAL: case FOR: case FALSE: case GOTO: case INTERFACE: case INTERNAL: case IS: case ISA: case IF: case IN: case NEW: case NOT: case NULL: case OF: case OR: case OVERRIDE: case PARTIAL: case PUBLIC: case PROTECTED: case PRIVATE: case RAISE: case RETURN: case SELF: case SUPER: case STATIC: case STRUCT: case THEN: case TRY: case TRANSIENT: case TRUE: case TYPEOF: case UNLESS: case VIRTUAL: case WHILE: case YIELD: case TRIPLE_QUOTED_STRING: case EOS: case LPAREN: case RPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case RBRACK: case ASSIGN: case COMMA: case SPLICE_BEGIN: case DOT: case COLON: case EXPONENTIATION: case BITWISE_OR: case LBRACE: case RBRACE: case QQ_BEGIN: case QQ_END: case INPLACE_BITWISE_OR: case INPLACE_EXCLUSIVE_OR: case INPLACE_BITWISE_AND: case INPLACE_SHIFT_LEFT: case INPLACE_SHIFT_RIGHT: case CMP_OPERATOR: case GREATER_THAN: case LESS_THAN: case ADD: case SUBTRACT: case EXCLUSIVE_OR: case DIVISION: case MODULUS: case BITWISE_AND: case SHIFT_LEFT: case SHIFT_RIGHT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex, "safe_atom"); recover(ex,tokenSet_75_); } else { throw ex; } } return e; }
public override void LeaveUnaryExpression(UnaryExpression node) { switch (node.Operator) { case UnaryOperatorType.Explode: { LeaveExplodeExpression(node); break; } case UnaryOperatorType.LogicalNot: { LeaveLogicalNot(node); break; } case UnaryOperatorType.Increment: case UnaryOperatorType.PostIncrement: case UnaryOperatorType.Decrement: case UnaryOperatorType.PostDecrement: { LeaveIncrementDecrement(node); break; } case UnaryOperatorType.UnaryNegation: { LeaveUnaryNegation(node); break; } case UnaryOperatorType.OnesComplement: { LeaveOnesComplement(node); break; } case UnaryOperatorType.AddressOf: { LeaveAddressOf(node); break; } case UnaryOperatorType.Indirection: { LeaveIndirection(node); break; } default: { NotImplemented(node, "unary operator not supported"); break; } } }
protected Expression slicing_expression() //throws RecognitionException, TokenStreamException { Expression e; IToken lbrack = null; IToken oft = null; IToken begin = null; IToken lparen = null; e = null; SlicingExpression se = null; MethodInvocationExpression mce = null; IToken memberName = null; TypeReference genericArgument = null; TypeReferenceCollection genericArguments = null; Expression nameSplice = null; Expression initializer = null; UnaryExpression ue = null; try { // for error handling e=safe_atom(); { // ( ... )* for (;;) { if ((LA(1)==LBRACK) && (tokenSet_72_.member(LA(2)))) { { lbrack = LT(1); match(LBRACK); { switch ( LA(1) ) { case OF: { { match(OF); if (0==inputState.guessing) { GenericReferenceExpression gre = new GenericReferenceExpression(ToLexicalInfo(lbrack)); gre.Target = e; e = gre; genericArguments = gre.GenericArguments; } type_reference_list(genericArguments); } break; } case ESEPARATOR: case CAST: case CHAR: case FALSE: case NOT: case NULL: case SELF: case SUPER: case THEN: case TRUE: case TYPEOF: case TRIPLE_QUOTED_STRING: case LPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case SPLICE_BEGIN: case DOT: case COLON: case LBRACE: case QQ_BEGIN: case SUBTRACT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { if (0==inputState.guessing) { se = new SlicingExpression(ToLexicalInfo(lbrack)); se.Target = e; e = se; } slice(se); { // ( ... )* for (;;) { if ((LA(1)==COMMA)) { match(COMMA); slice(se); } else { goto _loop591_breakloop; } } _loop591_breakloop: ; } // ( ... )* break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } match(RBRACK); { switch ( LA(1) ) { case NULLABLE_SUFFIX: { match(NULLABLE_SUFFIX); if (0==inputState.guessing) { ue = new UnaryExpression(e.LexicalInfo); ue.Operator = UnaryOperatorType.SafeAccess; ue.Operand = e; e = ue; } break; } case EOF: case DEDENT: case ESEPARATOR: case EOL: case ASSEMBLY_ATTRIBUTE_BEGIN: case MODULE_ATTRIBUTE_BEGIN: case ABSTRACT: case AND: case AS: case BREAK: case CONTINUE: case CALLABLE: case CAST: case CHAR: case CLASS: case CONSTRUCTOR: case DEF: case DESTRUCTOR: case DO: case ELSE: case ENUM: case EVENT: case FINAL: case FOR: case FALSE: case GOTO: case INTERFACE: case INTERNAL: case IS: case ISA: case IF: case IN: case NEW: case NOT: case NULL: case OF: case OR: case OVERRIDE: case PARTIAL: case PUBLIC: case PROTECTED: case PRIVATE: case RAISE: case RETURN: case SELF: case SUPER: case STATIC: case STRUCT: case THEN: case TRY: case TRANSIENT: case TRUE: case TYPEOF: case UNLESS: case VIRTUAL: case WHILE: case YIELD: case TRIPLE_QUOTED_STRING: case EOS: case LPAREN: case RPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case RBRACK: case ASSIGN: case COMMA: case SPLICE_BEGIN: case DOT: case COLON: case EXPONENTIATION: case BITWISE_OR: case LBRACE: case RBRACE: case QQ_BEGIN: case QQ_END: case INPLACE_BITWISE_OR: case INPLACE_EXCLUSIVE_OR: case INPLACE_BITWISE_AND: case INPLACE_SHIFT_LEFT: case INPLACE_SHIFT_RIGHT: case CMP_OPERATOR: case GREATER_THAN: case LESS_THAN: case ADD: case SUBTRACT: case EXCLUSIVE_OR: case DIVISION: case MODULUS: case BITWISE_AND: case SHIFT_LEFT: case SHIFT_RIGHT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } } } else if ((LA(1)==OF)) { { oft = LT(1); match(OF); genericArgument=type_reference(); if (0==inputState.guessing) { GenericReferenceExpression gre = new GenericReferenceExpression(ToLexicalInfo(oft)); gre.Target = e; e = gre; gre.GenericArguments.Add(genericArgument); } } } else if ((LA(1)==DOT) && (tokenSet_33_.member(LA(2)))) { { match(DOT); { switch ( LA(1) ) { case EVENT: case GET: case INTERNAL: case PUBLIC: case PROTECTED: case REF: case SET: case YIELD: case ID: { { memberName=member(); if (0==inputState.guessing) { e = MemberReferenceForToken(e, memberName); } } break; } case SPLICE_BEGIN: { { begin = LT(1); match(SPLICE_BEGIN); nameSplice=atom(); if (0==inputState.guessing) { e = new SpliceMemberReferenceExpression( ToLexicalInfo(begin), e, nameSplice); } } break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } { switch ( LA(1) ) { case NULLABLE_SUFFIX: { match(NULLABLE_SUFFIX); if (0==inputState.guessing) { ue = new UnaryExpression(e.LexicalInfo); ue.Operator = UnaryOperatorType.SafeAccess; ue.Operand = e; e = ue; } break; } case EOF: case DEDENT: case ESEPARATOR: case EOL: case ASSEMBLY_ATTRIBUTE_BEGIN: case MODULE_ATTRIBUTE_BEGIN: case ABSTRACT: case AND: case AS: case BREAK: case CONTINUE: case CALLABLE: case CAST: case CHAR: case CLASS: case CONSTRUCTOR: case DEF: case DESTRUCTOR: case DO: case ELSE: case ENUM: case EVENT: case FINAL: case FOR: case FALSE: case GOTO: case INTERFACE: case INTERNAL: case IS: case ISA: case IF: case IN: case NEW: case NOT: case NULL: case OF: case OR: case OVERRIDE: case PARTIAL: case PUBLIC: case PROTECTED: case PRIVATE: case RAISE: case RETURN: case SELF: case SUPER: case STATIC: case STRUCT: case THEN: case TRY: case TRANSIENT: case TRUE: case TYPEOF: case UNLESS: case VIRTUAL: case WHILE: case YIELD: case TRIPLE_QUOTED_STRING: case EOS: case LPAREN: case RPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case RBRACK: case ASSIGN: case COMMA: case SPLICE_BEGIN: case DOT: case COLON: case EXPONENTIATION: case BITWISE_OR: case LBRACE: case RBRACE: case QQ_BEGIN: case QQ_END: case INPLACE_BITWISE_OR: case INPLACE_EXCLUSIVE_OR: case INPLACE_BITWISE_AND: case INPLACE_SHIFT_LEFT: case INPLACE_SHIFT_RIGHT: case CMP_OPERATOR: case GREATER_THAN: case LESS_THAN: case ADD: case SUBTRACT: case EXCLUSIVE_OR: case DIVISION: case MODULUS: case BITWISE_AND: case SHIFT_LEFT: case SHIFT_RIGHT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } } } else if ((LA(1)==LPAREN) && (tokenSet_73_.member(LA(2)))) { { lparen = LT(1); match(LPAREN); if (0==inputState.guessing) { mce = new MethodInvocationExpression(ToLexicalInfo(lparen)); mce.Target = e; e = mce; } { switch ( LA(1) ) { case ESEPARATOR: case CAST: case CHAR: case FALSE: case NOT: case NULL: case SELF: case SUPER: case THEN: case TRUE: case TYPEOF: case TRIPLE_QUOTED_STRING: case LPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case SPLICE_BEGIN: case DOT: case LBRACE: case QQ_BEGIN: case SUBTRACT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { argument(mce); { // ( ... )* for (;;) { if ((LA(1)==COMMA)) { match(COMMA); argument(mce); } else { goto _loop602_breakloop; } } _loop602_breakloop: ; } // ( ... )* break; } case RPAREN: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } match(RPAREN); { switch ( LA(1) ) { case NULLABLE_SUFFIX: { match(NULLABLE_SUFFIX); if (0==inputState.guessing) { ue = new UnaryExpression(e.LexicalInfo); ue.Operator = UnaryOperatorType.SafeAccess; ue.Operand = e; e = ue; } break; } case EOF: case DEDENT: case ESEPARATOR: case EOL: case ASSEMBLY_ATTRIBUTE_BEGIN: case MODULE_ATTRIBUTE_BEGIN: case ABSTRACT: case AND: case AS: case BREAK: case CONTINUE: case CALLABLE: case CAST: case CHAR: case CLASS: case CONSTRUCTOR: case DEF: case DESTRUCTOR: case DO: case ELSE: case ENUM: case EVENT: case FINAL: case FOR: case FALSE: case GOTO: case INTERFACE: case INTERNAL: case IS: case ISA: case IF: case IN: case NEW: case NOT: case NULL: case OF: case OR: case OVERRIDE: case PARTIAL: case PUBLIC: case PROTECTED: case PRIVATE: case RAISE: case RETURN: case SELF: case SUPER: case STATIC: case STRUCT: case THEN: case TRY: case TRANSIENT: case TRUE: case TYPEOF: case UNLESS: case VIRTUAL: case WHILE: case YIELD: case TRIPLE_QUOTED_STRING: case EOS: case LPAREN: case RPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case RBRACK: case ASSIGN: case COMMA: case SPLICE_BEGIN: case DOT: case COLON: case EXPONENTIATION: case BITWISE_OR: case LBRACE: case RBRACE: case QQ_BEGIN: case QQ_END: case INPLACE_BITWISE_OR: case INPLACE_EXCLUSIVE_OR: case INPLACE_BITWISE_AND: case INPLACE_SHIFT_LEFT: case INPLACE_SHIFT_RIGHT: case CMP_OPERATOR: case GREATER_THAN: case LESS_THAN: case ADD: case SUBTRACT: case EXCLUSIVE_OR: case DIVISION: case MODULUS: case BITWISE_AND: case SHIFT_LEFT: case SHIFT_RIGHT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } { if ((LA(1)==LBRACE) && (tokenSet_74_.member(LA(2)))) { { bool synPredMatched607 = false; if (((LA(1)==LBRACE) && (tokenSet_74_.member(LA(2))))) { int _m607 = mark(); synPredMatched607 = true; inputState.guessing++; try { { hash_literal_test(); } } catch (RecognitionException) { synPredMatched607 = false; } rewind(_m607); inputState.guessing--; } if ( synPredMatched607 ) { initializer=hash_literal(); } else if ((LA(1)==LBRACE) && (tokenSet_74_.member(LA(2)))) { initializer=list_initializer(); } else { throw new NoViableAltException(LT(1), getFilename()); } } if (0==inputState.guessing) { e = new CollectionInitializationExpression(e, initializer); } } else if ((tokenSet_75_.member(LA(1))) && (tokenSet_15_.member(LA(2)))) { } else { throw new NoViableAltException(LT(1), getFilename()); } } } } else { goto _loop608_breakloop; } } _loop608_breakloop: ; } // ( ... )* } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex, "slicing_expression"); recover(ex,tokenSet_76_); } else { throw ex; } } return e; }
bool ResolveOperator(UnaryExpression node) { MethodInvocationExpression mie = new MethodInvocationExpression(node.LexicalInfo); mie.Arguments.Add(node.Operand.CloneNode()); string operatorName = AstUtil.GetMethodNameForOperator(node.Operator); IType operand = GetExpressionType(node.Operand); if (ResolveOperator(node, operand, operatorName, mie)) { return true; } return ResolveOperator(node, TypeSystemServices.RuntimeServicesType, operatorName, mie); }
protected virtual void LeaveExplodeExpression(UnaryExpression node) { IType type = GetConcreteExpressionType(node.Operand); if (!type.IsArray) Error(node, CompilerErrorFactory.ExplodedExpressionMustBeArray(node)); else BindExpressionType(node, type); }