# HG changeset patch # User Michael Pavone # Date 1428653986 25200 # Node ID a3b06d53bcb9497be75730a0e885cfd8422dd2b5 # Parent 60292f131de91bb544f76447cf3761603f7906d1 Make il and x86 modules cope with dict hash instead of dict linear for the program definition diff -r 60292f131de9 -r a3b06d53bcb9 modules/il.tp --- a/modules/il.tp Fri Apr 10 01:19:10 2015 -0700 +++ b/modules/il.tp Fri Apr 10 01:19:46 2015 -0700 @@ -705,7 +705,7 @@ } outprog <- #[] foreach: prepped :name instarr { - outprog append: (labels get: name) + outprog append: (labels get: name else: { false }) foreach: instarr :_ inst { print: "Translating: " . inst . "\n" backend convertIL: inst to: outprog withLabels: labels diff -r 60292f131de9 -r a3b06d53bcb9 modules/x86.tp --- a/modules/x86.tp Fri Apr 10 01:19:10 2015 -0700 +++ b/modules/x86.tp Fri Apr 10 01:19:46 2015 -0700 @@ -764,9 +764,7 @@ { //call arguments <- inst args - cur <- (arguments length) - 1 - while: { cur >= 0 } do: { - src <- (arguments get: cur) + arguments foldr: (arguments length) - 1 with: :cur src { if: cur < (_argregs length) { dst <- _argregs get: cur if: (not: dst = src) { @@ -778,12 +776,19 @@ } else: { outarr append: (push: src) } - cur <- cur - 1 + cur - 1 } + toCall <- inst target if: (toCall isString?) { //TODO: Handle call to undefined label - toCall <- labels get: toCall + toCall <- labels get: toCall else: { + print: "Could not find label " . toCall . "\nDefined labels:\n" + foreach: labels :key _ { + print: "\t" . key . "\n" + } + false + } } outarr append: (call: toCall) }