Commit a51313ff authored by Axel Simon's avatar Axel Simon
Browse files

correctly backup the context when checking usage sites

parent 9102ee55
......@@ -192,15 +192,15 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w118,0w118,10),
(0w48,0w57,11)], [64]), ([], [63]), ([], [60, 63]), ([(0w48,0w57,12)], [63]), ([(0w48,0w57,13)], []), ([], [60]), ([(0w32,0w33,14),
(0w35,0w91,14),
(0w93,0w126,14)], [62]), ([], [68]), ([(0w42,0w42,19)], [68]), ([(0w41,0w41,18)], [68]), ([], [67]), ([], [66]), ([], [69]), ([], [48, 69]), ([], [43, 69]), ([(0w48,0w57,24)], [52, 69]), ([(0w48,0w57,24)], [52]), ([], [47, 69]), ([(0w46,0w46,31),
(0w93,0w126,14)], [61]), ([], [67]), ([(0w42,0w42,19)], [67]), ([(0w41,0w41,18)], [67]), ([], [66]), ([], [65]), ([], [68]), ([], [48, 68]), ([], [43, 68]), ([(0w48,0w57,24)], [52, 68]), ([(0w48,0w57,24)], [52]), ([], [47, 68]), ([(0w46,0w46,31),
(0w48,0w49,31),
(0w124,0w124,31)], [45, 69]), ([(0w39,0w39,30),
(0w124,0w124,31)], [45, 68]), ([(0w39,0w39,30),
(0w45,0w45,30),
(0w47,0w57,30),
(0w63,0w63,30),
(0w65,0w90,30),
(0w95,0w95,30),
(0w97,0w122,30)], [46, 69]), ([], [42, 69]), ([], [44, 69]), ([(0w39,0w39,30),
(0w97,0w122,30)], [46, 68]), ([], [42, 68]), ([], [44, 68]), ([(0w39,0w39,30),
(0w45,0w45,30),
(0w47,0w57,30),
(0w63,0w63,30),
......@@ -208,7 +208,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w95,0w95,30),
(0w97,0w122,30)], [46]), ([(0w46,0w46,31),
(0w48,0w49,31),
(0w124,0w124,31)], [45]), ([], [56, 69]), ([(0w33,0w33,75),
(0w124,0w124,31)], [45]), ([], [56, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -219,7 +219,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,75),
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75)], [51, 69]), ([], [58, 69]), ([(0w0,0w9,156),
(0w126,0w126,75)], [51, 68]), ([], [58, 68]), ([(0w0,0w9,156),
(0w11,0w32,156),
(0w34,0w34,156),
(0w39,0w41,156),
......@@ -245,7 +245,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,158),
(0w96,0w96,158),
(0w124,0w124,158),
(0w126,0w126,158)], [51, 59, 69]), ([(0w33,0w33,75),
(0w126,0w126,158)], [51, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -256,7 +256,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,75),
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75)], [28, 51, 69]), ([(0w33,0w33,75),
(0w126,0w126,75)], [28, 51, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -267,7 +267,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,75),
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75)], [19, 51, 69]), ([], [40, 69]), ([(0w42,0w42,155)], [35, 69]), ([], [36, 69]), ([(0w33,0w33,75),
(0w126,0w126,75)], [19, 51, 68]), ([], [40, 68]), ([(0w42,0w42,155)], [35, 68]), ([], [36, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -278,7 +278,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,75),
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75)], [26, 51, 69]), ([(0w33,0w33,75),
(0w126,0w126,75)], [26, 51, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -289,7 +289,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,75),
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75)], [37, 51, 69]), ([], [30, 69]), ([(0w33,0w33,75),
(0w126,0w126,75)], [37, 51, 68]), ([], [30, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -300,7 +300,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,75),
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75)], [38, 51, 69]), ([], [41, 69]), ([(0w33,0w33,75),
(0w126,0w126,75)], [38, 51, 68]), ([], [41, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w58,0w58,75),
......@@ -318,10 +318,10 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w97,0w122,82),
(0w45,0w45,154),
(0w47,0w47,154),
(0w63,0w63,154)], [50, 51, 69]), ([(0w46,0w46,77),
(0w63,0w63,154)], [50, 51, 68]), ([(0w46,0w46,77),
(0w48,0w57,151),
(0w120,0w120,152)], [52, 69]), ([(0w46,0w46,77),
(0w48,0w57,151)], [52, 69]), ([(0w33,0w33,75),
(0w120,0w120,152)], [52, 68]), ([(0w46,0w46,77),
(0w48,0w57,151)], [52, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -332,7 +332,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,75),
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75)], [34, 51, 69]), ([], [31, 69]), ([(0w33,0w33,75),
(0w126,0w126,75)], [34, 51, 68]), ([], [31, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w47,0w47,75),
......@@ -343,7 +343,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75),
(0w45,0w45,150)], [51, 69]), ([(0w33,0w33,75),
(0w45,0w45,150)], [51, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -354,7 +354,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,75),
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75)], [29, 51, 69]), ([(0w33,0w33,75),
(0w126,0w126,75)], [29, 51, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -365,13 +365,13 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,75),
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75)], [27, 51, 69]), ([(0w39,0w39,149),
(0w126,0w126,75)], [27, 51, 68]), ([(0w39,0w39,149),
(0w45,0w45,149),
(0w47,0w57,149),
(0w63,0w63,149),
(0w65,0w90,149),
(0w95,0w95,149),
(0w97,0w122,149)], [49, 50, 69]), ([], [21, 69]), ([], [22, 69]), ([(0w33,0w33,75),
(0w97,0w122,149)], [49, 50, 68]), ([], [21, 68]), ([], [22, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -382,7 +382,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,75),
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75)], [32, 51, 69]), ([], [25, 69]), ([(0w39,0w39,82),
(0w126,0w126,75)], [32, 51, 68]), ([], [25, 68]), ([(0w39,0w39,82),
(0w45,0w45,82),
(0w47,0w57,82),
(0w63,0w63,82),
......@@ -390,7 +390,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w95,0w95,82),
(0w97,0w109,82),
(0w111,0w122,82),
(0w110,0w110,143)], [50, 69]), ([(0w39,0w39,82),
(0w110,0w110,143)], [50, 68]), ([(0w39,0w39,82),
(0w45,0w45,82),
(0w47,0w57,82),
(0w63,0w63,82),
......@@ -403,7 +403,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w65,0w90,82),
(0w95,0w95,82),
(0w98,0w122,82),
(0w97,0w97,140)], [50, 69]), ([(0w39,0w39,82),
(0w97,0w97,140)], [50, 68]), ([(0w39,0w39,82),
(0w45,0w45,82),
(0w47,0w57,82),
(0w63,0w63,82),
......@@ -414,7 +414,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w112,0w122,82),
(0w97,0w97,130),
(0w105,0w105,131),
(0w111,0w111,132)], [50, 69]), ([(0w39,0w39,82),
(0w111,0w111,132)], [50, 68]), ([(0w39,0w39,82),
(0w45,0w45,82),
(0w47,0w57,82),
(0w63,0w63,82),
......@@ -426,7 +426,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w121,0w122,82),
(0w108,0w108,120),
(0w110,0w110,121),
(0w120,0w120,122)], [50, 69]), ([(0w39,0w39,82),
(0w120,0w120,122)], [50, 68]), ([(0w39,0w39,82),
(0w45,0w45,82),
(0w47,0w57,82),
(0w63,0w63,82),
......@@ -434,7 +434,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w95,0w95,82),
(0w97,0w113,82),
(0w115,0w122,82),
(0w114,0w114,110)], [50, 69]), ([(0w39,0w39,82),
(0w114,0w114,110)], [50, 68]), ([(0w39,0w39,82),
(0w45,0w45,82),
(0w47,0w57,82),
(0w63,0w63,82),
......@@ -444,7 +444,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w103,0w109,82),
(0w111,0w122,82),
(0w102,0w102,103),
(0w110,0w110,104)], [50, 69]), ([(0w39,0w39,82),
(0w110,0w110,104)], [50, 68]), ([(0w39,0w39,82),
(0w45,0w45,82),
(0w47,0w57,82),
(0w63,0w63,82),
......@@ -452,7 +452,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w95,0w95,82),
(0w97,0w100,82),
(0w102,0w122,82),
(0w101,0w101,101)], [50, 69]), ([(0w39,0w39,82),
(0w101,0w101,101)], [50, 68]), ([(0w39,0w39,82),
(0w45,0w45,82),
(0w47,0w57,82),
(0w63,0w63,82),
......@@ -462,14 +462,14 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w103,0w113,82),
(0w115,0w122,82),
(0w102,0w102,95),
(0w114,0w114,96)], [50, 69]), ([(0w39,0w39,82),
(0w114,0w114,96)], [50, 68]), ([(0w39,0w39,82),
(0w45,0w45,82),
(0w47,0w57,82),
(0w63,0w63,82),
(0w65,0w90,82),
(0w95,0w95,82),
(0w98,0w122,82),
(0w97,0w97,91)], [50, 69]), ([(0w39,0w39,82),
(0w97,0w97,91)], [50, 68]), ([(0w39,0w39,82),
(0w45,0w45,82),
(0w47,0w57,82),
(0w63,0w63,82),
......@@ -486,7 +486,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w65,0w90,82),
(0w95,0w95,82),
(0w98,0w122,82),
(0w97,0w97,83)], [50, 69]), ([], [23, 69]), ([(0w33,0w33,75),
(0w97,0w97,83)], [50, 68]), ([], [23, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -497,7 +497,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,75),
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75)], [33, 51, 69]), ([], [24, 69]), ([(0w33,0w33,75),
(0w126,0w126,75)], [33, 51, 68]), ([], [24, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -509,7 +509,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w96,0w96,75),
(0w124,0w124,75),
(0w126,0w126,75),
(0w48,0w57,76)], [39, 51, 69]), ([(0w33,0w33,75),
(0w48,0w57,76)], [39, 51, 68]), ([(0w33,0w33,75),
(0w35,0w38,75),
(0w42,0w43,75),
(0w45,0w45,75),
......@@ -1060,7 +1060,8 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w45,0w45,154),
(0w47,0w47,154),
(0w63,0w63,154)], [50, 51]), ([], [57]), ([(0w0,0w9,156),
(0w11,0w2147483647,156)], [59]), ([], [60]), ([(0w0,0w9,156),
(0w11,0w2147483647,156),
(0w10,0w10,157)], []), ([], [59]), ([(0w0,0w9,156),
(0w11,0w32,156),
(0w34,0w34,156),
(0w39,0w41,156),
......@@ -1074,6 +1075,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w97,0w123,156),
(0w125,0w125,156),
(0w127,0w2147483647,156),
(0w10,0w10,157),
(0w33,0w33,158),
(0w35,0w38,158),
(0w42,0w43,158),
......@@ -1085,7 +1087,7 @@ STRING | COMMENT | BITPATNUM | BITPAT | INITIAL
(0w94,0w94,158),
(0w96,0w96,158),
(0w124,0w124,158),
(0w126,0w126,158)], [51, 59])]
(0w126,0w126,158)], [51])]
fun yystreamify' p input = ULexBuffer.mkStream (p, input)
fun yystreamifyReader' p readFn strm = let
......
......@@ -116,6 +116,7 @@ fun typeInferencePass (errStrm, ti : TI.type_info, ast) = let
fun checkUsage (s, (unstable, env)) =
let
val fs = E.getContextOfUsage (sym, s, env)
val oldCtxt = E.getCtxt env
val env = List.foldl E.pushFunction env fs
val envFun = E.pushSymbol (sym, s, env)
......@@ -165,7 +166,7 @@ fun typeInferencePass (errStrm, ti : TI.type_info, ast) = let
E.meetFlow (envCall, envFun))
handle (S.UnificationFailure str) =>
(raiseError str; (S.emptySubsts, envCall))
val (changed, env) = E.popToUsage (sym, s, env)
val (changed, env) = E.popToUsage (sym, s, oldCtxt, env)
val _ = sm := List.foldl
(fn (sym,sm) => (sym, E.getFunctionInfo (sym, env)) ::
List.filter (fn (s,_) =>
......@@ -256,9 +257,9 @@ fun typeInferencePass (errStrm, ti : TI.type_info, ast) = let
val env = E.popToFunction (sym, env)
val fInfo = E.getFunctionInfo (sym, env)
val _ = sm := (sym, fInfo) :: !sm
val env = checkUsages false (sym, env)
val (unstable, env) = checkUsages false (sym, env)
in
env
(unstable, env)
end
and infDecl stenv (AST.MARKdecl m) = reportError infDecl stenv m
......@@ -691,7 +692,7 @@ fun typeInferencePass (errStrm, ti : TI.type_info, ast) = let
(#tree (ast : SpecAbstractTree.specification))
val toplevelEnv = calcFixpoint (unstable, toplevelEnv)
handle TypeError => toplevelEnv
val _ = TextIO.print ("toplevel environment:\n" ^ E.toString toplevelEnv)
(*val _ = TextIO.print ("toplevel environment:\n" ^ E.toString toplevelEnv)*)
val (badSizes, primEnv) = E.popGroup (toplevelEnv, false)
val _ = reportBadSizes badSizes
val (badSizes, _) = E.popGroup (primEnv, false)
......
......@@ -53,8 +53,10 @@ structure Environment : sig
val getContextOfUsage : VarInfo.symid * Error.span * environment ->
VarInfo.symid list
(*stack: [...,t] -> [...] and type of f for call-site s is set to t*)
val popToUsage : VarInfo.symid * Error.span * environment ->
val getCtxt : environment -> VarInfo.symid list
(*stack: [...,t] -> [...] and type of f for call-site s is set to t*)
val popToUsage : VarInfo.symid * Error.span * VarInfo.symid list * environment ->
VarInfo.symid list * environment
(*stack: [...] -> [...,t] where t is type of usage of f at call-site s,
......@@ -681,7 +683,6 @@ end = struct
else bFun
val state = Scope.setFlow bFunRem state
val env = Scope.update (sym, setType (t,bFun), (scs, state))
(*val _ = TextIO.print ("*** popToFunction " ^ SymbolTable.getString(!SymbolTables.varTable, sym) ^ ", containing bVars " ^ BD.setToString funBVars ^ ", mono bVars " ^ BD.setToString monoBVars ^ ":\nbefore " ^ BD.showBFun bFunOrig ^ "\nafter " ^ BD.showBFun bFun ^ "\nenvironment:\n" ^ topToString env)*)
in
env
end
......@@ -848,7 +849,9 @@ end = struct
end
)
fun popToUsage (sym, span, env) = (case Scope.unwrap env of
fun getCtxt (scs, state) = Scope.getCtxt state
fun popToUsage (sym, span, oldCtxt, env) = (case Scope.unwrap env of
(KAPPA {ty = tUse}, env) =>
let
val changedFuns = ref ([] : ST.symid list)
......@@ -881,7 +884,7 @@ end = struct
reduceBooleanFormula (f,t,setType,List.null fs,env))
| _ => raise InferenceBug
val (scs, state) = env
val env = (scs, Scope.setCtxt [] state)
val env = (scs, Scope.setCtxt oldCtxt state)
in
(changedFuns, project (changedFuns, env))
end
......@@ -1118,6 +1121,7 @@ end = struct
fun popToFunction (sym, env) =
let
(*val _ = TextIO.print ("popToFunction " ^ SymbolTable.getString(!SymbolTables.varTable, sym) ^ ":\n" ^ toString env)*)
fun setType t (COMPOUND {ty = NONE, width = NONE, uses}, cons) =
(COMPOUND {ty = SOME t, width = NONE, uses = uses},
cons)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment