public virtual void Visit(DClassLike n) { VisitBlock(n); foreach (var bc in n.BaseClasses) bc.Accept(this); }
// Only for parsing the base class identifiers! public override void Visit (DClassLike dc) { foreach (var bc in dc.BaseClasses) bc.Accept(this); PushBlock(dc); }
public virtual void Visit(DClassLike n) { VisitBlock(n); foreach (var bc in n.BaseClasses) { bc.Accept(this); } }
// Only for parsing the base class identifiers! public override void Visit(DClassLike dc) { var back = ctxt.ScopedBlock; using(ctxt.Push(dc)) { if(back != ctxt.ScopedBlock) OnScopedBlockChanged (dc); base.Visit(dc); } }
// Only for parsing the base class identifiers! public override void Visit(DClassLike dc) { var back = ctxt.ScopedBlock; if (back != dc) { ctxt.PushNewScope (dc); OnScopedBlockChanged (dc); } base.Visit (dc); if(back != dc) ctxt.Pop (); }
private INode ClassDeclaration(INode Parent) { Expect(Class); var dc = new DClassLike(Class) { Location = t.Location, Description=GetComments(), Parent=Parent }; ApplyAttributes(dc); if (Expect(Identifier)) { dc.Name = t.Value; dc.NameLocation = t.Location; } else if (IsEOF) dc.NameHash = DTokens.IncompleteIdHash; if (laKind == (OpenParenthesis)) TemplateParameterList(dc); // Constraints // http://dlang.org/template.html#ClassTemplateDeclaration if (Constraint (dc)) { // Constraint_opt BaseClassList_opt if (laKind == (Colon)) BaseClassList (dc); } else if (laKind == (Colon)) { // Constraint_opt BaseClassList_opt BaseClassList (dc); Constraint (dc); } ClassBody(dc); dc.EndLocation = t.EndLocation; return dc; }
private IBlockNode InterfaceDeclaration(INode Parent) { Expect(Interface); var dc = new DClassLike() { Location = t.Location, Description = GetComments(), ClassType= DTokens.Interface, Parent=Parent }; LastParsedObject = dc; ApplyAttributes(dc); Expect(Identifier); dc.Name = t.Value; dc.NameLocation = t.Location; if (laKind == (OpenParenthesis)) dc.TemplateParameters = TemplateParameterList(); if (laKind == (If)) dc.TemplateConstraint=Constraint(); if (laKind == (Colon)) dc.BaseClasses = BaseClassList(); // Empty interfaces are allowed if (laKind == Semicolon) Step(); else ClassBody(dc); dc.EndLocation = t.EndLocation; return dc; }
public InterfaceType(DClassLike dc, ISyntaxRegion td, InterfaceType[] baseInterfaces, ReadOnlyCollection<TemplateParameterSymbol> deducedTypes) : base(dc, td, null, baseInterfaces, deducedTypes) { }
static IEnumerable<AbstractType> GetStructMembers(StructType t, ResolutionContext ctxt) { if(lastStructMembersEnlisted == null || lastStructHandled != t.Definition) { lastStructHandled = t.Definition; var children = ItemEnumeration.EnumChildren(t, ctxt, MemberFilter.Variables); lastStructMembersEnlisted = TypeDeclarationResolver.HandleNodeMatches(children, ctxt, t); } return lastStructMembersEnlisted; }
protected InstanceValue(DClassLike Class, AbstractType ClassType) : base(Class, ClassType) { }
/* * American beer is like sex on a boat - F*****g close to water;) */ private INode TemplateDeclaration(INode Parent) { var startLoc = la.Location; // TemplateMixinDeclaration Modifier mixinMod; if (laKind == Mixin){ Step(); mixinMod = new Modifier(Mixin){ Location = t.Location, EndLocation = t.EndLocation }; } else mixinMod = null; Expect(Template); var dc = new DClassLike(Template) { Description=GetComments(), Location=startLoc, Parent=Parent }; ApplyAttributes(dc); if (mixinMod != null) dc.Attributes.Add(mixinMod); if (Expect(Identifier)) { dc.Name = t.Value; dc.NameLocation = t.Location; } else if (IsEOF) dc.NameHash = DTokens.IncompleteIdHash; TemplateParameterList(dc); if (laKind == (If)) Constraint(dc); // [Must not contain a base class list] ClassBody(dc); return dc; }
public InterfaceType(DClassLike dc, ISyntaxRegion td, InterfaceType[] baseInterfaces=null, Dictionary<string, TemplateParameterSymbol> deducedTypes = null) : base(dc, td, null, baseInterfaces, deducedTypes) { }
public ClassType(DClassLike dc, ISyntaxRegion td, TemplateIntermediateType baseType, InterfaceType[] baseInterfaces, ReadOnlyCollection<KeyValuePair<string, TemplateParameterSymbol>> deducedTypes) : base(dc, td, baseType, baseInterfaces, deducedTypes) { }
private void BaseClassList(DClassLike dc,bool ExpectColon=true) { if (ExpectColon) Expect(Colon); var ret = new List<ITypeDeclaration>(); dc.BaseClasses = ret; bool init = true; while (init || laKind == (Comma)) { if (!init) Step(); init = false; if (IsProtectionAttribute() && laKind != (Protected)) Step(); var ids=IdentifierList(); if (ids != null) ret.Add(ids); } if (IsEOF) { if (ret.Count != 0) LastParsedObject = ret[ret.Count - 1]; TrackerVariables.IsParsingBaseClassList = true; TrackerVariables.InitializedNode = dc; } }
private INode AggregateDeclaration(INode Parent) { if (!(laKind == (Union) || laKind == (Struct))) SynErr(t.Kind, "union or struct required"); Step(); var ret = new DClassLike(t.Kind) { Location = t.Location, Description = GetComments(), ClassType=DTokens.Struct, Parent=Parent }; LastParsedObject = ret; ApplyAttributes(ret); // Allow anonymous structs&unions if (laKind == Identifier) { Expect(Identifier); ret.Name = t.Value; ret.NameLocation = t.Location; } if (laKind == (Semicolon)) { Step(); return ret; } // StructTemplateDeclaration if (laKind == (OpenParenthesis)) { ret.TemplateParameters = TemplateParameterList(); // Constraint[opt] if (laKind == (If)) Constraint(); } ClassBody(ret); return ret; }
/* * American beer is like sex on a boat - F*****g close to water;) */ private INode TemplateDeclaration(INode Parent) { var startLoc = la.Location; // TemplateMixinDeclaration bool isTemplateMixinDecl = laKind == Mixin; if (isTemplateMixinDecl) Step(); Expect(Template); var dc = new DClassLike(Template) { Description=GetComments(), Location=startLoc, Parent=Parent }; LastParsedObject = dc; ApplyAttributes(dc); if (isTemplateMixinDecl) dc.Attributes.Add(new DAttribute(Mixin)); if (Expect(Identifier)) { dc.Name = t.Value; dc.NameLocation = t.Location; } dc.TemplateParameters = TemplateParameterList(); if (laKind == (If)) dc.TemplateConstraint=Constraint(); // [Must not contain a base class list] ClassBody(dc); return dc; }
private IBlockNode InterfaceDeclaration(INode Parent) { Expect(Interface); var dc = new DClassLike() { Location = t.Location, Description = GetComments(), ClassType= DTokens.Interface, Parent=Parent }; ApplyAttributes(dc); if (Expect (Identifier)) { dc.Name = t.Value; dc.NameLocation = t.Location; } else if(IsEOF) dc.NameHash = DTokens.IncompleteIdHash; if (laKind == (OpenParenthesis)) TemplateParameterList(dc); if (laKind == (If)) Constraint(dc); if (laKind == (Colon)) BaseClassList(dc); if (laKind == (If)) Constraint(dc); // Empty interfaces are allowed if (laKind == Semicolon) Step(); else ClassBody(dc); dc.EndLocation = t.EndLocation; return dc; }
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 TemplateIntermediateType(DClassLike dc, ISyntaxRegion td, AbstractType baseType, InterfaceType[] baseInterfaces, Dictionary<string, TemplateParameterSymbol> deducedTypes) : this(dc,td, baseType,baseInterfaces, deducedTypes != null && deducedTypes.Count != 0 ? new ReadOnlyCollection<KeyValuePair<string, TemplateParameterSymbol>>(deducedTypes.ToArray()) : null) { }
public TemplateType(DClassLike dc, ISyntaxRegion td) : base(dc, td) { }
public UnionType(DClassLike dc, ISyntaxRegion td, Dictionary<string, TemplateParameterSymbol> deducedTypes = null) : base(dc, td, null, null, deducedTypes) { }
public override void Visit(DClassLike n) { byte type; if (DoPrimaryIdCheck (n.NameHash, out type)) AddResult (n, type); base.Visit (n); }
public TemplateIntermediateType(DClassLike dc, ISyntaxRegion td, AbstractType baseType, InterfaceType[] baseInterfaces, IEnumerable<TemplateParameterSymbol> deducedTypes) : this(dc,td, baseType,baseInterfaces, deducedTypes != null ? new ReadOnlyCollection<TemplateParameterSymbol>(deducedTypes.ToArray()) : null) { }
public InterfaceType(DClassLike dc, ISyntaxRegion td, InterfaceType[] baseInterfaces=null, IEnumerable<TemplateParameterSymbol> deducedTypes = null) : base(dc, td, null, baseInterfaces, deducedTypes) { }
public TemplateType(DClassLike dc, ISyntaxRegion td, ReadOnlyCollection<TemplateParameterSymbol> inheritedTypeParams = null) : base(dc, td, null, null, inheritedTypeParams) { }
public TemplateIntermediateType(DClassLike dc, ISyntaxRegion td, AbstractType baseType = null, InterfaceType[] baseInterfaces = null, ReadOnlyCollection<TemplateParameterSymbol> deducedTypes = null) : base(dc, baseType, deducedTypes, td) { this.BaseInterfaces = baseInterfaces; }
private INode ClassDeclaration(INode Parent) { Expect(Class); var dc = new DClassLike(Class) { Location = t.Location, Description=GetComments(), Parent=Parent }; LastParsedObject = dc; ApplyAttributes(dc); Expect(Identifier); dc.Name = t.Value; dc.NameLocation = t.Location; if (laKind == (OpenParenthesis)) { dc.TemplateParameters = TemplateParameterList(true); // Constraints if (laKind == If) { Step(); Expect(OpenParenthesis); dc.TemplateConstraint = Expression(); Expect(CloseParenthesis); } } if (laKind == (Colon)) dc.BaseClasses = BaseClassList(); ClassBody(dc); dc.EndLocation = t.EndLocation; return dc; }
public TemplateType(DClassLike dc, ISyntaxRegion td, IEnumerable<TemplateParameterSymbol> inheritedTypeParams = null) : base(dc, td, null, null, inheritedTypeParams) { }
private INode AggregateDeclaration(INode Parent) { var classType = laKind; if (!(classType == Union || classType == Struct)) SynErr(t.Kind, "union or struct required"); Step(); var ret = new DClassLike(t.Kind) { Location = t.Location, Description = GetComments(), ClassType=classType, Parent=Parent }; ApplyAttributes(ret); // Allow anonymous structs&unions if (laKind == Identifier) { Expect(Identifier); ret.Name = t.Value; ret.NameLocation = t.Location; } else if (IsEOF) ret.NameHash = DTokens.IncompleteIdHash; if (laKind == (Semicolon)) { Step(); return ret; } // StructTemplateDeclaration if (laKind == (OpenParenthesis)) { TemplateParameterList(ret); // Constraint[opt] if (laKind == (If)) Constraint(ret); } ClassBody(ret); return ret; }
public UnionType(DClassLike dc, ISyntaxRegion td, IEnumerable<TemplateParameterSymbol> deducedTypes = null) : base(dc, td, null, null, deducedTypes) { }
private void BaseClassList(DClassLike dc,bool ExpectColon=true) { if (ExpectColon) Expect(Colon); var ret = new List<ITypeDeclaration>(); dc.BaseClasses = ret; bool init = true; while (init || laKind == (Comma)) { if (!init) Step(); init = false; if (IsProtectionAttribute() && laKind != (Protected)) Step(); var ids=Type(); if (ids != null) ret.Add(ids); } }