Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/analysis/typepal/Collector.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import String;
import analysis::typepal::Version;
import analysis::typepal::Messenger;
import analysis::typepal::LocationChecks;
import analysis::typepal::GetLoc;

extend analysis::typepal::ConfigurableScopeGraph;
extend analysis::typepal::ICollector;
Expand Down Expand Up @@ -268,8 +269,7 @@ Collector newCollector(str modelName, map[str,Tree] namedTrees, TypePalConfig co
else if(loc ldef := def) l = ldef;
else throw TypePalUsage("Argument `def` of `define` should be `Tree` or `loc`, found <typeOf(def)>");
nname = normalizeName(orgId);
Define newDef = <currentScope, nname, orgId, idRole, l, info>;
logL = buildLogical2physical(newDef);
Define newDef = buildLogicalDefine(<currentScope, nname, orgId, idRole, l, info>);
if(info is defTypeLub){
// Look for an outer variable declaration of id that overrules the defTypeLub
for(Define def <- defines + definesPerLubScope[currentLubScope]){
Expand Down Expand Up @@ -347,8 +347,7 @@ Collector newCollector(str modelName, map[str,Tree] namedTrees, TypePalConfig co
else throw TypePalUsage("Argument `def` of `defineInScope` should be `Tree` or `loc`, found <typeOf(def)>");

nname = normalizeName(orgId);
Define newDef = <definingScope, nname, orgId, idRole, l, info>;
logL = buildLogical2physical(newDef);
Define newDef = buildLogicalDefine(<definingScope, nname, orgId, idRole, l, info>);
if(info is defTypeLub){
throw TypePalUsage("`defLub` cannot be used in combination with `defineInScope`");
} else {
Expand Down Expand Up @@ -961,23 +960,24 @@ Collector newCollector(str modelName, map[str,Tree] namedTrees, TypePalConfig co
return l;
}

loc buildLogical2physical(Define def){
if(def.defined in logical2physical) return logical2physical[def.defined];
Define buildLogicalDefine(Define def){
if(def.defined in logical2physical) return def;
loc logicalLoc = physical2logical[def.defined] ? config.createLogicalLoc(def, modelName, config.typepalPathConfig);
if(logicalLoc != def.defined){
if(logicalLoc in logical2physical){
if(logical2physical[logicalLoc] != def.defined){
causes = [ info("First declaration of <prettyRole(def.idRole)> `<def.id>`", logical2physical[logicalLoc]),
info("Second declaration of <prettyRole(def.idRole)> `<def.id>`", def.defined)
];
// restrict clone location to first line for readability
messages += error("Duplicate declaration of <prettyRole(def.idRole)> `<def.id>`", limitLocToFirstLine(def.defined), causes=causes);
}

if(logicalLoc in logical2physical){
if(logical2physical[logicalLoc] != def.defined){
causes = [ info("First declaration of <prettyRole(def.idRole)> `<def.id>`", logical2physical[logicalLoc]),
info("Second declaration of <prettyRole(def.idRole)> `<def.id>`", def.defined)
];
// restrict clone location to first line for readability
messages += error("Duplicate declaration of <prettyRole(def.idRole)> `<def.id>`", limitLocToFirstLine(def.defined), causes=causes);
}
logical2physical[logicalLoc] = def.defined;
physical2logical[def.defined] = logicalLoc;
}
return logicalLoc;
logical2physical[logicalLoc] = def.defined;
physical2logical[def.defined] = logicalLoc;
def.defined = logicalLoc;

return def;
}

&T toLogicalLocs(&T v){
Expand Down
1 change: 1 addition & 0 deletions src/analysis/typepal/Messenger.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import util::IDEServices;

extend analysis::typepal::AType;
extend analysis::typepal::Exception;
import analysis::typepal::GetLoc;

// ---- Message utilities -----------------------------------------------------

Expand Down
Loading