public void Visit(AnonymousClassExpression x) { }
public AbstractType Visit(AnonymousClassExpression x) { return(TypeDeclarationResolver.HandleNodeMatch(x.AnonymousClass, ctxt, typeBase: x)); }
IExpression NewExpression(IBlockNode Scope = null) { Expect(New); var startLoc = t.Location; IExpression[] newArgs = null; // NewArguments if (laKind == (OpenParenthesis)) { Step(); if (laKind != (CloseParenthesis)) newArgs = ArgumentList(Scope).ToArray(); Expect(CloseParenthesis); } /* * If there occurs a class keyword here, interpretate it as an anonymous class definition * http://digitalmars.com/d/2.0/expression.html#NewExpression * * NewArguments ClassArguments BaseClasslist_opt { DeclDefs } * * http://digitalmars.com/d/2.0/class.html#anonymous * NewAnonClassExpression: new PerenArgumentListopt class PerenArgumentList_opt SuperClass_opt InterfaceClasses_opt ClassBody PerenArgumentList: (ArgumentList) * */ if (laKind == (Class)) { Step(); var ac = new AnonymousClassExpression(); ac.NewArguments = newArgs; // ClassArguments if (laKind == (OpenParenthesis)) { Step(); if (laKind == (CloseParenthesis)) Step(); else ac.ClassArguments = ArgumentList(Scope).ToArray(); } var anclass = new DClassLike(Class) { IsAnonymousClass=true, Name = "(Anonymous Class)" }; // BaseClasslist_opt if (laKind == (Colon)) { //TODO : Add base classes to expression BaseClassList(anclass); } // SuperClass_opt InterfaceClasses_opt else if (laKind != OpenCurlyBrace) BaseClassList(anclass,false); ClassBody(anclass); ac.AnonymousClass = anclass; ac.Location = startLoc; ac.EndLocation = t.EndLocation; if (Scope != null) Scope.Add(ac.AnonymousClass); return ac; } // NewArguments Type else { var nt = BasicType(); while (IsBasicType2()) { var bt=BasicType2(); if (bt == null) break; bt.InnerDeclaration = nt; nt = bt; } var initExpr = new NewExpression() { NewArguments = newArgs, Type=nt, Location=startLoc }; List<IExpression> args; var ad=nt as ArrayDecl; if ((ad == null || ad.ClampsEmpty) && laKind == OpenParenthesis) { Step (); if (laKind != CloseParenthesis) args = ArgumentList (Scope); else args = new List<IExpression> (); if (Expect (CloseParenthesis)) initExpr.EndLocation = t.EndLocation; else initExpr.EndLocation = CodeLocation.Empty; if (ad != null) { if (args.Count == 0) { SemErr (CloseParenthesis, "Size for the rightmost array dimension needed"); initExpr.EndLocation = t.EndLocation; return initExpr; } while (ad != null) { if (args.Count == 0) break; ad.ClampsEmpty = false; ad.KeyType = null; ad.KeyExpression = args [args.Count - 1]; args.RemoveAt (args.Count - 1); ad = ad.InnerDeclaration as ArrayDecl; } } } else { initExpr.EndLocation = t.EndLocation; args = new List<IExpression> (); } ad = nt as ArrayDecl; if (ad != null && ad.KeyExpression == null) { if (ad.KeyType != null) SemErr(ad.KeyType is DTokenDeclaration ? (ad.KeyType as DTokenDeclaration).Token : CloseSquareBracket, "Size of array expected, not type " + ad.KeyType); } initExpr.Arguments = args.ToArray(); return initExpr; } }
public ISymbolValue Visit(AnonymousClassExpression x) { //TODO return(null); }
public ISymbolValue Visit(AnonymousClassExpression x) { //TODO return null; }
IExpression NewExpression(IBlockNode Scope = null) { Expect(New); var startLoc = t.Location; IExpression[] newArgs = null; // NewArguments if (laKind == (OpenParenthesis)) { Step(); if (laKind != (CloseParenthesis)) newArgs = ArgumentList(Scope).ToArray(); Expect(CloseParenthesis); } /* * If there occurs a class keyword here, interpretate it as an anonymous class definition * http://digitalmars.com/d/2.0/expression.html#NewExpression * * NewArguments ClassArguments BaseClasslist_opt { DeclDefs } * * http://digitalmars.com/d/2.0/class.html#anonymous * NewAnonClassExpression: new PerenArgumentListopt class PerenArgumentList_opt SuperClass_opt InterfaceClasses_opt ClassBody PerenArgumentList: (ArgumentList) * */ if (laKind == (Class)) { Step(); var ac = new AnonymousClassExpression(); LastParsedObject = ac; ac.NewArguments = newArgs; // ClassArguments if (laKind == (OpenParenthesis)) { Step(); if (laKind == (CloseParenthesis)) Step(); else ac.ClassArguments = ArgumentList(Scope).ToArray(); } var anclass = new DClassLike(Class) { IsAnonymous=true }; LastParsedObject = anclass; anclass.Name = "(Anonymous Class)"; // BaseClasslist_opt if (laKind == (Colon)) //TODO : Add base classes to expression anclass.BaseClasses = BaseClassList(); // SuperClass_opt InterfaceClasses_opt else if (laKind != OpenCurlyBrace) anclass.BaseClasses = BaseClassList(false); //TODO: Add the parsed results to node tree somehow ClassBody(anclass); ac.AnonymousClass = anclass; ac.Location = startLoc; ac.EndLocation = t.EndLocation; if (Scope != null) Scope.Add(ac.AnonymousClass); return ac; } // NewArguments Type else { var initExpr = new NewExpression() { NewArguments = newArgs, Type = BasicType(), IsArrayArgument = laKind == OpenSquareBracket, Location=startLoc }; LastParsedObject = initExpr; var args = new List<IExpression>(); while (laKind == OpenSquareBracket) { Step(); if(laKind!=CloseSquareBracket) args.Add(AssignExpression(Scope)); Expect(CloseSquareBracket); } if (laKind == (OpenParenthesis)) { Step(); if (laKind != CloseParenthesis) args = ArgumentList(Scope); Expect(CloseParenthesis); } initExpr.Arguments = args.ToArray(); initExpr.EndLocation = t.EndLocation; return initExpr; } }
public AbstractType Visit(AnonymousClassExpression x) { throw new NotImplementedException(); }