From eca2d82fd61ff45454d1bd0f75d4f1247f7acbd9 Mon Sep 17 00:00:00 2001 From: paulklint Date: Thu, 31 Oct 2024 11:38:08 +0100 Subject: [PATCH] Partly undone optimization of convertLocs, it was incomplete --- src/analysis/typepal/Collector.rsc | 34 ++++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/analysis/typepal/Collector.rsc b/src/analysis/typepal/Collector.rsc index 46609cc..6604062 100644 --- a/src/analysis/typepal/Collector.rsc +++ b/src/analysis/typepal/Collector.rsc @@ -193,29 +193,35 @@ Collector newCollector(str modelName, Tree pt, TypePalConfig config){ return newCollector(modelName, (modelName : pt), config); } -// The folliwng function can be written with a single (expensive) visit +// The following function can be written with a single (expensive) visit // This version avoids visis as much as possible TModel convertLocs(TModel tm, map[loc,loc] locMap){ defines = {}; definitions = (); for(d: <- tm.defines){ - defi = defInfo; - if(defType(loc src) := defInfo){ - defi.src = locMap[src] ? src; - } else - if(defType(AType atype) := defInfo){ - if(overloadedAType(rel[loc, IdRole, AType] overloads) := atype){ - defi.atype = overloadedAType({ | <- overloads }); - } - } else { - throw "convertLocs: cannot handle "; - } - // defi = visit(defInfo){ case loc l => locMap[l] ? l }; - + defi = visit(defInfo){ case loc l => locMap[l] ? l }; d1 = d[scope=locMap[scope]?scope][defined=locMap[defined]?defined][defInfo=defi]; defines += d1; definitions[d1.defined] = d1; } + // for(d: <- tm.defines){ + // defi = defInfo; + // if(defType(loc src) := defInfo){ + // defi.src = locMap[src] ? src; + // } else + // if(defType(AType atype) := defInfo){ + // if(overloadedAType(rel[loc, IdRole, AType] overloads) := atype){ + // defi.atype = overloadedAType({ | <- overloads }); + // } + // } else { + // throw "convertLocs: cannot handle "; + // } + // // defi = visit(defInfo){ case loc l => locMap[l] ? l }; + + // d1 = d[scope=locMap[scope]?scope][defined=locMap[defined]?defined][defInfo=defi]; + // defines += d1; + // definitions[d1.defined] = d1; + // } tm.defines = defines; tm.definitions = definitions;