(: generated by: arc -uNMLP -o array.c -H array.h -m array.argl.tmp array.arg :) (:: : array.arg -- array and pointer manipulations : : Copyright (C) 2009,2010,2011,2014 the Argile authors : : This file is part of libargrt -- Argile runtime library. : : This software is provided 'as-is', without any express or implied : warranty. In no event will the authors be held liable for any damages : arising from the use of this software. : : Permission is granted to anyone to use this software for any purpose, : including commercial applications, and to alter it and redistribute it : freely, subject to the following restrictions: : : 1. The origin of this software must not be misrepresented; you must not : claim that you wrote the original software. If you use this software : in a product, an acknowledgment in the product documentation would be : appreciated but is not required. : : 2. Altered source versions must be plainly marked as such, and must not : be misrepresented as being the original software. : : 3. This notice may not be removed or altered from any source : distribution. :) use std; = :(raw) array (of () ): = - > (type) { Cgen ((t) . prefix) "(" (? ? 3 (Cgen "") (? ? 1 (Cgen "") (Cgen "*"))); Cgen (? ? 3 (Cgen "[" (n) "]") (? ? 1 (Cgen "[]"))) ")" ((t) . suffix); }; = : \[ ]: = - > (((a) . (type)) &) { Cgen_ref "&(" (a) ")[" (i) "]"; }; = : \[ ]: = - > ((a) . (type)) { Cgen "(" (a) ")[" (i) "]"; }; = : + : = - > (array of ((a) . (type))) { Cgen "(" (a) " + " (i) ")"; }; = :new array (of () ): = - > (array of (t)) { (memset (malloc ((size) * (size of (t)))) 0 ((size) * (size of (t)))) as (array of (t)); }; = :@ \[ [ ... 1,] ]: = - > (array of (type of (x))) { Cgen "(" (raw array of (type of (x))) "){" (@ (x)) "}"; }; = : \[ ] : = - > (array of ((t) @)) { Cgen "(" (((t) @) . prefix) "([])" (((t) @) . suffix) ")" (Cdata (data)); }; = :{pointer | *}: = - > (type) { Cgen ((t) . prefix) "*"; Cgen ((t) . suffix); }; = :* : = - > (((p) . t) &) { Cgen (p); }; = :& <(any) @ a>: = - > ((type of (a)) &) { a; }; = :& <(any) & a>: = - > ((type of (a)) *) { Cgen_ref "&" (a); }; = :alloc : = - > ((t) *) { (malloc (size of (t))) as ((t) *); }; = :for each <(any) & x> in (from ) to : = { let (int) for_each_iterator; for ((for_each_iterator) = (f)) ((for_each_iterator) < = (t)) ((for_each_iterator) + +) { (x) = ((a) [ (for_each_iterator) ]); call (c); }; }; # extern argc - > (int); # extern argv - > (array of (text));