Exemplo n.º 1
0
 public static TypeReference Lift(TypeofExpression e)
 {
     if (e == null)
     {
         return(null);
     }
     return(e.Type.CloneNode());
 }
 public override void OnReferenceExpression(ReferenceExpression node)
 {
     if (TypeInference.IsTypeLiteral(node))
     {
         TypeofExpression typeofExpression = new TypeofExpression(LexicalInfo.Empty);
         TypeReference typeReference = typeofExpression.Type = TypeReference.Lift(node);
         this.ReplaceCurrentNode(typeofExpression);
     }
 }
Exemplo n.º 3
0
 B.TypeReference ConvertTypeReference(B.Expression expr)
 {
     B.TypeofExpression te = expr as B.TypeofExpression;
     if (te != null)
     {
         return(te.Type);
     }
     if (expr is B.ReferenceExpression)
     {
         return(new B.SimpleTypeReference(expr.ToCodeString()));
     }
     AddError(expr.LexicalInfo, "Expected type, but found expression.");
     return(null);
 }
Exemplo n.º 4
0
        override public object Clone()
        {
            TypeofExpression clone = new TypeofExpression();

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._isSynthetic       = _isSynthetic;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }
            clone._expressionType = _expressionType;
            if (null != _type)
            {
                clone._type = _type.Clone() as TypeReference;
                clone._type.InitializeParent(clone);
            }
            return(clone);
        }
Exemplo n.º 5
0
        override public object Clone()
        {
            TypeofExpression clone = (TypeofExpression)FormatterServices.GetUninitializedObject(typeof(TypeofExpression));

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }

            clone._expressionType = _expressionType;
            if (null != _type)
            {
                clone._type = _type.Clone() as TypeReference;
                clone._type.InitializeParent(clone);
            }
            return(clone);
        }
Exemplo n.º 6
0
		public override void OnTypeofExpression(TypeofExpression node)
		{
			MakeResult(projectContent.SystemTypes.Type);
		}
Exemplo n.º 7
0
	protected Expression  typeof_expression() //throws RecognitionException, TokenStreamException
{
		Expression e;
		
		IToken  t = null;
		
				e = null;
				TypeReference tr = null;
			
		
		try {      // for error handling
			t = LT(1);
			match(TYPEOF);
			match(LPAREN);
			tr=type_reference();
			match(RPAREN);
			if (0==inputState.guessing)
			{
				
						e = new TypeofExpression(ToLexicalInfo(t), tr);
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "typeof_expression");
				recover(ex,tokenSet_44_);
			}
			else
			{
				throw ex;
			}
		}
		return e;
	}
Exemplo n.º 8
0
		public override void OnTypeofExpression(TypeofExpression node)
		{
			_expression = new CodeTypeOfExpression(ConvTypeRef(node.Type));
		}
Exemplo n.º 9
0
		public static TypeReference Lift(TypeofExpression e)
		{
			if (e == null) return null;
			return e.Type.CloneNode();
		}
Exemplo n.º 10
0
 public override void OnTypeofExpression(TypeofExpression node)
 {
     Write("typeof(");
     Visit(node.Type);
     Write(")");
 }
Exemplo n.º 11
0
		override public object Clone()
		{
		
			TypeofExpression clone = new TypeofExpression();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			clone._expressionType = _expressionType;
			if (null != _type)
			{
				clone._type = _type.Clone() as TypeReference;
				clone._type.InitializeParent(clone);
			}
			return clone;


		}
Exemplo n.º 12
0
 public Expression CreateTypeofExpression(IType type)
 {
     var expression = new TypeofExpression();
     expression.Type = CreateTypeReference(type);
     expression.ExpressionType = TypeSystemServices.TypeType;
     expression.Entity = type;
     return expression;
 }
Exemplo n.º 13
0
 protected Expression typeof_with_typeref()
 {
     Expression expression = null;
     IToken token = null;
     try
     {
         token = this.LT(1);
         this.match(0x2c);
         this.match(0x3f);
         TypeReference reference = this.type_reference();
         this.match(0x40);
         if (base.inputState.guessing == 0)
         {
             expression = new TypeofExpression(ToLexicalInfo(token), reference);
         }
     }
     catch (RecognitionException exception)
     {
         if (base.inputState.guessing != 0)
         {
             throw;
         }
         this.reportError(exception);
         this.recover(exception, tokenSet_20_);
         return expression;
     }
     return expression;
 }
Exemplo n.º 14
0
        public Expression comparison()
        {
            Expression expression = null;
            IToken token = null;
            IToken token2 = null;
            IToken token3 = null;
            IToken token4 = null;
            IToken token5 = null;
            IToken token6 = null;
            IToken token7 = null;
            Expression expression2 = null;
            BinaryOperatorType type = 0;
            IToken token8 = null;
            try
            {
                expression = this.shift();
                while (true)
                {
                    if (!tokenSet_56_.member(this.LA(1)) || !tokenSet_57_.member(this.LA(2)))
                    {
                        return expression;
                    }
                    int num = this.LA(1);
                    if ((((num == 0x18) || (num == 0x1c)) || ((num == 0x5b) || (num == 0x5c))) || ((num == 0x5f) || (num == 0x60)))
                    {
                        num = this.LA(1);
                        switch (num)
                        {
                            case 0x1c:
                                token = this.LT(1);
                                this.match(0x1c);
                                this.match(0x18);
                                if (base.inputState.guessing == 0)
                                {
                                    type = 0x1b;
                                    token8 = token;
                                }
                                break;

                            case 0x18:
                                token2 = this.LT(1);
                                this.match(0x18);
                                if (base.inputState.guessing == 0)
                                {
                                    type = 0x1a;
                                    token8 = token2;
                                }
                                break;

                            case 0x5f:
                                token3 = this.LT(1);
                                this.match(0x5f);
                                if (base.inputState.guessing == 0)
                                {
                                    type = 9;
                                    token8 = token3;
                                }
                                break;

                            case 0x60:
                                token4 = this.LT(1);
                                this.match(0x60);
                                if (base.inputState.guessing == 0)
                                {
                                    type = 10;
                                    token8 = token4;
                                }
                                break;

                            case 0x5b:
                                token5 = this.LT(1);
                                this.match(0x5b);
                                if (base.inputState.guessing == 0)
                                {
                                    type = 7;
                                    token8 = token5;
                                }
                                break;

                            case 0x5c:
                                token6 = this.LT(1);
                                this.match(0x5c);
                                if (base.inputState.guessing == 0)
                                {
                                    type = 8;
                                    token8 = token6;
                                }
                                break;

                            default:
                                throw new NoViableAltException(this.LT(1), this.getFilename());
                        }
                        expression2 = this.shift();
                    }
                    else
                    {
                        if (num != 0x1a)
                        {
                            throw new NoViableAltException(this.LT(1), this.getFilename());
                        }
                        token7 = this.LT(1);
                        this.match(0x1a);
                        TypeReference reference = this.type_reference();
                        if (base.inputState.guessing == 0)
                        {
                            type = 0x19;
                            token8 = token7;
                            expression2 = new TypeofExpression(reference.get_LexicalInfo(), reference);
                        }
                    }
                    if (base.inputState.guessing == 0)
                    {
                        BinaryExpression expression3 = new BinaryExpression(ToLexicalInfo(token8));
                        expression3.set_Operator(type);
                        expression3.set_Left(expression);
                        expression3.set_Right(expression2);
                        expression = expression3;
                    }
                }
            }
            catch (RecognitionException exception)
            {
                if (base.inputState.guessing != 0)
                {
                    throw;
                }
                this.reportError(exception);
                this.recover(exception, tokenSet_20_);
                return expression;
            }
            return expression;
        }
Exemplo n.º 15
0
 public override void OnTypeofExpression(TypeofExpression node)
 {
     EmitGetTypeFromHandle(GetSystemType(node.Type));
 }
Exemplo n.º 16
0
 public override void OnMemberReferenceExpression(MemberReferenceExpression node)
 {
     base.OnMemberReferenceExpression(node);
     if (_methodsStack.Count > 0 && node == _methodsStack.Peek().Target)
     {
         ReplaceCurrentNode(node.Target);
     }
     else
     {
         if (node.Target is ReferenceExpression && node.Target != _parameterRef)
         {
             var target = new TypeofExpression()
             {
                 Type = _codeBuilder.CreateTypeReference(node.Target.ExpressionType)
             };
             ReplaceCurrentNode(new MethodInvocationExpression(
                 ReferenceExpression.Lift("Boo.Lang.Runtime.RuntimeServices.StaticPropertyOrField"),
                 target,
                 new StringLiteralExpression(node.Name)));
         }
         else
         {
             ReplaceCurrentNode(new MethodInvocationExpression(
                 ReferenceExpression.Lift("System.Linq.Expressions.Expression.PropertyOrField"),
                 node.Target,
                 new StringLiteralExpression(node.Name)));
         }
     }
 }
Exemplo n.º 17
0
	protected Expression  conditional_expression() //throws RecognitionException, TokenStreamException
{
		Expression e;
		
		IToken  t = null;
		IToken  tgt = null;
		IToken  tlt = null;
		IToken  tnot = null;
		IToken  tis = null;
		IToken  tnint = null;
		IToken  tin = null;
		IToken  tisa = null;
		
				e = null;		
				Expression r = null;
				BinaryOperatorType op = BinaryOperatorType.None;
				IToken token = null;
				TypeReference tr = null;
			
		
		try {      // for error handling
			e=sum();
			{    // ( ... )*
				for (;;)
				{
					if ((tokenSet_115_.member(LA(1))))
					{
						{
							switch ( LA(1) )
							{
							case IS:
							case IN:
							case NOT:
							case CMP_OPERATOR:
							case GREATER_THAN:
							case LESS_THAN:
							{
								{
									{
										switch ( LA(1) )
										{
										case CMP_OPERATOR:
										{
											{
												t = LT(1);
												match(CMP_OPERATOR);
												if (0==inputState.guessing)
												{
													op = OperatorParser.ParseComparison(t.getText()); token = t;
												}
											}
											break;
										}
										case GREATER_THAN:
										{
											{
												tgt = LT(1);
												match(GREATER_THAN);
												if (0==inputState.guessing)
												{
													op = BinaryOperatorType.GreaterThan; token = tgt;
												}
											}
											break;
										}
										case LESS_THAN:
										{
											{
												tlt = LT(1);
												match(LESS_THAN);
												if (0==inputState.guessing)
												{
													op = BinaryOperatorType.LessThan; token = tlt;
												}
											}
											break;
										}
										case NOT:
										{
											{
												tnint = LT(1);
												match(NOT);
												match(IN);
												if (0==inputState.guessing)
												{
													op = BinaryOperatorType.NotMember; token = tnint;
												}
											}
											break;
										}
										case IN:
										{
											{
												tin = LT(1);
												match(IN);
												if (0==inputState.guessing)
												{
													op = BinaryOperatorType.Member; token = tin;
												}
											}
											break;
										}
										default:
											if ((LA(1)==IS) && (LA(2)==NOT))
											{
												{
													tnot = LT(1);
													match(IS);
													match(NOT);
													if (0==inputState.guessing)
													{
														op = BinaryOperatorType.ReferenceInequality; token = tnot;
													}
												}
											}
											else if ((LA(1)==IS) && (tokenSet_116_.member(LA(2)))) {
												{
													tis = LT(1);
													match(IS);
													if (0==inputState.guessing)
													{
														op = BinaryOperatorType.ReferenceEquality; token = tis;
													}
												}
											}
										else
										{
											throw new NoViableAltException(LT(1), getFilename());
										}
										break; }
									}
									r=sum();
								}
								break;
							}
							case ISA:
							{
								{
									tisa = LT(1);
									match(ISA);
									tr=type_reference();
									if (0==inputState.guessing)
									{
										
													op = BinaryOperatorType.TypeTest;
													token = tisa;
													r = new TypeofExpression(tr.LexicalInfo, tr);
												
									}
								}
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
						if (0==inputState.guessing)
						{
							
									BinaryExpression be = new BinaryExpression(ToLexicalInfo(token));
									be.Operator = op;
									be.Left = e;
									be.Right = r;
									e = be;
								
						}
					}
					else
					{
						goto _loop525_breakloop;
					}
					
				}
_loop525_breakloop:				;
			}    // ( ... )*
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "conditional_expression");
				recover(ex,tokenSet_117_);
			}
			else
			{
				throw ex;
			}
		}
		return e;
	}
Exemplo n.º 18
0
 public static TypeReference Lift(TypeofExpression e)
 {
     return e.Type.CloneNode();
 }
Exemplo n.º 19
0
 public override void LeaveTypeofExpression(TypeofExpression node)
 {
     BindExpressionType(node, TypeSystemServices.TypeType);
 }
Exemplo n.º 20
0
 public Expression CreateTypeofExpression(IType type)
 {
     TypeofExpression expression = new TypeofExpression();
     expression.Type = CreateTypeReference(type);
     expression.ExpressionType = _tss.TypeType;
     expression.Entity = type;
     return expression;
 }