Commit 7e943cca authored by Axel Simon's avatar Axel Simon
Browse files

replace pushed nested group without resorting to function name in which it was nested

parent 46b6f4a4
......@@ -375,7 +375,6 @@ fun typeInferencePass (errStrm, ti : TI.type_info, ast) = let
val env = E.popToUsage (sym, s, env)
val env = E.popNested (n1+n2,env)
val env = E.leaveFunction (fid,env)
in
env
end
......@@ -965,7 +964,7 @@ fun typeInferencePass (errStrm, ti : TI.type_info, ast) = let
| checkExports s _ = ()
val _ = List.app (checkExports SymbolTable.noSpan) ast
(*val _ = TextIO.print ("toplevel environment:\n" ^ E.topToString toplevelEnv)*)
val _ = TextIO.print ("toplevel environment:\n" ^ E.toString toplevelEnv)
val (badSizes, primEnv) = E.popGroup (toplevelEnv, false)
val _ = reportBadSizes badSizes
......
......@@ -1331,24 +1331,28 @@ in () end;*)
| SOME r => r
end
fun popNested (n, env) =
if n<=0 then env else case Scope.unwrap env of
(GROUP bs, env) =>
let
fun replGroup (GROUP bs' :: gs) =
if List.all (fn (b,b') =>
SymbolTable.eq_symid (#name b, #name b'))
(ListPair.zip (bs,bs'))
then GROUP bs :: gs else GROUP bs' :: replGroup gs
| replGroup _ = raise InferenceBug
fun action (COMPOUND {ty, width, uses, nested},cons) =
(COMPOUND {ty = ty, width = width,
uses = uses, nested = replGroup nested}, cons)
| action _ = raise InferenceBug
val env = Scope.update (Scope.getCurFun (#2 env), action, env)
in
popNested (n-1,env)
end
fun popNested (n, env) = if n<=0 then env else
case Scope.unwrap env of
(GROUP bs, env) => (case Scope.unwrap env of
(GROUP bsPrev, env) =>
let
fun replGroup (GROUP bs' :: gs) =
if List.all (fn (b,b') =>
SymbolTable.eq_symid (#name b, #name b'))
(ListPair.zip (bs,bs'))
then GROUP bs :: gs else GROUP bs' :: replGroup gs
| replGroup [] = []
| replGroup _ = raise InferenceBug
fun replBs ({name, ty, width, uses, nested}) =
{name = name, ty = ty, width = width,
uses = uses, nested = replGroup nested}
val bsPrev = List.map replBs bsPrev
in
popNested (n-1,Scope.wrap (GROUP bsPrev,env))
end
| _ => raise InferenceBug
)
| (_, env) => raise InferenceBug
fun clearFunction (sym, env) =
......
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