From db9e59813541e06caece64592854862bab9c0138 Mon Sep 17 00:00:00 2001 From: ronny Date: Tue, 5 Oct 1999 13:09:14 +0000 Subject: Initial import git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@2 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d --- frontend/general.icl | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 frontend/general.icl (limited to 'frontend/general.icl') diff --git a/frontend/general.icl b/frontend/general.icl new file mode 100644 index 0000000..83f854e --- /dev/null +++ b/frontend/general.icl @@ -0,0 +1,72 @@ +implementation module general + +import StdEnv + +:: Bind a b = + { bind_src :: !a + , bind_dst :: !b + } + +:: Env a b :== [Bind a b] + +:: Optional x = Yes !x | No + +cMAXINT :== 2147483647 + +:: BITVECT :== Int + +instance ~ Bool +where ~ b = not b + +instance <<< Bool +where + (<<<) file bool = file <<< (toString bool) + +instance <<< (a,b) | <<< a & <<< b +where + (<<<) file (x,y) = file <<< '(' <<< x <<< ", " <<< y <<< ") " + +instance <<< (a,b,c) | <<< a & <<< b & <<< c +where + (<<<) file (x,y,z) = file <<< '(' <<< x <<< ", " <<< y <<< ", " <<< z <<< ") " + +instance <<< (a,b,c,d) | <<< a & <<< b & <<< c & <<< d +where + (<<<) file (w,x,y,z) = file <<< '(' <<< w <<< ", " <<< x <<< ", " <<< y <<< ", " <<< z <<< ") " + +instance <<< (a,b,c,d,e) | <<< a & <<< b & <<< c & <<< d & <<< e +where + (<<<) file (v,w,x,y,z) = file <<< '(' <<< v <<< ", " <<< w <<< ", " <<< x <<< ", " <<< y <<< ", " <<< z <<< ") " + +instance <<< [a] | <<< a +where + (<<<) file [] = file <<< "[]" + (<<<) file l = showTail (file <<< "[") l + where + showTail f [x] = f <<< x <<< "] " + showTail f [a:x] = showTail (f <<< a <<< ", ") x + showTail f [] = f <<< "] " + +(--->) infix :: .a !b -> .a | <<< b +(--->) val message + | file_to_true (stderr <<< message <<< '\n') + = val + = abort "Internal error in --->" + +(-?->) infix :: .a !(!Bool, !b) -> .a | <<< b +(-?->) val (cond, message) + | cond && file_to_true (stderr <<< message <<< '\n') + = val + = abort "Internal error in --->" + +file_to_true :: !File -> Bool +file_to_true file = code { + .inline file_to_true + pop_b 2 + pushB TRUE + .end + } + +instance + {#Char} +where + (+) s t = s +++ t -- cgit v1.2.3