Skip to content

Commit

Permalink
Moved code to avoid extend cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Oct 20, 2024
1 parent 52a53ab commit 9d86fcd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extend lang::rascalcore::check::CollectDataDeclaration;
extend lang::rascalcore::check::CollectSyntaxDeclaration;

extend lang::rascalcore::check::Fingerprint;
//extend lang::rascalcore::check::PathAnalysis;
import lang::rascalcore::check::PathAnalysis;

//import lang::rascalcore::check::ScopeInfo;
import lang::rascalcore::check::CollectOperators;
Expand Down Expand Up @@ -150,7 +150,14 @@ void collect(current: (Declaration) `<Tags tags> <Visibility visibility> <Type v

if(var is initialized){
initial = var.initial;
c.require("initialization of `<vname>`", initial, [initial, varType], makeVarInitRequirement(var, c));
if(initial is nonEmptyBlock){
statements = initial.statements;
Statement stat = (Statement) `{ <Statement+ statements> }`;
if(!returnsValue(stat, "", c)){
c.report(error(initial, "Right-hand side of assignment does not always have a value"));
}
}
c.require("initialization of `<vname>`", initial, [initial, varType], makeVarInitRequirement(var));
collect(initial, c);
}
c.leaveScope(var);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,8 +1165,15 @@ void collect(current: (Statement) `<Type varType> <{Variable ","}+ variables>;`,
if(var is initialized){
initial = var.initial;
if(initial is nonEmptyBlock){
statements = initial.statements;
Statement stat = (Statement) `{ <Statement+ statements> }`;
if(!returnsValue(stat, "", c)){
c.report(error(initial, "Right-hand side of assignment does not always have a value"));
}
}
c.enterLubScope(var);
c.require("initialization of `<var.name>`", initial, [initial, varType], makeVarInitRequirement(var, c));
c.require("initialization of `<var.name>`", initial, [initial, varType], makeVarInitRequirement(var));
collect(initial, c);
c.leaveScope(var);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,8 @@ void checkNonVoid(Tree e, AType t, Solver s, str msg){
AType(Solver) makeGetSyntaxType(Type varType)
= AType(Solver s) { Tree t = varType; return getSyntaxType(t, s); };

void(Solver) makeVarInitRequirement(Variable var, Collector c){
Expression initial = var.initial;
if(initial is nonEmptyBlock){
statements = initial.statements;
Statement stat = (Statement) `{ <Statement+ statements> }`;
if(!returnsValue(stat, "", c)){
c.report(error(initial, "Right-hand side of assignment does not always have a value"));
}
}
return void(Solver s){
void(Solver) makeVarInitRequirement(Variable var)
= void(Solver s){
Bindings bindings = ();
initialType = s.getType(var.initial);
varType = s.getType(var.name);
Expand All @@ -86,7 +78,6 @@ void(Solver) makeVarInitRequirement(Variable var, Collector c){
checkNonVoid(var.initial, initialTypeU, s, "Variable initialization");
s.fact(var, deUnique(varType));
};
}

void(Solver) makeNonVoidRequirement(Tree t, str msg)
= void(Solver s) { checkNonVoid(t, s, msg ); };
Expand Down

0 comments on commit 9d86fcd

Please sign in to comment.