Commit 0c1cfcf3 authored by Julian Kranz's avatar Julian Kranz

Merge branch 'master' of bitbucket.org:simona/gdsl-toolkit into experimental

parents a1799a29 e82f4159
......@@ -895,6 +895,7 @@ structure C1 = struct
| emitPrim s (GET_CON_ARGprim, [_,e],[FUNvtype (_,_,[t]),_]) = seq [str "((", emitConType s t, str "*) ", emitExp s e , str ")->payload"]
| emitPrim s (VOIDprim, [],_) = str "0 /* void value */"
| emitPrim s (MERGE_ROPEprim, [e],_) = seq [str (#prefix s ^ "merge_rope"), fArgs [emitExp s e]]
| emitPrim s (SET_ENDIANESSprim, es,_) = seq [str (#prefix s ^ "set_endianess"), fArgs (map (emitExp s) es)]
| emitPrim s _ = raise CodeGenBug
and addConsume s n = #consumeSizes s := IntListSet.add (!(#consumeSizes s),n)
......
......@@ -78,12 +78,13 @@ structure DesugarDecode = struct
| _ => SymbolTable.noSpan
fun buildEquiv (i, (toks, _, _), map) =
StringMap.insert
(map,
StringMap.unionWith (fn ((sp1,rules1),(sp2,rules2)) => (sp1,Set.union (rules1,rules2)))
(map, StringMap.singleton (
if VS.length toks = 0
then "" (* as placeholder for the real wildcard pattern "_" *)
else toWildcardPattern (VS.sub (toks, 0)),
(getSpan toks, Set.singleton i))
)
in
VS.foldli buildEquiv StringMap.empty decls
end
......
......@@ -92,6 +92,7 @@ structure Imp = struct
| GET_CON_ARGprim
| VOIDprim
| MERGE_ROPEprim
| SET_ENDIANESSprim
(* information on how to print primitives, the name is the C name
and the priority is the operator precedence, 0 if not infix *)
......@@ -130,6 +131,7 @@ structure Imp = struct
| prim_info GET_CON_ARGprim = { name = "__get_con_arg", prio = 0 }
| prim_info VOIDprim = { name = "void", prio = 0 }
| prim_info MERGE_ROPEprim = { name = "merge-rope", prio = 0 }
| prim_info SET_ENDIANESSprim = { name = "endianess", prio = 0 }
(*
* fun f x =
......
......@@ -244,7 +244,8 @@ structure Primitives = struct
BD.meetVarImpliesVar (bvar content'''', bvar content''') o
BD.meetVarImpliesVar (bvar content'', bvar content')},
{name="void", ty=UNIT, flow = noFlow},
{name="merge-rope", ty=FUN([ropeVar],STRING), flow = noFlow}
{name="merge-rope", ty=FUN([ropeVar],STRING), flow = noFlow},
{name="endianess", ty=FUN([ZENO,ZENO],UNIT), flow = noFlow}
]
val primitiveSizeConstraints =
......@@ -314,6 +315,7 @@ structure Primitives = struct
val ssis = ftype [STRINGvtype, STRINGvtype, INTvtype] STRINGvtype
val si = ftype [STRINGvtype] INTvtype
val i = ftype [] INTvtype
val iiv = ftype [INTvtype, INTvtype] VOIDvtype
val v = ftype [] VOIDvtype
val fMv = ftype [ftype [OBJvtype] OBJvtype] (MONADvtype VOIDvtype)
(* Generate type of the returned expression. The value that this
......@@ -371,7 +373,8 @@ structure Primitives = struct
("return", (t ~1, fn args => (case args of
[e] => action e
| _ => raise ImpPrimTranslationBug))),
("merge-rope", (t 0, fn args => pr (MERGE_ROPEprim,os,args)))
("merge-rope", (t 0, fn args => pr (MERGE_ROPEprim,os,args))),
("endianess", (t 0, fn args => pr (SET_ENDIANESSprim,iiv,unboxI args)))
]
end
......
......@@ -526,6 +526,7 @@ val / ['1001010110101000'] = nullop WDR
val / ['1001001 d d d d d 0100'] = binop XCH /Z rd5
val decode config = do
set-endianess LITTLE_ENDIAN 2;
update@{rd='',rr='',ck='',cs='',cb='',io='',dq='', config = config};
idx-before <- idxget;
insn <- /;
......
......@@ -195,18 +195,20 @@ val conf data short long = CONF
confData = data,
confNext = END }
val forceConfType x =
let
val c = conf '01' "foo" "foo"
val r1 = has-conf c
val r2 = conf-short c
val r3 = conf-long c
val r4 = conf-data c
val r5 = conf-next c
in
x
end
# Type for the representation of user-defined data structures exchanged through
# the native interface
type obj = OBJ
# Set the endianess of the input.
type endianess =
BIG_ENDIAN
| LITTLE_ENDIAN
val set-endianess kind size = let
val e = case kind of
BIG_ENDIAN : 0
| LITTLE_ENDIAN : 1
end
in
return (endianess e size)
end
......@@ -21,8 +21,9 @@ val config-default-opnd-sz-32 = '10'
val test-opt opt config = if (zx (opt and config)) > 0 then '1' else '0'
val decode config = do
update @{tab=void};
main config
set-endianess LITTLE_ENDIAN 1;
update @{tab=void};
main config
end
val main config = do
......
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