From 07608fe926a5f78c68754f7b1f60ee5eeb991152 Mon Sep 17 00:00:00 2001 From: paulklint Date: Sun, 21 Jul 2024 23:29:19 +0200 Subject: [PATCH] Simplified hash computations --- .../core/library/CheckTestSources.rsc | 2 +- .../check/CollectDataDeclaration.rsc | 2 +- .../rascalcore/check/CollectDeclaration.rsc | 2 +- .../check/CollectSyntaxDeclaration.rsc | 41 ++----------------- .../lang/rascalcore/check/CollectType.rsc | 21 ++-------- 5 files changed, 11 insertions(+), 57 deletions(-) diff --git a/src/org/rascalmpl/core/library/CheckTestSources.rsc b/src/org/rascalmpl/core/library/CheckTestSources.rsc index 821301f7..a0bf7c3d 100644 --- a/src/org/rascalmpl/core/library/CheckTestSources.rsc +++ b/src/org/rascalmpl/core/library/CheckTestSources.rsc @@ -15,7 +15,7 @@ PathConfig manualTestConfig= pathConfig(bin=|project://rascal-core/target/test-c resources = |project://rascal-core/target/generated-test-resources2| ); -void main() = checkTestSources(manualTestConfig); +void main() = checkTestSources([], manualTestConfig); // if cmdLineArgs contains "all", then all files in the rascal project are used (~400 files) // otherwise only standard library and test files (~200 files) diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDataDeclaration.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDataDeclaration.rsc index 935199c3..4dfde74f 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDataDeclaration.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDataDeclaration.rsc @@ -91,7 +91,7 @@ void collect(current:(Variant) ` ( <{TypeArg ","}* arguments> ")>"); + dt.md5 = md5Hash(""); c.define(fieldName, fieldId(), ta.name, dt); } } diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDeclaration.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDeclaration.rsc index a827e5f6..26fcdce8 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDeclaration.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDeclaration.rsc @@ -194,7 +194,7 @@ void collect(current: (KeywordFormal) ` = "); + dt.md5 = md5Hash(unparseNoLayout(current)); c.define(kwformalName, keywordFormalId(), current, dt); c.calculate("keyword formal", current, [kwType, expression], AType(Solver s){ diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectSyntaxDeclaration.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectSyntaxDeclaration.rsc index 158c33da..e561f2ab 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectSyntaxDeclaration.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectSyntaxDeclaration.rsc @@ -53,7 +53,7 @@ void declareSyntax(SyntaxDefinition current, SyntaxRole syntaxRole, IdRole idRol dt = defType(nonterminalType); dt.vis = vis; - dt.md5 = md5Hash(""); + dt.md5 = md5Hash(""); syndefCounter += 1; // Define the syntax symbol itself and all labelled alternatives as constructors @@ -77,17 +77,6 @@ void declareSyntax(SyntaxDefinition current, SyntaxRole syntaxRole, IdRole idRol } } -// ---- ProdModifier --------------------------------------------------------- - -str md5ContribProdMod(Tag \tag) - = ""; - -default str md5ContribProdMod(ProdModifier pm) - = ""; - -str md5ContribProdMods(ProdModifier* pms) - = "<}>"; - // ---- Prod ------------------------------------------------------------------ AProduction getProd(AType adtType, Tree tree, Solver s){ @@ -101,9 +90,6 @@ void collect(current: (Prod) `: `, Collector c){ c.fact(current, referenced); } -str md5ContribProd((Prod) `: `) - = "REF"; - void requireNonLayout(Tree current, AType u, str msg, Solver s){ if(isLayoutAType(u)) s.report(error(current, "Layout type %t not allowed %v", u, msg)); } @@ -179,7 +165,7 @@ void collect(current: (Prod) ` : ")); } else throw "Unexpected type of production: "; - })[md5=md5Hash("")]); + })[md5=md5Hash("")]); beginUseTypeParameters(c,closed=true); c.push(currentAlternative, ", syms>); collect(symbols, c); @@ -190,9 +176,6 @@ void collect(current: (Prod) ` : : `) - = "")>C<}>"; - void collect(current: (Prod) ` `, Collector c){ symbols = [sym | sym <- syms]; @@ -212,10 +195,6 @@ void collect(current: (Prod) ` `, Collector } } -str md5ContribProd(p:(Prod) ` `){ - return "<}>"; -} - private AProduction associativity(AType nt, nothing(), AProduction p) = p; private default AProduction associativity(AType nt, just(AAssociativity a), AProduction p) = associativity(nt, a, {p}); @@ -245,9 +224,6 @@ list[Prod] normalizeAlt((Prod) ` | `) default list[Prod] normalizeAlt(Prod p) = [p]; -str md5ContribProd((Prod) ` ( )`) - = "LR"; - void collect(current: (Prod) ` | `, Collector c){ if( := c.top(currentAdt)){ alts = normalizeAlt(current); @@ -261,14 +237,12 @@ void collect(current: (Prod) ` | `, Collector c){ c.pop(inAlternative); if(isEmpty(c.getStack(inAlternative))){ nalternatives += 1; - c.define("alternative-", nonterminalId(), current, defType(current)[md5=md5ContribProd(current)]); + c.define("alternative-", nonterminalId(), current, defType(current)[md5=md5Hash(unparseNoLayout(current))]); } } else { throw "collect alt: currentAdt not found"; } } -str md5ContribProd((Prod) ` | `) - = "A"; void collect(current: (Prod) ` \> `, Collector c){ if( := c.top(currentAdt)){ @@ -281,11 +255,4 @@ void collect(current: (Prod) ` \> `, Collector c){ } else { throw "collect alt: currentAdt not found"; } -} - -str md5ContribProd((Prod) ` \> `) - = "R"; - -//default void collect(Prod current, Collector c){ -// throw "collect Prod, missed case "; -//} \ No newline at end of file +} \ No newline at end of file diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectType.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectType.rsc index 0916859a..22580956 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectType.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectType.rsc @@ -536,10 +536,8 @@ void collect(current:(Sym) `start [ ]`, Collector c){ collect(n, c); } -str md5ContribSym((Sym) `start [ ]`) - = "S"; - -str removeLayout(str s){ +str unparseNoLayout(Tree t){ + s = ""; return "<}>"; } @@ -547,7 +545,7 @@ void collect(current:(Sym) ` `, Collector c){ un = unescape(""); md5Contrib = ""; if(!isEmpty(c.getStack(currentAlternative)) && := c.top(currentAlternative)){ - md5Contrib += "")>"; + md5Contrib += ""; } else if(!isEmpty(c.getStack(currentAdt)) && := c.top(currentAdt)){ md5Contrib += ""; } @@ -557,7 +555,7 @@ void collect(current:(Sym) ` `, Collector c){ AType(Solver s){ res = s.getType(symbol)[alabel=un]; return res; - })[md5=md5Hash("")]); + })[md5=md5Hash("")]); c.fact(current, n); collect(symbol, c); @@ -572,21 +570,13 @@ void collect(current:(Sym) ``, Collector c){ c.fact(current, cc2ranges(cc)); } -str md5ContribSym((Sym) ``) - = reduceToURIChars(""); - void collect(current:(Sym) ``, Collector c){ c.fact(current, AType::alit(unescapeLiteral(l))); } -str md5ContribSym((Sym) ``) - = reduceToURIChars(""); - void collect(current:(Sym) ``, Collector c){ c.fact(current, AType::acilit(unescapeLiteral(l))); } -str md5ContribSym((Sym) ``) - = reduceToURIChars(""); // ---- regular expressions @@ -834,9 +824,6 @@ void collect(current:(Sym) ` \\ `, Collector c){ str md5ContribSym((Sym) ` \\ `) = "NOTEQUAL"; -default str md5ContribSym(Sym sym) - = reduceToURIChars(""); - void collect(Sym current, Collector c){ throw "collect Sym, missed case "; }