Commit 6f563dc5 authored by Axel Simon's avatar Axel Simon
Browse files

fix complex patterns and improve error message

parent 37a1e9d1
......@@ -11,6 +11,7 @@ end = struct
open CM
infix >>=
infix >>
fun all s =
SplitDeclarations.run s >>=
......@@ -24,6 +25,8 @@ end = struct
fun dumpPre (os, (_, spec)) = AT.PP.prettyTo (os, spec)
fun dumpPost (os, spec) = Pretty.prettyTo (os, Core.PP.spec spec)
fun pass (s, spec) = CM.run s (all spec)
handle DT.DesugarTreeException (sp,err) =>
CM.run s (errorAt (sp, [err]) >> fail)
val desugar =
BasicControl.mkKeepPass
......
structure DesugaredTree = struct
exception DesugarTreeException of (Error.span * string)
structure Exp = Core.Exp
type sym = Core.sym
......@@ -82,28 +84,30 @@ structure DesugaredTree = struct
mapUpdates fs
end
and match (p, e) = (pat p, exp e)
and match (p, e) = (pat SymbolTable.noSpan p, exp e)
and stripMarkPat p =
and stripMarkPat sp p =
case p of
MARKpat t => stripMarkPat (#tree t)
| p => p
MARKpat t => stripMarkPat (#span t) (#tree t)
| p => (sp,p)
and pat p =
and pat sp p =
case p of
MARKpat t => pat (#tree t)
MARKpat t => pat (#span t) (#tree t)
| CONpat (s, SOME p) =>
let
val p = stripMarkPat p
val (sp,p) = stripMarkPat sp p
in
case p of
IDpat x => Pat.CON (s, SOME x)
| _ => raise Fail "Invalid pattern (too complex...)"
| _ => raise DesugarException
(sp, "expect variable as argument in constructor pattern")
end
| CONpat (s, NONE) => Pat.CON (s, NONE)
| LITpat (INTlit i) => Pat.INT i
| LITpat (VEClit i) => Pat.BIT i
| LITpat _ => raise CM.CompilationError
| LITpat _ => raise DesugarException
(sp, "cannot pattern match against this literal")
| IDpat id => Pat.ID id
| WILDpat => Pat.WILD
......
......@@ -1882,14 +1882,19 @@ val segmentation-set-for-base base =
in
do
mode64 <- mode64?;
if not(mode64) then
if not(mode64) then return void else
case base of
REG ESP: override-ss
| REG EBP: override-ss
| _: return void
REG r: case r of
SP : override-ss
| ESP: override-ss
| RSP: override-ss
| BP : override-ss
| EBP: override-ss
| RBP: override-ss
| _ : return void
end
| _ : return void
end
else
return void
end
end
......
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