private FParam FParamsTail() { string first = ","; this.SkipErrors(first); var lookaheadToken = this.TokenStream.Peek(); string lookahead = lookaheadToken.AToCCFormat(); if (first.HasToken(lookahead)) { this.ApplyDerivation("fParamsTail -> ',' type 'id' infArraySize"); Match(","); var location = this.TokenStream.Peek().SourceLocation; string type = Type(); string id = Match("id"); var dimensions = InfArraySize(); var parameter = new FParam(location); parameter.Type = type; parameter.Id = id; parameter.Dimensions = dimensions; return(parameter); } return(null); }
public override void Visit(FParam fParam) { if (!this.DoneClassList) { return; } int numElements = 1; var dimensions = new List <int>(); // Calculate the dimensions and the total size. foreach (var dimension in fParam.Dimensions) { dimensions.Add(int.Parse(dimension.Value)); numElements *= dimensions.Last(); } var nodeEntry = this.GetCurrentScope().Get(fParam.Id, Classification.Variable); if (!this.Sizes.ContainsKey(fParam.Type)) { // If it doesn't exist, the memory size will be -1. By multiplying it by the number of elements, // the true size will happen when (in the class) we resolve it by doing *= -sizeof(type); nodeEntry.EntryMemorySize *= numElements; } else { nodeEntry.EntryMemorySize = Sizes[fParam.Type] * numElements; } nodeEntry.MaxSizeDimensions = dimensions; }
public override void Visit(FParam fParam) { if (fParam.Id != string.Empty) { var entry = new TableEntry(fParam.Id, Classification.Parameter, -1) { Type = fParam.Type + "[]".Repeat(fParam.Dimensions.Count) }; fParam.Entry = entry; } }
private List <FParam> FParams() { string first = "id int float"; string follow = ")"; this.SkipErrors(first, follow); var lookaheadToken = this.TokenStream.Peek(); string lookahead = lookaheadToken.AToCCFormat(); if (first.HasToken(lookahead)) { this.ApplyDerivation("fParams -> type 'id' infArraySize infFParamsTail"); var paramList = new List <FParam>(); var parameter = new FParam(lookaheadToken.SourceLocation); string type = Type(); string id = Match("id"); var dimensions = InfArraySize(); var trailingParameters = InfFParamsTail(); parameter.Type = type; parameter.Id = id; parameter.Dimensions = dimensions; paramList.Add(parameter); paramList.JoinListWhereNotNull(trailingParameters); return(paramList); } if (follow.HasToken(lookahead)) { this.ApplyDerivation("fParams -> EPSILON"); return(new List <FParam>()); } return(null); }
public virtual void Visit(FParam fParam) { }