diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2006-02-09 14:55:48 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2006-02-09 14:55:48 +0000 |
commit | 2ae43be7b9d4118335c9d2cef6e098f9b9f807fe (patch) | |
tree | bbb5e49ccbf7e3614966571acc317f8d318fecad /test/cminor/integr.cm | |
download | compcert-2ae43be7b9d4118335c9d2cef6e098f9b9f807fe.tar.gz compcert-2ae43be7b9d4118335c9d2cef6e098f9b9f807fe.zip |
Initial import of compcert
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/cminor/integr.cm')
-rw-r--r-- | test/cminor/integr.cm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/cminor/integr.cm b/test/cminor/integr.cm new file mode 100644 index 00000000..28f0a1de --- /dev/null +++ b/test/cminor/integr.cm @@ -0,0 +1,25 @@ +"square" (x): float -> float +{ + return x *f x; +} + +"integr"(f, low, high, n): int -> float -> float -> int -> float +{ + var h, x, s, i; + h = (high -f low) /f floatofint n; + x = low; + s = 0.0; + i = n; + {{ loop { + if (! (i > 0)) exit; + s = s +f (f(x): float -> float); + x = x +f h; + i = i - 1; + } }} + return s *f h; +} + +"test"(n) : int -> float +{ + return "integr"("square", 0.0, 1.0, n): int -> float -> float -> int -> float; +} |