public AbstractType Visit(UnaryExpression_Type x) { var uat = x as UnaryExpression_Type; if (uat.Type == null) { return(null); } var types = TypeDeclarationResolver.Resolve(uat.Type, ctxt); ctxt.CheckForSingleResult(types, uat.Type); if (types != null && types.Length != 0) { var res = TypeDeclarationResolver.Resolve(new IdentifierDeclaration(uat.AccessIdentifierHash) { EndLocation = uat.EndLocation }, ctxt, types); ctxt.CheckForSingleResult(res, x); if (res != null && res.Length != 0) { return(res[0]); } } return(null); }
public ISymbolValue Visit(UnaryExpression_Type x) { var uat = x as UnaryExpression_Type; if (uat.Type == null) { return(null); } var types = TypeDeclarationResolver.Resolve(uat.Type, ctxt); ctxt.CheckForSingleResult(types, uat.Type); if (types != null && types.Length != 0) { // First off, try to resolve static properties var statProp = StaticProperties.TryEvalPropertyValue(ValueProvider, types[0], uat.AccessIdentifierHash); if (statProp != null) { return(statProp); } //TODO } return(null); }
ISemantic E(UnaryExpression_Type x) { var uat = x as UnaryExpression_Type; if (uat.Type == null) { return(null); } var types = TypeDeclarationResolver.Resolve(uat.Type, ctxt); ctxt.CheckForSingleResult(types, uat.Type); if (types != null && types.Length != 0) { // First off, try to resolve static properties if (eval) { var statProp = StaticProperties.TryEvalPropertyValue(ValueProvider, types[0], uat.AccessIdentifierHash); if (statProp != null) { return(statProp); } } // If it's not the case, try the conservative way var res = TypeDeclarationResolver.Resolve(new IdentifierDeclaration(uat.AccessIdentifierHash) { EndLocation = uat.EndLocation }, ctxt, types); ctxt.CheckForSingleResult(res, x); if (res != null && res.Length != 0) { return(res[0]); } } return(null); }
public ISymbolValue Visit(UnaryExpression_Type x) { var uat = x as UnaryExpression_Type; if (uat.Type == null) { return(null); } var types = TypeDeclarationResolver.ResolveSingle(uat.Type, ctxt); // First off, try to resolve static properties var statProp = StaticProperties.TryEvalPropertyValue(ValueProvider, types, uat.AccessIdentifierHash); if (statProp != null) { return(statProp); } //TODO return(null); }
public void Visit(UnaryExpression_Type x) { }
ISemantic E(UnaryExpression_Type x) { var uat = x as UnaryExpression_Type; if (uat.Type == null) return null; var types = TypeDeclarationResolver.Resolve(uat.Type, ctxt); ctxt.CheckForSingleResult(types, uat.Type); if (types != null && types.Length != 0) { // First off, try to resolve static properties if(eval) { var statProp = StaticProperties.TryEvalPropertyValue(ValueProvider, types[0], uat.AccessIdentifierHash); if (statProp != null) return statProp; } // If it's not the case, try the conservative way var res = TypeDeclarationResolver.Resolve(new IdentifierDeclaration(uat.AccessIdentifierHash) { EndLocation = uat.EndLocation }, ctxt, types); ctxt.CheckForSingleResult(res, x); if (res != null && res.Length != 0) return res[0]; } return null; }
public void Visit(UnaryExpression_Type x) { }
IExpression PostfixExpression(IBlockNode Scope = null) { IExpression leftExpr = null; /* * Despite the following syntax is an explicit UnaryExpression (see http://dlang.org/expression.html#UnaryExpression), * stuff like (MyType).init[] is actually allowed - so it's obviously a PostfixExpression! (Nov 13 2013) */ // ( Type ) . Identifier if (laKind == OpenParenthesis) { Lexer.StartPeek(); OverPeekBrackets(OpenParenthesis, false); var dotToken = Lexer.CurrentPeekToken; if (Lexer.CurrentPeekToken.Kind == DTokens.Dot && (Peek().Kind == DTokens.Identifier || Lexer.CurrentPeekToken.Kind == EOF)) { var wkParsing = AllowWeakTypeParsing; AllowWeakTypeParsing = true; Lexer.PushLookAheadBackup(); Step(); var startLoc = t.Location; var td = Type(); AllowWeakTypeParsing = wkParsing; /* * (a. -- expression: (a.myProp + 2) / b; * (int. -- must be expression anyway * (const).asdf -- definitely unary expression ("type") * (const). -- also treat it as type accessor */ if (td != null && laKind == CloseParenthesis && Lexer.CurrentPeekToken == dotToken) // Also take it as a type declaration if there's nothing following (see Expression Resolving) { Step(); // Skip to ) if (laKind == DTokens.Dot) { Step(); // Skip to . if ((laKind == DTokens.Identifier && Peek(1).Kind != Not && Peek(1).Kind != OpenParenthesis) || IsEOF) { Lexer.PopLookAheadBackup(); Step(); // Skip to identifier leftExpr = new UnaryExpression_Type() { Type = td, AccessIdentifier = t.Value, Location = startLoc, EndLocation = t.EndLocation }; } else Lexer.RestoreLookAheadBackup(); } else Lexer.RestoreLookAheadBackup(); } else Lexer.RestoreLookAheadBackup(); } } // PostfixExpression if(leftExpr == null) leftExpr = PrimaryExpression(Scope); while (!IsEOF) { switch (laKind) { case Dot: Step(); var pea = new PostfixExpression_Access { PostfixForeExpression = leftExpr }; leftExpr = pea; if (laKind == New) pea.AccessExpression = PostfixExpression(Scope); else if (IsTemplateInstance) pea.AccessExpression = TemplateInstance(Scope); else if (Expect(Identifier)) pea.AccessExpression = new IdentifierExpression(t.Value) { Location = t.Location, EndLocation = t.EndLocation }; else if (IsEOF) pea.AccessExpression = new TokenExpression(DTokens.Incomplete); pea.EndLocation = t.EndLocation; break; case Increment: case Decrement: Step(); var peid = t.Kind == Increment ? (PostfixExpression)new PostfixExpression_Increment() : new PostfixExpression_Decrement(); peid.EndLocation = t.EndLocation; peid.PostfixForeExpression = leftExpr; leftExpr = peid; break; // Function call case OpenParenthesis: Step(); var pemc = new PostfixExpression_MethodCall(); pemc.PostfixForeExpression = leftExpr; leftExpr = pemc; if (laKind == CloseParenthesis) Step(); else { pemc.Arguments = ArgumentList(Scope).ToArray(); Expect(CloseParenthesis); } if(IsEOF) pemc.EndLocation = CodeLocation.Empty; else pemc.EndLocation = t.EndLocation; break; // IndexExpression | SliceExpression case OpenSquareBracket: Step(); if (laKind != CloseSquareBracket) { var firstEx = AssignExpression(Scope); // [ AssignExpression .. AssignExpression ] if (laKind == DoubleDot) { Step(); leftExpr = new PostfixExpression_Slice() { FromExpression = firstEx, PostfixForeExpression = leftExpr, ToExpression = AssignExpression(Scope) }; } // [ ArgumentList ] else if (laKind == CloseSquareBracket || laKind == (Comma)) { var args = new List<IExpression>(); args.Add(firstEx); if (laKind == Comma) { Step(); args.AddRange(ArgumentList(Scope)); } leftExpr = new PostfixExpression_Index() { PostfixForeExpression = leftExpr, Arguments = args.ToArray() }; } } else // Empty array literal = SliceExpression { leftExpr = new PostfixExpression_Slice() { PostfixForeExpression=leftExpr }; } Expect(CloseSquareBracket); if(leftExpr is PostfixExpression) ((PostfixExpression)leftExpr).EndLocation = t.EndLocation; break; default: return leftExpr; } } return leftExpr; }
public ISymbolValue Visit(UnaryExpression_Type x) { var uat = x as UnaryExpression_Type; if (uat.Type == null) return null; var types = TypeDeclarationResolver.Resolve(uat.Type, ctxt); ctxt.CheckForSingleResult(types, uat.Type); if (types != null && types.Length != 0) { // First off, try to resolve static properties var statProp = StaticProperties.TryEvalPropertyValue(ValueProvider, types[0], uat.AccessIdentifierHash); if (statProp != null) return statProp; //TODO } return null; }
IExpression UnaryExpression(IBlockNode Scope = null) { // Note: PowExpressions are handled in PowExpression() if (laKind == (BitwiseAnd) || laKind == (Increment) || laKind == (Decrement) || laKind == (Times) || laKind == (Minus) || laKind == (Plus) || laKind == (Not) || laKind == (Tilde)) { Step(); SimpleUnaryExpression ae = null; switch (t.Kind) { case BitwiseAnd: ae = new UnaryExpression_And(); break; case Increment: ae = new UnaryExpression_Increment(); break; case Decrement: ae = new UnaryExpression_Decrement(); break; case Times: ae = new UnaryExpression_Mul(); break; case Minus: ae = new UnaryExpression_Sub(); break; case Plus: ae = new UnaryExpression_Add(); break; case Tilde: ae = new UnaryExpression_Cat(); break; case Not: ae = new UnaryExpression_Not(); break; } LastParsedObject = ae; ae.Location = t.Location; ae.UnaryExpression = UnaryExpression(Scope); return ae; } // ( Type ) . Identifier if (laKind == OpenParenthesis) { var wkParsing = AllowWeakTypeParsing; AllowWeakTypeParsing = true; var curLA = la; Step(); var td = Type(); AllowWeakTypeParsing = wkParsing; if (td!=null && ((t.Kind!=OpenParenthesis && laKind == CloseParenthesis && Peek(1).Kind == Dot && Peek(2).Kind == Identifier) || (IsEOF || Peek(1).Kind==EOF || Peek(2).Kind==EOF))) // Also take it as a type declaration if there's nothing following (see Expression Resolving) { Step(); // Skip to ) Step(); // Skip to . Step(); // Skip to identifier var accExpr = new UnaryExpression_Type() { Type=td, AccessIdentifier=t.Value }; accExpr.Location = curLA.Location; accExpr.EndLocation = t.EndLocation; return accExpr; } else { // Reset the current token with the earlier one to enable Expression parsing la = curLA; Peek(1); } } // CastExpression if (laKind == (Cast)) { Step(); var ae = new CastExpression { Location= t.Location }; if (Expect(OpenParenthesis)) { if (laKind != CloseParenthesis) // Yes, it is possible that a cast() can contain an empty type! ae.Type = Type(); Expect(CloseParenthesis); } ae.UnaryExpression = UnaryExpression(Scope); ae.EndLocation = t.EndLocation; return ae; } // NewExpression if (laKind == (New)) return NewExpression(Scope); // DeleteExpression if (laKind == (Delete)) { Step(); return new DeleteExpression() { UnaryExpression = UnaryExpression(Scope) }; } // PowExpression var left = PostfixExpression(Scope); if (laKind != Pow) return left; Step(); var pe = new PowExpression(); pe.LeftOperand = left; pe.RightOperand = UnaryExpression(Scope); return pe; }
public ISymbolValue Visit(UnaryExpression_Type x) { var uat = x as UnaryExpression_Type; if (uat.Type == null) return null; var types = TypeDeclarationResolver.ResolveSingle(uat.Type, ctxt); // First off, try to resolve static properties var statProp = StaticProperties.TryEvalPropertyValue(ValueProvider, types, uat.AccessIdentifierHash); if (statProp != null) return statProp; //TODO return null; }