1.1.12 fdoc2html initialisation 1.1.12 flx2html initialisation 1.1.12 cpp2html initialisation 1.1.12 cpp2html initialisation ocaml2html initialisation Py2html initialisation

Felix Library Contents


__init__.flx
algebraic.flx
0004:  class FloatAddgrp[t]

Additive symmetric float-approximate group, symbol +. Note: associativity is not assumed.

0006:    virtual fun zero: unit -> t
0020:    fun add(x:t,y:t)
0021:    fun plus(x:t)
0022:    fun sub(x:t,y:t)
0023:    fun neg(x:t)
0024:    proc pluseq(px:&t, y:t)
0025:    proc  minuseq(px:&t, y:t)
0030:  class Addgrp[t]

Additive symmetric group, symbol +.

0038:  class FloatMultSemi1[t]

Multiplicative symmetric float-approximate semi group with unit symbol *. Note: associativity is not assumed.

0040:    proc muleq(px:&t, y:t)
0041:    fun mul(x:t, y:t)
0042:    fun sqr(x:t)
0043:    fun cube(x:t)
0044:    virtual fun one: unit -> t
0052:  class MultSemi1[t]

Multiplicative semi group with unit.

0059:  class FloatRing[t]

Float-approximate ring.

0065:  class Ring[t]

Ring.

0072:  class FloatDring[t]

Float-approximate division ring.

0079:    fun div(x:t, y:t)
0080:    fun mod(x:t, y:t)
0081:    fun recip (x:t)
0083:    proc diveq(px:&t, y:t)
0084:    proc modeq(px:&t, y:t)
0088:  class Dring[t]

Division ring.

0095:  class Bits[t]

Bitwise operators.

0104:    fun bxor(x:t,y:t)
0105:    fun bor(x:t,y:t)
0106:    fun band(x:t,y:t)
0107:    fun bnot(x:t)
0112:  class Integer[t]

Integers.

0119:    fun shl(x:t,y:t)
0120:    fun shr(x:t,y:t)
0124:  class Signed_integer[t]

Signed Integers.

0126:    virtual fun sgn: t -> int
0127:    virtual fun abs: t -> t
0131:  class Unsigned_integer[t]

Unsigned Integers.

0137:  class Trig[t]

Float-approximate trigonometric functions.

0146:    virtual fun sin: t -> t
0147:    virtual fun cos: t -> t
0148:    virtual fun tan (x:t)
0150:    virtual fun sec (x:t)
0151:    virtual fun csc (x:t)
0152:    virtual fun cot (x:t)
0154:    virtual fun asin: t -> t
0155:    virtual fun acos: t -> t
0156:    virtual fun atan: t -> t
0158:    virtual fun asec (x:t)
0159:    virtual fun acsc (x:t)
0160:    virtual fun acot (x:t)
0164:    virtual fun sinh: t -> t
0165:    virtual fun cosh: t -> t
0166:    virtual fun tanh (x:t)
0168:    virtual fun sech (x:t)
0169:    virtual fun csch (x:t)
0170:    virtual fun coth (x:t)
0172:    virtual fun asinh: t -> t
0173:    virtual fun acosh: t -> t
0174:    virtual fun atanh: t -> t
0176:    virtual fun asech (x:t)
0177:    virtual fun acsch (x:t)
0178:    virtual fun acoth (x:t)
0181:    virtual fun exp: t -> t
0182:    virtual fun log: t -> t
0183:    virtual fun pow: t * t -> t
0187:  class Special[t]

Finance and Statistics.

0188:    virtual fun erf: t -> t
0189:    virtual fun erfc: t -> t
0193:  class Real[t]

Float-approximate real numbers.

0197:    virtual fun embed: int -> t
0199:    virtual fun log10: t -> t
0200:    virtual fun abs: t -> t
0201:    virtual fun sqrt: t -> t
0202:    virtual fun ceil: t -> t
0203:    virtual fun floor: t -> t
0204:    virtual fun trunc: t -> t
0208:  class Complex[t,r]

Float-approximate Complex.

0212:    virtual fun real: t -> r
0213:    virtual fun imag: t -> r
0214:    virtual fun abs: t -> r
0215:    virtual fun arg: t -> r

c_hack.flx
0006:  class C_hack

This class provides access to raw C/C++ encodings. Incorrect typing is likely to pass by Felix and be trapped by the C/C++ compiler. Incorrect management of storage can lead to corruption. The use of the C_hack class is necessary for interfacing.

0012:    type va_list

C void type. Incomplete, can't be instantiated. Standard variable argument list pointer type.

0016:    type __builtin_va_list

GCC specific valist thingo: it will be optimised away if not used (eg on MSVC).

0021:    proc ignore[t]:t

Throw away result of a function call: only useful for C functions that are mainly called for side effects.

0024:    fun cast[dst,src]: src->dst

C style cast.

0027:    fun static_cast[dst,src]: src->dst

C++ static cast.

0030:    fun dynamic_cast[dst,src]: src->dst

C++ dynamic cast.

0033:    fun const_cast[dst,src]: src->dst

C++ const cast.

0036:    fun reinterpret_cast[dst,src]: src->dst

C++ reinterpret cast.

0041:    fun reinterpret[dst,src]: src->dst

Felix reinterpret cast. More powerful than C++ reinterpret cast. Allows casting an rvalue to an lvalue.

0047:    fun eq[T]: gcptr[T] * gcptr[T] -> bool

Equality for gcptr

0055:    fun isNULL[t]: &t -> bool

Special lvalue deref for gcptr Special NULL check for Felix pointers. Should never succeed.

0059:    fun isNULL[t]: +t -> bool

Special NULL check for carray. Should never succeed.

0063:    fun isNULL[t]: gcptr[t] -> bool

Special NULL check for gcptr. Might succeed.

0074:    fun dflt[t]:1->t

Polymorphic null pointer constant Values of this type should not exist. This value is provided for checking. C++ default value for a type T. Workaround for g++ 3.2.2 parsing bug, it can parse T() as a default ctor call, but screws up on (T())

0087:    gen raw_malloc: !ints -> address

Raw unchecked malloc. Used typed malloc in carray if possible.

0091:    gen malloc: !ints -> address

Malloc with out of memory check. Throws c"out of memory" if out of memory.

0094:    proc free: address

Raw unchecked free.

0097:    proc destroy[T] : &T

Invoke C++ destructor


c_headers.flx
0004:  class C89_headers
0024:  class C95_headers
0033:  class C99_headers

carray.flx
0002:  open class Carray

A carray[T] = +T is an incrementable, non-NULL, pointer.

0008:    type carray[T]

The carray type.

0011:    typedef fun +(T:TYPE) : TYPE

Define prefix + notation.

0020:    fun n"&." [T]: carray[T] * !ints -> &T

Unsafe conversion of Felix pointer to carray. Demote carray to Felix pointer (safe unless off the end). a &. i returns pointer to i'th component of an array.

0023:    ctor[T] carray[T] : &T

Unsafe conversion of Felix pointer to carray.

0026:    ctor[T,N] carray[T]: &array[T,N]

Get a carray from a Felix array object.

0030:    fun array_alloc[T]: !ints -> carray[T]

Allocate a C array on the C heap (malloc). Unsafe: Not tracked by GC.

0034:    fun array_calloc[T]: !ints -> carray[T]

Allocate a C array on the C heap with 0 fill (cmalloc). Unsafe: Not tracked by GC.

0038:    proc free[T]: carray[T]

Free a C array (free). Must point to C heap allocated storage. Unsafe.

0041:    fun subscript[T]: carray[T] * !ints -> T

Lvalue reference to element by index position. Unsafe.

0047:    fun get[T]: carray[T] * !ints -> T

Lvalue reference to element by pointer. Functional get by index.

0051:    fun apply [T,I in ints] (i:I, x:carray[T])

Get by index using application. i x = x . i = get (x,i)

0054:    proc set[T] : carray[T] * !ints * T

Store value in array at index position.

0057:    fun stl_begin[T,N]: carray[array[T,N]] -> carray[T]

Get carray of an array.

0070:    proc pre_incr[T]: &carray[T]

Advance carray to next element. Backup carray to previous element. Calculate the offset in elements between two overlapping carrays. Mutable pre-increment ++p.

0073:    proc post_incr[T]: &carray[T]

Mutable post-increment p++.

0076:    proc pre_decr[T]: &carray[T]

Mutable pre-decarement --p.

0079:    proc post_decr[T]: &carray[T]

Mutable post-decarement p--.

0102:    fun array_of[T,N]: carray[T] -> &array[T,N]

Mutable advance by offset amount. Mutable backup by offset amount. Pointer equality. Pointer total ordering. Convert C array to Felix array.

0106:    proc memcpy: address * address * size

Fast byte-wise copy from address to address. WHY IS THIS HERE?

0112:    fun memcmp: address * address * size -> int

Fast bytewise comparison from address to address. WHY IS THIS HERE?

0120:    proc strcpy: carray[char] * carray[char]

C strcpy.

0123:    proc strncpy: carray[char] * carray[char] * !ints

C strncpy.

0126:    fun strlen: carray[char] ->size

C strlen: NTBS length.

0129:    gen strdup(s:carray[char])

Traditional NTBS strdup.


categ.flx
0002:  open class Categ

Categorical Operators

0013:    fun curry[u,v,r] (f:u*v->r) : u -> v -> r

change star into arrow (2 components)

0016:    fun curry[u,v,w,r] (f:u*v*w->r) : u -> v -> w -> r

change star into arrow (3 components)

0019:    fun uncurry2[u,v,r] (f:u->v->r) : u * v -> r

change arrow into star (arity 2)

0022:    fun uncurry3[u,v,w,r] (f:u->v->w->r) : u * v * w -> r

change arrow into star (arity 3)

0025:    fun twist[u,v,r] (f:u*v->r) : v * u -> r

argument order permutation (2 components)

0028:    fun proj1[u1,u2,r1,r2] (f:u1*u2->r1*r2) : u1 * u2 -> r1

projection 1 (2 components)

0032:    fun proj2[u1,u2,r1,r2] (f:u1*u2->r1*r2) : u1 * u2 -> r2

projection 2 (2 components)

0037:    fun ravel[u1,u2,r1,r2] (f1:u1->r1,f2:u2->r2) : u1 * u2 -> r1 * r2

parallel composition

0041:    fun compose[u,v,w] (f:v->w, g:u->v) : u -> w

series composition (2 functions)

0051:    fun rev_compose[u,v,w] (f:u->v, g:v->w) : u -> w

series reverse composition (2 functions)


codec/__init__.flx
codec/base64.flx
0004:  class Base64

Base64 encode/decode functions. http://en.wikipedia.org/wiki/Base64

0013:    gen make_string: size*char->string
0029:    fun encode (inp:string)

Returns base 64 encoding of supplied string inp.

0031:    fun encode (inp:string, iOff:int, iLen:int) : string
0066:    fun wrap (b64_str:string,ll:uint) : string

Wraps encoded string after ll chars, no newline on last line.

0083:    fun decode(enc_str:string)

Decodes supplied base 64 encoded string.


codec/csv.flx
0003:  class Csv

Comma Separated Values (CSV) reader Splits a string like 1,2,"hell" up into three strings.

0008:    proc get_csv_value(s:string, i:&int,res:&string)

Fetch a value string res from position i of string s. Update i past the comma ready to fetch another value.

0010:    proc add(j:int)
0013:    fun eq(a:state_t, b:state_t)
0044:    fun get_csv_values(s:string): list[string]

Fetch all the values in a CSV string and return them as list.


codec/uri_codec.flx
0015:  class URICodec
0058:    gen uri_encode: string -> string
0066:    fun uri_decode(encoded:string):string

control/__init__.fdoc
control/condition_variable.flx
0002:  open class Condition_Variable

Condition Variable for pthread synchronisation.

0007:    type condition_variable

The type of a condition variable.

0010:    ctor condition_variable: 1

Condition variable constructor taking unit argument.

0013:    proc destroy: condition_variable

Function to release a condition variable.

0017:    proc wait: condition_variable * mutex

Function to wait until a signal is raised on the condition variable by another thread.

0022:    proc signal: condition_variable

Function to raise a signal on a condition variable which will allow at most one thread waiting on it to proceed.

0026:    proc broadcast: condition_variable

Function to broadcast a signal releasing all threads waiting on a conditiona variable.

0030:    gen timedwait: condition_variable * mutex * double -> int

Timed wait for signal on condition variable. Time in seconds. Resolution nanoseconds.


control/control.flx
0001:  open class Control
0005:    proc forever (bdy:unit->void)

infinite loop

0014:    proc pass()
0017:    proc for_each

C style for loop

0039:    gen throw[ret,exn] : exn -> any

throw[ret, exn] throw exception of type exn in a context expecting type ret. It can only be used in an expecting context such as the argument of a function return or handler of a match expression. Felix does not check the ret type, since it sees the type is 'any'. The generated C++, however, will fail if the wrong type is used.

0043:    gen raise[exn] : exn -> any

raise is a statement/procedure which doesn't return. that is, it's the function throw with C++ type void.

0048:    proc fail:string

fail is a deprecated procedure which throws a C++ standard runtime_error with the given message string. It is deprecated because Felix cannot detect it never returns.

0058:    fun current_continuation: unit -> cont

This is the type of a Felix procedural continuations in C++ lifted into Felix. Do not confuse this with the Felix type of the procedure. This is a hack to get the procedural continuation currently executing, it is just the procedures C++ this pointer.

0084:    proc throw_continuation(x: unit->void)

The type of a Felix fthread or fibre, which is a container which holds a procedural continuation. Throw a continuation. This is unsafe. It should work from a top level procedure, or any function called by such a procedure, but may fail if thrown from a procedure called by a function. The library run and driver will catch the continuation and execute it instead of the current continuation. If the library run is used and the continuation being executed is down the C stack, the C stack will not have been correctly popped. Crudely, nested drivers should rethrow the exception until the C stack is in the correct state to execute the continuation, but there is no way to determine that at the moment.

Compiler generated runs ignore the exception, the library run catches it. Exceptions typically use a non-local goto, and they cannot pass across a function boundary.

0098:    union svc_req_t

Type of the implementation of a synchronous channel. should be private but needed in this class for the data type, and also needed in schannels to do the svc call. Felix-OS service call codes.

0118:    noinline proc svc(x:svc_req_t)

Procedure to perform a supervisor call. this interface just gets rid of the horrible requirement the request be in a variable so it is addressable. The _svc statement is a compiler intrinsic.


control/fibres.flx
0002:  open class Fibres

Low level management of Felix fthreads (fibres).

0007:    gen start[t] (p:t->0) (x:t)

Function to start a continution with argument type t.

0012:    gen start (p:1->0)

Function to start a contiuation without an argument.

0015:    gen mk_thread: cont->fthread

Function to make a fibre out of a continuation.

0019:    proc spawn_fthread(p:1->0)
0026:    proc schedule_fthread(p:1->0)
0034:    proc chain : cont
0037:    type fibre_scheduler

The type of a fibre scheduler.

0041:    ctor fibre_scheduler: 1

Construct a fibre scheduler. NOTE: NOT GARBAGE COLLECTED!

0044:    proc delete_fibre_scheduler : fibre_scheduler
0056:    proc spawn_fibre: fibre_scheduler * fthread

Spawn a fibre on a given scheduler with a given continuation.

0079:    fun get_state : fibre_scheduler -> fibre_scheduler_state

The type of the stop state of the fibre scheduler. terminated: the scheduler is terminated. blocked: the scheduler is out of threads to run. delegated: the scheduler has been issued a service request by a thread which it cannot satisfy. The scheduler is put in delegated state and awaits for another service to satisfy the request and put it back in operation.

Note: there is no "operating" state because the stop state can only be queried by the schedulers caller when the scheduler returns control to it.

0083:    proc spawn_fthread (fs:fibre_scheduler) (p:1->0)

Core user procedure for launching a fibre.

0086:    gen step: cont -> cont

Execute a single step of a fibre.

0089:    proc kill: fthread

Schedule death of a fibre.

0095:    proc run: cont

Run a continuation until it terminates. Do not use this proc if the underlying procedure attempts to read messages. This is a low level primitive, bypassing fthreads.

0134:    proc send[t] (p:&cont) (x:t)

Send a message to a continuation. There is no type checking on the message type. The procedure is executed until the next wait_state, then the message is stored. Low level primitive, bypassing fthreads.


control/forkjoin.flx
0002:  open class ForkJoin

Implement fork/join protocol.

0006:    proc concurrently_by_iterator (var it:1 -> opt[1->0])

Launch a set of pthreads and wait until all of them are finished.

0028:    proc concurrently[T with Streamable[T,1->0]] (d:T)

control/future.fdoc
0025:  open class Future
0071:    type future[T]
0115:    ctor[T] future[T] (e:1->T)
0130:    inline gen get[T](fut:future[T]):T
0141:    fun apply[T] (x:future[T], a:unit)

control/mutex.flx
0001:  open class Mutex
0006:    type mutex
0007:    ctor mutex: unit
0008:    proc lock: mutex
0009:    proc unlock: mutex
0010:    proc destroy: mutex

control/mux.flx
0003:  open class Multiplexor

Schannel multiplexor. Read multiple input schannels, write to an output schannel.

0006:    noinline proc copy[T] (i:ischannel[T],o:oschannel[T]) ()

Schannel copy.

0017:    proc mux[T] (inp:1->opt[ischannel[T]], out:oschannel[T]) ()

Schannel multiplexor based on iterator argument. Accepts stream of input schannels. Writes to output schannel.

0028:    fun mux[C,T with Streamable[C,ischannel[T]]] (a:C, out:oschannel[T])

Schannel multiplexor based on streamable data structure. Creates stream of input schannels. Writes to output schannel.


control/pchannels.flx
0009:  open class Pchannel

Pchannels are unbuffered synchronisation points for pre-emptive threads.

Similarly to schannels, paired reader-writer pthreads cannot proceed until both parties agree data exchange is complete. Unlike schannels, both reader and writer can subsequently continue concurrently after the exchange.

0014:    type pchannel[t]

Pre-emptive thread channels (monitor).

0016:    type ipchannel[t]

Pre-emptive thread input channel.

0018:    type opchannel[t]

Pre-emptive thread output channel.

0021:    fun mk_pchannel[t]: 1->pchannel[t]

Make bidirectional pchannel.

0024:    ctor[t] opchannel[t](x:pchannel[t])

Safe cast from bidirectional to output pchannel.

0026:    ctor[t] ipchannel[t](x:pchannel[t])

Safe cast from bidirectional to input pchannel.

0029:    fun mk_iopchannel_pair[t](var ch:pchannel[t])

Make an input and an output pchannel out of a bidirectional channel.

0034:    fun mk_iopchannel_pair[t]()

Construct a connected input and output pchannel pair.

0047:    proc _read[t]: pchannel[t] * &&t

Read from a pchannel.

0059:    noinline gen read[t] (chan:pchannel[t])

Write to a pchannel.

0064:    gen read[t] (chan:ipchannel[t])
0066:    proc _write[t]: pchannel[t] * &t
0077:    noinline proc write[t](chan:pchannel[t], v:t)
0081:    proc write[t] (chan:opchannel[t], v:t)

control/ppipe.flx
0003:  open class Ppipe

Asynchronous Synchronous Pipe. Used to link pthreads.

0006:    proc psource[T] (var it:1 -> T) (out:opchannel[T])

Send an stream down a channel.

0013:    proc pisrc[V,T with Streamable[T,V]] (dat:T) (out:opchannel[opt[V]])

isrc converts a streamable data structure such as an array into a source.

0021:    fun pipe[T]

Wire a source component to a sink. Return coupled fibre ready to run.

0036:    fun pipe[T,U]

Wire a source component to a transducer. Return source.

0052:    fun xpipe[V,T,U with Streamable[T,V]]

xpipe connects a streamable data structure such as an array directly into a transducer.

0064:    fun pipe[T,U,V]

Wire a transducer into a transducer. Return another transducer.

0080:    fun pipe[T,U]

Wire a transducer into a sink. Return a sink.

0097:    proc sort[T with Tord[T]] (r: ipchannel[opt[T]], w: opchannel[opt[T]])

Stream sort using intermediate darray. Requires stream of option type.


control/pthread.flx
0013:  open class Pthread

This class provides access to the operating system's native threading routines. On systems with multiple cpus, this may increase performance as the operating system may schedule threads on different processors.

0017:    type job_queue
0018:    type worker_task
0019:    gen mk_job_queue: int * int -> job_queue
0020:    proc add_worker_task : job_queue  * worker_task
0023:    proc spawn_pthread(p:1->0)

spawn a detached pthread.


control/schannels.flx
0005:  open class Schannel

Sychronous Channels. Used to exchange control and possibly data between Felix f-threads (aka fibres).

0017:    gen mk_schannel[t]: 1->schannel[t]

The type of a bidirectional synchronous channel. The type of an input synchronous channel. The type of an output synchronous channel. Create a bidirectional synchronous channel.

0026:    gen mk_null_schannel[t]: 1->schannel[t]

Model a NULL pointer as an schannel. Necessary for killing off schannels, so as to make them unreachable, so the gc can reap them. Note: null_schannels are safe.

0031:    gen mk_null_ischannel[t]: 1->ischannel[t]

Model a NULL pointer as an ischannel. Necessary for killing off schannels, so as to make them unreachable, so the gc can reap them.

0036:    gen mk_null_oschannel[t]: 1->oschannel[t]

Model a NULL pointer as an oschannel. Necessary for killing off schannels, so as to make them unreachable, so the gc can reap them.

0039:    fun isNULL[T] :schannel[T] -> bool

Check if an schannel is NULL.

0042:    fun isNULL[T] :ischannel[T] -> bool

Check if an ischannel is NULL.

0045:    fun isNULL[T] :oschannel[T] -> bool

Check if an oschannel is NULL.

0048:    ctor[t] oschannel[t](x:schannel[t])

Safe cast from bidirectional to ouput synchronous channel.

0051:    ctor[t] ischannel[t](x:schannel[t])

Safe cast from bidirectional to input synchronous channel.

0054:    gen mk_ioschannel_pair[t](var ch:schannel[t])

Make an input and an output channel out of a bidirectional channel.

0059:    gen mk_ioschannel_pair[t]()

Construct a connected input and output channel pair.

0064:    inline gen read[T] (chan:schannel[T])

Read an item from a bidirectional channel.

0071:    inline gen read[T] (chan:ischannel[T])

Read an item from an input channel.

0074:    proc write[T] (chan:schannel[T], v:T)

Write an item to a bidirectional channel.

0080:    proc broadcast[T] (chan:schannel[T], v:T)

Multi Write an item to a bidirectional channel.

0086:    proc write[T] (chan:oschannel[T], v:T)

Multi Write an item to an output channel.

0089:    proc broadcast[T] (chan:oschannel[T], v:T)

control/spipe.flx
0002:  open class Spipe

Synchronous Pipe.

0005:    proc source[T] (var it:1 -> T) (out:oschannel[T])

Send an stream down a channel.

0012:    proc isrc[V,T with Streamable[T,V]] (var dat:T) (out:oschannel[opt[V]])

isrc converts a streamable data structure such as an array into a source.

0020:    fun pipe[T]

Wire a source component to a sink. Return coupled fibre ready to run.

0035:    fun pipe[T0,T1]

Wire two sources to two sinks. Returns a SINGLE pipeline!

0054:    proc run_tee[T,N] (i:ischannel[T], oa:oschannel[T]^N)

Utility for tee connector: array of outputs

0067:    fun pipe[T,N]

Wire together a source component with an array of sinks. Returns a closed pipeline.

0091:    fun pipe[T,U]

Wire a source component to a transducer. Return source.

0107:    fun pipe[T0,T1,U0,U1]

Wire two source components to two transducers. Return two sources.

0135:    fun pipe[T,U0,U1]

Wire together a source component with two transducers Returns two sources.

0159:    fun xpipe[V,T,U with Streamable[T,V]]

xpipe connects a streamable data structure such as an array directly into a transducer.

0171:    fun pipe[T,U,V]

Wire a transducer into a transducer. Return another transducer.

0187:    fun pipe[T0,T1,U0,U1,V0,V1]

Wire two transducers into two transducers. Return two transducers.

0207:    fun pipe[T,U]

Wire a transducer into a sink. Return a sink.

0223:    fun pipe[T0,T1,U0,U1]

Wire two transducers into two sinks. Return two sinks.

0244:    proc sort[T with Tord[T]] (r: ischannel[opt[T]], w: oschannel[opt[T]])

Stream sort using intermediate darray. Requires stream of option type.


control/stream.flx
0005:  open class Streamable[ContainerType, ValueType]

Class of data structures supporting streaming. The container type just needs an iterator method. The iterator method returns a generator which yields the values stored in the container.

0006:    virtual fun iterator : ContainerType -> 1 -> opt[ValueType]

control/ts_bound_queue.flx
0001:  open class TS_Bound_Queue
0009:    ctor[T] ts_bound_queue_t[T]: !ints
0013:    proc enqueue[T] (Q:ts_bound_queue_t[T])  (elt:T)
0016:    gen dequeue[T] (Q:ts_bound_queue_t[T]): T
0017:    proc wait[T]: ts_bound_queue_t[T]
0018:    proc resize[T]: ts_bound_queue_t[T] * !ints

control/ts_counter.flx
0001:  open class Ts_counter
0003:    type ts_counter
0004:    ctor ts_counter : 1
0005:    proc destroy : ts_counter
0006:    gen pre_incr: ts_counter -> long
0007:    gen post_incr: ts_counter-> long
0008:    gen pre_decr: ts_counter -> long
0009:    gen post_decr: ts_counter -> long
0010:    gen decr_pos: ts_counter -> long
0011:    gen get: ts_counter -> long
0012:    proc set: ts_counter * long
0013:    gen swap: ts_counter * long -> long
0014:    proc wait_zero: ts_counter

cptr.flx
0005:  open class Cptr

Felix and C pointers. Felix pointer ptr[T] = &T. C pointer cptr[T] = &T. See also carray for incrementable pointers carray[T] = +T.

0011:    typedef ptr[T]

Type of a Felix pointer. Always points to an object. Cannot be NULL. Cannot be incremented.

0019:    union cptr[T]

Dereference a Felx pointer. Type of a C pointer. Either pointes to an object or is NULL. Cannot be incremented.

0022:    ctor[T] cptr[T]: &T

Demote a Felix pointer to a C pointer. Safe.

0027:    ctor[T] ptr[T]( px:cptr[T])

Promote a C pointer to a Felix pointer. Conversion is checked. Aborts with match failure if NULL.

0030:    fun deref[T] (px:cptr[T])

Checked dereference of C pointer.

0033:    fun is_nullptr[T] (px:cptr[T])

Test if a C pointer is NULL.


cstdlib.flx
0001:  open class Cstdlib
0007:    proc srand: uint

C89 Standard C library seed random number generator.

0011:    fun rand: unit -> int

C89 Standard C library random number generator. Known to be not very good. Try not to use it!


cxx_headers.flx
0001:  class Cxx_headers
0059:  class Cxx11_headers  // http://en.cppreference.com/w/cpp/header

datatype/__init__.fdoc
datatype/array.flx
0002:  open class Farray

Compile time fix length array.

0004:    typedef array[t,n]
0009:    fun copy[T,N] (var x:array[T,N])

Array copy.

0012:    ctor[T] array[T,1] (x:T)

Array of one element.

0016:    fun len (x:array[t, n]): size

Array as value.

0018:    fun unsafe_get (var a: array[t, n], j: size): t
0023:    fun len (x:&array[t, n]): size

Pointer to array as value.

0025:    fun unsafe_get: &array[t, n] * size  -> &t
0029:    proc unsafe_set[t,n] (a: &(t^n), i:size, v:t)
0030:    proc set[t,n, I in ints] (a: &array[t,n], i:I,v:t)
0036:    fun stl_begin[t,n]: &array[t,n] -> +t
0037:    fun stl_end[t,n] ( x:&array[t,n] ) : +t
0040:    fun map[V,N,U] (_f:V->U) (x:array[V,N]):array[U,N]

Array map.

0058:    fun join[T, N, M] (x:array[T, N]) (y:array[T, M]):array[T, N + M]

Join two arrays (functional).

0077:    fun join[T, N] (x:array[T, N]) (y:T):array[T, N + 1]

Append value to end of an array (functional).

0090:    fun join[T, M] (x:T) (y:array[T, M]):array[T, 1 + M]

Prepand value to start of an array (functional).

0111:    fun transpose[T,N,M] (y:array[array[T,M],N]) : array[array[T,N],M]

Join two arrays (functional). Transpose and array. Subsumes zip. Example: transpose ( (1,2,3), (4,5,6) ) = ( (1,4), (2,4), (3,6) ).

0127:    fun rev[T, N] (x:array[T, N]): array[T, N]

Reverse elements of an array.

0138:    fun sort[T,N] (cmp: T * T -> bool) (var x:array[T,N]) : array[T,N]
0143:    fun sort[T,N] (var x:array[T,N]) : array[T,N]
0151:    fun str (xs:array[T,N])

Display: convert to string like (1,2,3).


datatype/array_class.fdoc
0014:  class ArrayValue[t,v]

Array as Value (immutable).

0021:    virtual fun len: t -> size

Length.

0028:    virtual fun unsafe_get: t * size -> v

Unchecked common indexing.

0032:    fun get[I in ints] (x:t, i:I)

Checked common indexing.

0040:    virtual function so that the default definitions
0057:    fun apply [I in ints] (i:I, x:t)

Checked common indexing.

0062:    virtual proc iter (_f:v->void) (x:t)

Callback based value iterator.

0075:    virtual proc iiter (_f:size -> v->void) (x:t)

Callback based index and value iterator. Callback f index value.

0099:    gen iterator(xs:t) () : opt[v]

Stream value iterator.

0116:    virtual fun fold_left[u] (_f:u->v->u) (init:u) (x:t): u

Traditional left fold.

0132:    virtual fun fold_right[u] (_f:v->u->u) (x:t) (init:u): u

Traditional right fold.

0152:    virtual fun fold[u] (_f:u->v->u) (init:u) (x:t): u
0161:    virtual fun mem(pred:v->bool) (x:t): bool

Membership by predicate.

0180:    virtual fun mem[u] (rel:v*u->bool) (x:t) (e:u): bool

Membership by relation to given value.

0201:    virtual fun find(pred:v->bool) (x:t): opt[v]

Array as Set: Membership by equality of value type. Searching for value satisfying predicate.

0218:    virtual fun find (rel:v*v->bool) (x:t) (e:v): opt[v]

Searching for value satisfying relation to given value.

0249:  class TrueArrayValue [t,x,v]
0253:    fun true_unsafe_get (a:t, i:x)
0263:  class ArrayObject[t,v]

Array as Object (mutable).

0272:    virtual proc unsafe_set: t * size * v
0280:    virtual fun unsafe_get_ref : t * size -> &v
0287:    proc set[I in ints] (x:t, i:I, a:v)
0293:    fun n"&." [I in ints] (x:t, i:I) : &v
0303:  class TrueArrayObject[t,x, v]
0307:    proc true_unsafe_set(a:t, i:x, e:v)
0324:  class ContiguousArrayObject[t,v]

Array as Contiguous STL Object. Provides STL iterators type +v

0331:    virtual fun stl_begin: t -> +v

Start of array iterator.

0334:    virtual fun stl_end: t -> +v

One past the end of array iterator.

0352:    proc sort (cmp: v * v -> bool) (a:t)

Add integer to iterator. In place sort using STL sort with Felix comparator.

0363:    proc sort[with Tord[v]] (a:t)

In place sort using STL sort with default comparison.

0371:  class TrueContiguousArrayObject[t,x, v]

datatype/assoc_list.fdoc
0005:  open class Assoc_list
0007:    typedef assoc_list[A,B]
0011:    fun mem[A,B] (eq:A -> bool) (xs:assoc_list[A,B]) : bool
0017:    fun mem[A,B,T] (eq:A * T -> bool) (xs:assoc_list[A,B]) (e:T) : bool
0022:    fun mem[A,B with Eq[A]] (xs:assoc_list[A,B]) (e:A) : bool
0029:    fun find[A,B] (eq:A -> bool) (xs:assoc_list[A,B]) : opt[B]
0038:    fun find[A,B,T] (eq:A * T -> bool) (xs:assoc_list[A,B]) (e:T) : opt[B]
0042:    fun find[A,B with Eq[A]] (xs:assoc_list[A,B]) (e:A) : opt[B]

datatype/avl.flx
0001:  class Avl
0003:    union avl[T]
0010:    fun _ctor_avl[T] ()
0012:    fun _ctor_avl[T] (x : T, left : avl[T], right : avl[T])
0078:    fun insert[T] (tree : avl[T], y : T, cmp : T*T->int)
0093:    fun insert[T] (y : T, cmp : T*T->int)
0099:    fun find[T] (tree : avl[T], y : T, cmp : T*T->int) : opt[T]
0115:    fun last[T] : avl[T]->T
0120:    fun all_but_last[T] : avl[T]->avl[T]
0127:    fun first[T] : avl[T]->T
0132:    fun all_but_first[T] : avl[T]->avl[T]
0139:    fun join[T] (A : avl[T], B : avl[T])
0146:    fun remove[T] (tree : avl[T], y : T, cmp : T*T->int)
0162:    fun fold_left[T, U] (f:U->T->U) (accumulated:U) (tree:avl[T]):U
0170:    fun fold_right[T, U] (f:T->U->U) (tree:avl[T]) (accumulated:U)
0180:    proc iter[T] (f:T->void, tree:avl[T])
0192:    proc iter[T] (f:int*T->void, tree:avl[T])
0194:    proc aux (depth:int, f:int*T->void, tree:avl[T])

datatype/bsarray.flx
0005:  open class Bsarray

Bounded sparse array. Basically a sarray with a given bound. The bound is ignored for get and set methods. The bound is used for membership tests and iteration.

0008:    type bsarray[T]
0017:    fun len(b:bsarray[T])

Contruct with default value and bound. Contrue as array value.

0018:    fun unsafe_get(b:bsarray[T], i:size)
0023:    proc unsafe_set(b:bsarray[T], i:size, v:T)

Contrue as array object.

0041:    fun str (xs:bsarray[T])

Contrue as set: membership test. Convert to string.


datatype/darray.fdoc
0019:  open class Darray

Unbounded Variable length object array.

0067:    type darray[T]

This is the default array resize function. If we run out of space, allocate what we have + 50%. If we need less than half the allocated space, return the requested size + 50%. Otherwise return the existing allocated space. Type of a darray.

0081:    proc do_resize[T] (pd: darray[T], new_size: size)

Force a resize. Similar to C++ vector reserve function.

0090:    ctor[T] darray[T] ()

Make an empty darray, give it 20 slots for no particular reason.

0093:    ctor[T,N] darray[T] (a:array[T,N])

Make a darray from an array

0096:    ctor[T] darray[T] (a:varray[T])

Make a darray from a varray

0099:    ctor[T] darray[T] (a:darray[T])

Make a darray from a darray (copy)

0103:    ctor[T] darray[T] (n:size, default:T)

make a darray of a certain size initialised with some default value

0109:    fun len (a:darray[v])

Basic array value stuff.

0110:    fun unsafe_get (a:darray[v], i:size)
0117:    proc unsafe_set (b:darray[v],  n:size, x:v)

Basic array object stuff.

0118:    fun unsafe_get_ref (b:darray[v],  n:size) : &v
0125:    fun stl_begin(b:darray[v])

Contrue as contiguous store.

0126:    fun stl_end(b:darray[v])
0137:    proc pop[t](a:darray[t])

Pop a value from the end. Same as pop_back in C++.

0151:    proc push_back[t] (a:darray[t], v:t)

Push a value onto the end. Same as push_back in C++. Push a value onto the end. Same as push_back in C++.

0159:    proc insert[t] (a:darray[t], i:int, v:t)

insert

0170:    proc erase[t] (a:darray[t], i:int)

Erase an element, note doesn't resize the varray, probably should ..

0174:    proc erase[t] (a:darray[t], first:int, last:int)

Erase multiple elements, note doesn't resize the varray, probably should ..

0182:    fun str (x:darray[T])

Convert an array to a string, provided the element type is convertible.


datatype/judy.flx
0008:  class Judy
0014:    type word
0015:    ctor word: !ints
0016:    ctor word: address
0017:    ctor int: word
0018:    ctor uint: word
0019:    ctor ulong: word
0020:    ctor size: word
0021:    ctor address: word
0022:    fun isNULL: word -> bool
0023:    fun isNULL: &word -> bool
0025:    type JError_t
0030:    typedef void *voidp
0060:    gen _ctor_J1Array: 1 -> J1Array
0066:    proc free: J1Array
0068:    proc Judy1Set: J1Array * word * &JError_t * &int
0071:    proc Judy1Unset: J1Array * word * &JError_t * &int
0074:    proc Judy1Test: J1Array * word * &JError_t * &int
0085:    proc Judy1Count: J1Array * word * word* &JError_t * &word
0088:    proc Judy1ByCount: J1Array * word * &word * &JError_t * &word
0091:    proc Judy1FreeArray: J1Array * &JError_t * &word
0094:    proc Judy1MemUsed: J1Array * &word
0096:    proc Judy1First: J1Array * &word * &JError_t * &int
0099:    proc Judy1Next: J1Array * &word * &JError_t * &int
0102:    proc Judy1Last: J1Array * &word * &JError_t * &int
0105:    proc Judy1Prev: J1Array * &word * &JError_t * &int
0108:    proc Judy1FirstEmpty: J1Array * &word * &JError_t * &int
0111:    proc Judy1NextEmpty: J1Array * &word * &JError_t * &int
0114:    proc Judy1LastEmpty: J1Array * &word * &JError_t * &int
0117:    proc Judy1PrevEmpty: J1Array * &word * &JError_t * &int
0139:    gen _ctor_JLArray: 1 -> JLArray
0145:    proc free: JLArray
0148:    proc JudyLIns: JLArray * word * &JError_t * &&word
0151:    proc JudyLDel: JLArray * word * &JError_t * &int
0154:    proc JudyLGet: JLArray * word * &JError_t * &&word
0157:    proc JudyLCount: JLArray * word * word * &JError_t * &word
0160:    proc JudyLByCount: JLArray * word * &word * &JError_t * &&word
0163:    proc JudyLFreeArray: JLArray * &JError_t * &word
0166:    proc JudyLMemUsed: JLArray * &word
0169:    proc JudyLFirst: JLArray * &word * &JError_t * &&word
0172:    proc JudyLNext: JLArray * &word * &JError_t * &&word
0175:    proc JudyLLast: JLArray * &word * &JError_t * &&word
0178:    proc JudyLPrev: JLArray * &word * &JError_t * &&word
0181:    proc JudyLFirstEmpty: JLArray * &word * &JError_t * &word
0184:    proc JudyLNextEmpty: JLArray * &word * &JError_t * &word
0187:    proc JudyLLastEmpty: JLArray * &word * &JError_t * &word
0190:    proc JudyLPrevEmpty: JLArray * &word * &JError_t * &word
0216:    gen _ctor_JSLArray: 1 -> JSLArray
0222:    proc free: JSLArray
0226:    proc JudySLIns: JSLArray * +char * &JError_t * &&word
0232:    proc JudySLDel: JSLArray * +char * &JError_t * &int
0235:    proc JudySLGet: JSLArray * +char * &JError_t * &&word
0238:    proc JudySLFirst: JSLArray * +char * &JError_t * &&word
0241:    proc JudySLNext: JSLArray * +char * &JError_t * &&word
0244:    proc JudySLLast: JSLArray * +char * &JError_t * &&word
0247:    proc JudySLPrev: JSLArray * +char * &JError_t * &&word
0255:    type JHSArray
0256:    gen _ctor_JHSArray: 1 -> JHSArray
0258:    proc free: JHSArray
0263:    proc JudyHSIns: JHSArray * address * word * &JError_t * &&word
0266:    proc JudyHSDel: JHSArray * address * word * &JError_t * &int
0269:    proc JudyHSGet: JHSArray * address * word * &JError_t * &&word

datatype/list.fdoc
0005:  open class List
0009:    union list[T]
0033:    proc splice[T] : &list[T] * list[T]

The second list is made the tail of the list stored at the location pointed at by the first argument. If the first list is empty, the variable will point at the second list. This operation is DANGEROUS because it is a mutator: lists are traditionally purely functional.

0036:    struct node_t
0049:    proc rev[T,PLT

In place list reversal: unsafe!

0055:    struct node_t
0076:    proc rev_last[T,PLT
0082:    struct node_t
0104:    fun copy[T] (x:list[T]):list[T]

Copy a list.

0115:    proc copy_last[T] (inp:list[T], out:&list[T], last:&list[T])

Copy a list, and return last element as a list, empty if original list was empty.

0124:    ctor[T] list[T] ()

Make an empty list.

0133:    ctor[T] list[T] (x:T)

Make a list with one element. NOTE: list (1,2) is a list of 2 ints. To get a list of one pair use list[int*int] (1,2) instead!

0138:    ctor[T,N] list[T] (x:array[T, N])

Make a list from an array.

0154:    fun list_comprehension[T] (f: (1->opt[T]))

List comprehension: Make a list from a stream.

0156:    fun aux (l:list[T])
0174:    ctor[T] list[T](f: (1->opt[T]))

List comprehension: Make a list from a stream.

0184:    fun aux (acc:size) (x:list[T])

Contrue a list as an array value Return umber of elements in a list.

0203:    proc iter (_f:T->void) (x:list[T])

get n'th element Apply a procedure to each element of a list.

0214:    fun fold_left[U] (_f:U->T->U) (init:U) (x:list[T]):U

Traditional left fold over list (tail rec).

0216:    fun aux (init:U) (x:list[T]):U
0228:    fun fold_right[U] (_f:T->U->U) (x:list[T]) (init:U):U

Right fold over list (not tail rec!).

0230:    fun aux (x:list[T]) (init:U):U
0244:    pure fun is_empty[T] : list[T] -> 2

Test if a list is empty.

0252:    pure fun tail[T] (x:list[T]) : list[T]

Tail of a list, abort with match failure if list is empty.

0261:    pure fun head[T] (x:list[T]) : T

Head of a list, abort with match failure if list is empty.

0271:    fun rev_map[T,U] (_f:T->U) (x:list[T]): list[U]

map a list, return mapped list in reverse order (tail rec).

0272:    fun aux (inp:list[T]) (out:list[U]) : list[U]
0287:    fun map[T,U] (_f:T->U) (x:list[T]): list[U]

map a list (tail-rec).

0298:    pure fun rev[T] (x:list[T]):list[T]

reverse a list (tail rec).

0299:    fun aux (x:list[T]) (y:list[T]) : list[T]
0316:    fun zip2[T1,T2] (l1: list[T1]) (l2: list[T2]) : list[T1 * T2]

Zip two lists into a list of pairs. Zips to length of shortest list.

0318:    fun aux (l1: list[T1]) (l2: list[T2]) (acc: list[T1 * T2])
0332:    fun range (low:int, high:int, step:int)

Generate an ordered list of ints between low and high with given step. Low included, high not included.

0334:    fun inner(low:int, high:int, step:int, values:list[int])
0364:    fun range (low:int, high:int)

Range with step 1.

0370:    fun range (num:int)

Range from 0 to num (excluded).

0375:    fun join[T] (x:list[T]) (y:list[T]):list[T]

Concatenate two lists.

0408:    noinline fun cat[T] (x:list[list[T]]):list[T]

Concatenate two lists. Prepend element to head of list. Append element to tail of list (slow!). Append element to tail of list (slow!). Concatenate all the lists in a list of lists.

0421:    pure fun cat (sep:string) (x:list[string]):string

Concatenate all the strings in a list with given separator.

0434:    fun catmap[T] (sep:string) (f:T -> string) (ls: list[T])
0438:    fun strcat[T with Str[T]]  (sep: string) (ls: list[T])
0442:    fun strcat[T with Str[T]]  (ls: list[T])
0450:    fun mem[T] (eq:T -> bool) (xs:list[T]) : bool

Return true if one value in a list satisfies the predicate.

0460:    fun mem[T, U] (eq:T * U -> bool) (xs:list[T]) (e:U) : bool

Return true if one value in the list satisfies the relation in the left slot with the given element on the right slot.

0474:    fun find[T] (eq:T -> bool) (xs:list[T]) : opt[T]

Construe a list as a set, imbuing it with a membership test, provided the element type has an equality operator. return option of the first element in a list satisfying the predicate.

0485:    fun find[T, U] (eq:T * U -> bool) (xs:list[T]) (e:U) : opt[T]

Return option the first value in the list satisfies the relation in the left slot with the given element on the right slot.

0490:    noinline fun filter[T] (P:T -> bool) (x:list[T]) : list[T]

Return a sub list with elements satisfying the given predicate.

0492:    fun aux (inp:list[T], out: list[T])
0506:    fun prepend_unique[T] (eq: T * T -> bool) (x:list[T]) (e:T) : list[T]

Push element onto front of list if there isn't one in the list already satisfying the relation.

0512:    fun insert_unique[T] (eq: T * T -> bool) (x:list[T]) (e:T) : list[T]

Attach element to tail of list if there isn't one in the list already satisfying the relation.

0517:    fun remove[T] (eq: T * T -> bool) (x:list[T]) (e:T) : list[T]

Remove all elements from a list satisfying relation.

0523:    noinline fun append_unique[T] (eq: T * T -> bool) (x:list[T]) (e:T) : list[T]

Attach element to tail of list if there isn't one in the list already satisfying the relation (tail-rec).

0524:    fun aux (inp:list[T], out: list[T])
0537:    fun take[T] (k:int) (lst:list[T]) : list[T]

Take the first k elements from a list.

0549:    fun drop[T] (k:int) (lst:list[T]) : list[T]

Drop the first k elements from a list.

0562:    fun sort[T] (lt:T*T->bool) (x:list[T])

Sort a list with given less than operator, which must be total order. Uses varray sort (which uses STL sort).

0577:    fun sort[T with Tord[T]](x:list[T])

Sort a list with default total order. Uses varray sort (which uses STL sort).

0581:    gen iterator (var xs:list[T]) ()

Convert a list to a stream.

0603:    noinline fun str (xs:List::list[T])

datatype/option.flx
0004:    union opt[T]
0009:  open class Option
0012:    fun str (x:opt[T])
0022:    fun or_else[T] (x:opt[T]) (d:T) : T
0031:    fun or_else[T] (x:opt[T]) (alt:opt[T]) : opt[T]
0039:    proc iter[T] (_f:T->void) (x:opt[T])
0047:    ctor[T] list[T] (x:opt[T])
0055:    pure fun is_empty[T] : opt[T] -> 2
0061:    pure fun is_defined[T] : opt[T] -> 2
0067:    fun get[T] : opt[T] -> T
0073:    fun map[T,U] (_f:T->U) (x:opt[T]): opt[U]
0083:    fun filter[T] (P:T -> bool) (x:opt[T]) : opt[T]
0093:    gen iterator[T] (var x:opt[T]) ()
0099:  class DefaultValue[T]
0100:    virtual fun default[T]: 1->T
0102:    fun or_default[T]  (x:opt[T]) ()

datatype/ralist.flx
0009:  class Ralist

Purely functional Random Access List. Based on design from Okasaki, Purely Functional Datastructures. Transcribed from Hongwei Xi's encoding for ATS2 library.

An ralist provides O(log N) indexed access and amortised O(1) consing. This is roughly the closest thing to purely functional array available.

0013:    union pt[a]

Auxilliary data structure.

0016:    union ralist[a]

Type of an ralist.

0023:    fun ralist_length[a] : ralist[a] -> int

Length of an ralist.

0040:    fun ralist_cons[a] (x:a, xs: ralist[a])

Cons: new list with extra value at the head.

0045:    fun ralist_empty[a]: ralist[a] -> bool

Check for an empty list.

0074:    proc ralist_uncons[a] (xs: ralist[a], phd: &a, ptl: &ralist[a])

Proedure to split a non-empty ralist into a head element and a tail.

0084:    fun ralist_head[a] (xs: ralist[a]) : a

Head element of a non-empty ralist.

0093:    fun ralist_tail[a] (xs: ralist[a]) : ralist[a]

Tail list of a non-empty ralist.

0128:    fun ralist_lookup[a] (xs:ralist[a],i:int)

Random access to an ralist. Unchecked.

0169:    fun ralist_update[a] (xs:ralist[a], i:int, x0:a)

Return a list with the i'th element replaced by x0. Index is unchecked.

0210:    proc ralist_foreach[a]

Callback based iteration. Apply procedure to each element of the ralist.

0229:    fun str (xx: ralist[a]):string

Convert ralist to a string.


datatype/sarray.flx
0004:  open class Sarray

Unbounded sparse psuedo-array sarray. This data type is not a real array because it has no bounds and therefore cannot support iteration.

0010:    type sarray[T]

Type of a sarray.

0013:    ctor[T] sarray[T] (dflt:T)

Construct an infinite sarray with all values set to the given default.

0016:    fun get[T] (a:sarray[T], i:size) : T

Get the value at the given position.

0025:    proc set[T] (a:sarray[T], i:size, v:T)

Set the given value at the given position.

0048:    proc del[T] (a:sarray[T], i:size)

Replace the value at a given position with the default.

0068:    proc pack[T] (a:sarray[T])

Pack a sparse array. This is an optimisation with no semantics. Reorganises the sarray to reduce memory use and optimise lookup.


datatype/sexpr.fdoc
0005:  class S_expr
0007:    union sexpr[T]
0009:    fun fold_left[T,U] (_f:U->T->U) (init:U) (x:sexpr[T]):U
0015:    proc iter[T] (_f:T->void) (x:sexpr[T])
0022:    fun map[T,U] (_f:T->U) (x:sexpr[T]):sexpr[U]

datatype/slice.flx
0002:    union slice[T]
0010:    gen slice_range[T with Integer[T]] (first:T) (last:T) ()
0015:    gen iterator[t] (f:1->opt[t])
0030:    fun cal_slice (n:int, var b:int, var e:int)

datatype/sort.flx
0002:  class Sort

Utility class to leverage STL sort.

0009:    struct comparator

STL compliant comparator object built from a closure of a Felix function.

0021:    type stl_comparator[T]
0028:    ctor[T] stl_comparator[T] (cmp:T * T -> bool)

Make a C++ STL comparator object from a Felix comparison function.

0033:    proc stl_sort[T]: stl_comparator[T] * +T * +T

Invoke stl sort with C++ comparator.

0037:    inline proc stl_sort[T] (cmp: T * T -> bool, b: +T,  e:+T)

Invoke stl sort with Felix comparison function.

0042:    inline proc stl_sort[T with Tord[T]] (b:+T, e:+T)

Invoke stl sort default comparison function.


datatype/strdict.flx
0014:  class StrDict[T]

A strdict is dictionary keyed by strings. The strings must not contain nul bytes.

This is an ultra high performance data structure implemented using a JudySLArray. Typically about the same speed as a hashtable on exact key retrieval, but with the ability to perform linear key seeking as well. Linear seeking means searching for a key satisfying one of the total ordering relations to a given key, including ordered iteration.

Scales to terabytes. No other data structure can do this.

0018:    type strdict

Type of a strdict.

0021:    ctor strdict()

Construct and empty dictionary.

0023:    proc add (x:strdict) (key:string) (value: T)
0031:    ctor strdict ( kv: list[string * T] )

Construct a dictionary from a list of pairs.

0039:    fun get (x:strdict) (key: string) : opt[T]

Fetch a value optionally using the given key.

0047:    fun haskey (x:strdict) (key: string) : bool

Check if value is in the dictionary.

0059:    fun get_dflt (x:strdict) (key:string, dflt:T)

Fetch a value using the given key. If there is no value in the dictionary with that key, then return a default value.

0068:    gen del (x:strdict) (key: string) : bool

Remove a key/value pair from the dictionary if it exists. Return a boolean value signalling if it existed.

0077:    gen charp_get_ge (x:strdict) (var key: +char) : opt[T]

Get an optional value with key greater than or equal to the supplied NTBS (unsafe!)

0091:    fun get_ge (x:strdict) (var key: string)

Get an optional value with key greater than or equal to the supplied string. Safer than the NTBS version but slower. Fails if the string contains a nul byte.

0110:    gen charp_get_gt (x:strdict) (var key: +char)

Get an optional value with key greater than (>) the supplied NTBS (unsafe!)

0124:    fun get_gt (x:strdict) (var key: string)

Get an optional value with key greater than (>) the supplied string. Safer than the NTBS version but slower. Fails if the string contains a nul byte.

0143:    gen charp_get_le (x:strdict) (var key: +char)

Get an optional value with key less than or equal to (<=) the supplied NTBS (unsafe!)

0157:    fun get_le (x:strdict) (var key: string)

Get an optional value with key less than or equal to (<=) the supplied string. Safer than the NTBS version but slower. Fails if the string contains a nul byte.

0176:    gen charp_get_lt (x:strdict) (var key: +char)

Get an optional value with key less than (<) the supplied NTBS (unsafe!)

0190:    fun get_lt (x:strdict) (var key: string)

Get an optional value with key less than (<) the supplied string. Safer than the NTBS version but slower. Fails if the string contains a nul byte.

0209:    gen charp_first (x:strdict) (buffer:+char)

Get the optional first key in the dictionary into the supplied NTBS (unsafe!)

0215:    fun first (x:strdict) : opt[string * T]

Get the optional first key in the dictionary.

0220:    gen iterator (x:strdict) () : opt[string * T]

Stream iterator scanning through all key value pairs in the dictionary, in key order.

0236:    fun str(var x:strdict) : string

datatype/tuple.flx
0005:  class Tuple[U]
0006:    virtual fun tuple_str (x:U)
0010:    fun tuple_str (x: U ** V)
0018:    fun tuple_str (x: U * V)
0027:    fun str (x: U ** V)
0031:    fun str (t:T, u:U)
0034:    fun str (t1:T, t2:T)
0087:    fun field[n,t,u where n
0088:    fun field[n,t,u where n
0090:    fun field[n,t,u,v where n
0091:    fun field[n,t,u,v where n
0092:    fun field[n,t,u,v where n
0094:    fun field[n,t,u,v,w where n
0095:    fun field[n,t,u,v,w where n
0096:    fun field[n,t,u,v,w where n
0097:    fun field[n,t,u,v,w where n
0099:    fun field[n,t,u,v,w,x where n
0100:    fun field[n,t,u,v,w,x where n
0101:    fun field[n,t,u,v,w,x where n
0102:    fun field[n,t,u,v,w,x where n
0103:    fun field[n,t,u,v,w,x where n

datatype/unitsum.fdoc
0005:    typedef unitsums
0012:    fun zero ()
0019:    fun str(x:T)

datatype/varray.flx
0003:  open class Varray

Bounded Variable length arrays, bound set at construction time.

0010:    ctor[t] carray[t] : varray[t]

A varray is just a pointer. The current length and bound are maintained by the GC. An ordinary carray, but owned by the GC.

0013:    ctor[t] varray[t]: size

Create an empty varray with the given bound.

0023:    ctor[t] varray[t] (bound:size, default:t)

Raw memory initialisation (really, this belongs in C_hack). Construct a varray filled up with a default value.

0032:    ctor[t] varray[t] (bound:size, used:size, f:size->t when used <

Construct a partially filled varray with a default value computed by a function.

0042:    ctor[t,N] varray[t] (x:array[t,N])

Construct a full varray from an array.

0047:    ctor[t] varray[t] (x:varray[t], maxlen:size)

Construct a partially full varray from a varray.

0052:    ctor[t] varray[t] (x:varray[t])

Construct a full varray from a varray (copy constructor).

0057:    ctor[t] varray[t] (x:list[t])
0066:    ctor varray[char] (var x:string)

Construct a varray from a string. Include a trailing nul byte.

0084:    fun len: varray[v] -> size

Treat a varray as an ArrayValue. Length of a varray (used).

0089:    fun unsafe_get: varray[v] * size -> v

Unsafe get value at position.

0096:    proc unsafe_set: varray[v] * size * v

Treat a varray as an ArrayObject. Allows modifications. Store the given value at the given position.

0097:    fun unsafe_get_ref: varray[v] * size -> &v
0103:    fun stl_begin: varray[v] -> +v

Treat a varray as a ContiguousArrayObject. STL iterator to start of array.

0106:    fun stl_end: varray[v] -> +v

STL iterator to end of array.

0110:    fun maxlen[t]: varray[t] -> size

Get the bound of a varray.

0121:    proc push_back[t] : varray[t] * t

Append a new element to the end of a varray. Aborts if you go past the bound. Append a new element to the end of a varray. Aborts if you go past the bound.

0134:    proc pop[t] : varray[t]

Pop an element off the end of a varray. Aborts if the array is empty.

0148:    proc erase[v] (a:varray[v], first:int, last:int)

Erase elements of array between and including first and last. Include first and last, intersect with array span. Cannot fail.

0168:    proc erase[v] (a:varray[v], i:int)
0177:    proc insert[t] (a:varray[t], i:int, v:t)

insert (a,i,v) inserts v in a at position i that is, inserts before element i. If i is negative, position relative to end, that is, -1 is last element, so insert (a,-1,v) inserts before the last element (not after!) If i equals the length, element is appended. If the index is out of range, nothing happens.

0200:    fun map[T, U] (_f:T->U) (x:varray[T]): varray[U]

Traditional map varray to varray.

0214:    fun str (xs:varray[T])

Convert a varray[T] to a string. Requires Show[T]


db/__init__.flx
db/sqlite3/__init__.flx
db/sqlite3/sqlite3.flx
0039:  class Sqlite3

Core Sqlite3 functions and extensions to provide row iterator, simple statement execution, statement preperation and access to sqlite_step statement execution.

Iterator example:

   var db : sqlite3_db_t;
   var stmt:sqlite3_stmt_t;
   var err = sqlite3_open("multiple_sa.db", &db);
   if err != 0 do
     print "open DB error[abort] ";
     println $ sqlite3_errmsg db;
     goto finish;
   done;
   err = sqlite3_prepare_v2(db, "select * from contact", 21, stmt, "");
   if not err == (caseno SQLITE_OK) then
     { println ("sql error "+str(err)+":"+sqlite3_errmsg(db));goto finish; }
   else {
     var it = sqlite3_row_iterator (stmt);
     var row:ret_val[darray[column_value]];
     while (fun ():bool = { row = it();
                return (match row with |end_of_results[darray[column_value]] =>false |_ => true
                endmatch); }) () do
     var t = match row with 
       | row ?a =>  ((get_text_val(get(a,0))),(get_text_val(get(a,1))))
       | _ => ("","")
     endmatch;
     print t; endl;
     done
   }
   finish:>
     err = sqlite3_finalize(stmt);
     println(str(err));
     sqlite3_close(db);

0043:    type sqlite3_db_t

Type of a database handle.

0046:    gen sqlite3_open : string * &sqlite3_db_t -> int

Database open.

0051:    proc sqlite3_close : sqlite3_db_t

Database close.

0054:    typedef sqlite3_exec_callback_t

Type of an exec callback.

0069:    gen sqlite3_exec : sqlite3_db_t * string * sqlite3_exec_callback_t * address * &(+char) -> int

Quick sql execution using callback. arg1: db_handle arg2: sql statement. arg3: callback function. arg4: client data pointer. arg5: pointer to error message array. result: error code.

0077:    gen sqlite3_exec : sqlite3_db_t * string   * &(+char) -> int

quick sql execution without data handler callback. arg1: db_handle arg2: sql statement. arg3: pointer to error message array.

0083:    gen sqlite3_errmsg : sqlite3_db_t -> +char

Error message extractor.

0088:    type sqlite3_stmt_t

Type of sql statement handle.

0125:    fun to_sqlite3_result_code: int -> sqlite3_result_codes

Sqlite3 return codes. Conversion from int result to named return codes.

0174:    fun to_sqlite3_type: int -> sqlite3_types

Tag names for Sqlite3 data types. Allow checking for specific return codes. Conversion from int type to named Sqlite3 data type.

0184:    gen sqlite3_prepare_v2: sqlite3_db_t * string * int * sqlite3_stmt_t *string -> int

Prepare an sqlite3 statement for execution.

0188:    noinline gen sqlite3_step: sqlite3_stmt_t -> int

Execute one step of the prepared statement.

0191:    gen sqlite3_column_count: sqlite3_stmt_t -> int

Determine the number of columns (field) a statement will process.

0194:    gen sqlite3_column_name: sqlite3_stmt_t*int -> string

Determine the name of the n'th column to be processed.

0197:    gen sqlite3_column_type: sqlite3_stmt_t*int->int

Determine the type of the n'th column to be processed.

0200:    gen sqlite3_column_text: sqlite3_stmt_t*int->string

Fetch the value of a text field.

0203:    gen sqlite3_column_double: sqlite3_stmt_t*int->double

Fetch the value of a double field.

0206:    gen sqlite3_column_int: sqlite3_stmt_t*int->int

Fetch the value of a int field.

0209:    gen sqlite3_column_blob: sqlite3_stmt_t*int->&byte

Fetch the value of a blob field.

0212:    gen sqlite3_column_bytes: sqlite3_stmt_t*int -> int

Fetch the number of bytes of a field.

0217:    gen sqlite3_finalize: sqlite3_stmt_t -> int

Finish up with stepping a statement. Releases associated resources. The statement handle becomes invalid afterwards.

0220:    union column_value

A unified type to fetch a field value.

0228:    union ret_val[t]

A unified result of a statement.

0234:    union result_code[t]

A unified result code.

0239:    fun sqlite3_prepare_stmt (db:sqlite3_db_t,query:string):result_code[sqlite3_stmt_t]

Unified preparation of a query.

0249:    fun sqlite3_get_columns (stmt:sqlite3_stmt_t):darray[column_value]

Fetch all the columns of a query at once. Return them in a darray.

0268:    gen sqlite3_row_iterator (stmt:sqlite3_stmt_t) () :ret_val[darray[column_value]]

A stream iterator which returns successive rows of a table.

0285:    fun get_int_val: column_value->int

Get the int value out of a int typed field. Throws match failure if the field isn't an int type.

0289:    fun get_double_val:  column_value->double

Get the double value out of a double typed field. Throws match failure if the field isn't a double type.

0293:    fun get_text_val:  column_value->string

Get the text value out of a text typed field. Throws match failure if the field isn't a text type.

0296:    fun get_stmt: result_code[sqlite3_stmt_t]-> sqlite3_stmt_t

Get the statement handle out of a return code.

0299:    gen get_next ( iter:()->ret_val[darray[column_value]],row:&ret_val[darray[column_value]]):bool

Get the next row from an row iterator.

0309:    gen sqlite3_execute (stmt:sqlite3_stmt_t) :bool

Execute an prepared statement.

0329:    gen sqlite3_quote: string->string

Quote a string for use in a query.

0376:    typename lpar number rpar |
0377:    typename lpar number , number rpar

db/sqlite3/sqlite3_pool.flx
0003:  class Sqlite3Pool
0010:    fun sqlite3_pool(db_file:string):pool
0024:    proc destroy_member (m:sqlite3_db_t)

debug.flx
0003:    type flx_location_t
0005:  class Debug
0012:    fun filename: flx_location_t -> +char
0013:    fun startline: flx_location_t -> int
0014:    fun startcol: flx_location_t -> int
0015:    fun endline: flx_location_t -> int
0016:    fun endcol: flx_location_t -> int
0019:    fun str(var x:flx_location_t)
0030:    fun repr_expr[t]: t -> string

felix/__init__.flx
felix/cident.flx
0005:  class Cident

A function to convert a byte string into a legal C identifier in a canonical way. This routine should match the Ocaml function Flx_name.flxid_to_cid.

0010:    fun basename : string -> string

Basename of a filename. Hacky, not the real thing. Enough for calculating module names hopefully. Treats / and \ as path separators.

0015:    fun chop_extension : string -> string

Chop extension of a filename. Hacky, not the real thing. Enough for calculating module names hopefully. Treats / and \ as path separators.

0020:    fun flxid_to_cid : string -> string

Convert a "normal enough" Felix identifier to a C identifier. Does canonical replacement of chars illegal in C identifiers. Hacky, only supports ASCII, doesn't support i18n.

0025:    fun filename_to_modulename : string -> string

Convert a "normal enough" filename to a modulename. Uses all the above hacky stuff. Just please use sensible ASCII filenames!


felix/config.flx
0006:  class Config
0007:    typedef config_type
0020:    fun str (x:config_type) : string
0033:    fun empty_config() :config_type
0047:    proc cascade_FLX_INSTALL_DIR (x: &config_type)  (y: string)
0052:    proc cascade_FLX_TARGET_DIR (x: &config_type)  (y: string)
0057:    proc cascade_FLX_SHARE_DIR (x: &config_type)  (y: string)
0061:    proc cascade_FLX_HOME_DIR (x: &config_type)  (y: string)
0068:    proc process_config_text (cfg:&config_type) (text:string)
0110:    fun config () : config_type
0148:    process_config_text &cfg text

felix/flx/bootflx.flx
0029:  class BootFlx
0031:    gen flx_processing
0124:    gen runflx(args:list[string]) : int

felix/flx/flx.flx
0021:  class Flx
0023:    gen flx_processing
0120:    gen runflx(args:list[string]) : int

felix/flx/flx_cmdopt.flx
0006:  class FlxCmdOpt
0117:    proc setup-from-file (debugln: string -> 0)
0185:    proc debugln[T with Str[T]] (x:T)
0544:    proc debugln[T with Str[T]] (x:T)
0626:    noinline proc processing_stage1
0636:    proc debugln[T with Str[T]] (x:T)
0728:    fun link_strings ()
0750:    fun mkrel (d:string, f:string)

felix/flx/flx_config.flx
0003:  class FlxConfig
0005:    proc print_config(config:Config::config_type)

felix/flx/flx_control.flx
0001:  class FlxControl
0003:    proc print_options(control:control_type)
0038:    fun init_loopctl ()
0048:    typedef loopctl_type
0050:    fun dflt_control (config:Config::config_type)
0138:    typedef control_type

felix/flx/flx_depchk.flx
0003:    gen cxx_depcheck (tc: toolchain_t, src:string, dst:string) : bool
0018:    fun maxf (t:double) (f:string)
0047:    gen c_depcheck (tc: toolchain_t, src:string, dst:string) : bool
0062:    fun maxf (t:double) (f:string)

felix/flx/flx_depvars.flx
0003:  class FlxDepvars
0005:    typedef dvars_type
0021:    gen cal_depvars(
0029:    proc debugln[T with Str[T]] (x:T)

felix/flx/flx_plugin_client.flx
0001:  class Flx_client
0003:    proc setup ()

felix/flx/flx_run.flx
0005:    gen dxqt(DBG:bool) (cmd:string)
0027:    proc xdebugln[T with Str[T]] (d:bool) (x:T)
0032:    proc check_cache(
0058:    proc debugln[T with Str[T]] (x:T)
0062:    proc echoln[T with Str[T]] (x:T)
0076:    proc showtime(msg:string, t0:double)
0106:    proc calpackages
0137:    fun cal_time_from_flxdepfile (debugln: string->0, df: string):double
0139:    fun maxf (x: double) (f:string)
0151:    fun cal_files_time (fs: list[string])
0164:    fun cal_cxx_uptodate(debugln:string -> 0, OUTPUT_DIR:string, f:string)
0182:    gen check_cxx_uptodate () : bool
0197:    gen run_felix_compiler_if_required () : int
0264:    gen cxx_compile_dynamic1(src:string, dst:string) : int
0288:    gen cxx_compile_dynamic () : int
0311:    gen cxx_compile_static () : int
0356:    gen cxx_compile_static1 (src: string, dst: string) : int
0384:    gen run_cxx_compiler_if_required () : int
0398:    gen check_run_if_required_and_uptodate() : bool
0422:    gen run_with_calpackages () : int
0436:    gen cxx_link_dynamic () : int
0472:    gen cxx_link_dynamic_with_calpackages () : int
0478:    gen cxx_link_static () : int
0518:    gen cxx_link_static_with_calpackages() :  int
0524:    gen cxx_static_library () : int
0562:    gen check_binary_uptodate () : bool
0564:    fun maxf (t:double) (f:string)
0603:    gen run_linker_if_required() : int
0648:    gen run_program_dynamic () : int
0672:    gen run_program_static () : int
0689:    gen run_dynamic_with_calpackages () : int
0695:    gen run_program_if_required () : int
0713:    gen check_output_if_required () : int

felix/flx_cache.flx
0001:  class FlxCache
0003:    fun gramtime(debugln: string -> 0) (path:string, s:string) : double
0005:    fun maxtime (x:double) (s:string)
0053:    typedef cache_validation_spec_t
0095:    gen validate_cache  (spec: cache_validation_spec_t) : int * double
0199:    fun cache_join (c:string, var f:string)

felix/flx_cp.flx
0001:  class CopyFiles
0002:    proc processfiles
0013:    proc addfile(f:string)
0040:    proc rfi(dir: string)
0103:    proc copyfiles(basedir:string, re:RE2, tpat:string, live:bool, verbose:bool)
0104:    processfiles (FileSystem::filecopy) (basedir, re, tpat, live, verbose)
0107:    proc copyfiles(basedir:string, re:string, tpat:string, live:bool, verbose:bool)

felix/flx_cxx.flx
0001:  class CxxCompiler
0003:    typedef cxx_dep_spec_t
0012:    gen generic_cxx_gen_deps (spec: cxx_dep_spec_t) (src:string) : int * string
0032:    gen generic_dependency_parser (data:string) : list[string]
0042:    typedef cxx_dynamic_spec_t
0052:    gen generic_cxx_compile_for_dynamic (spec: cxx_dynamic_spec_t) (src:string, dst:string) : int
0073:    typedef link_dynamic_spec_t
0083:    gen generic_link_dynamic
0110:    typedef cxx_compile_static_t
0120:    gen generic_cxx_compile_for_static
0146:    typedef generic_link_static_t
0155:    gen generic_link_static
0175:    typedef generic_lib_static_t
0183:    gen generic_static_library

felix/flx_flxg.flx
0001:  class Flxg
0003:    typedef flxg_spec_t
0027:    gen run_felix_compiler (spec:flxg_spec_t) : int

felix/flx_gc.fdoc
0004:  class Collector
0007:    struct pointer_data_t
0021:    fun get_pointer_data (p:address)
0023:    fun is_felix_pointer (pd: pointer_data_t)
0024:    fun is_head_pointer (pd: pointer_data_t)
0025:    fun repeat_count (pd: pointer_data_t)
0026:    fun allocated_bytes (pd: pointer_data_t)
0032:    proc print_pointer_data (pd: pointer_data_t)

Diagnostic routine, dump pointer data and computed values.

0053:    proc print_pointer_data (p:address)

Diagnostic routine, print info about a pointer.

0058:    proc print_pointer_data[T] (p:&T)
0059:    proc print_pointer_data[T] (p:cptr[T])
0060:    proc print_pointer_data[T] (p:+T)

felix/flx_pkg.flx
0003:  class FlxPkg
0005:    typedef pkgconfig_inspec_t
0017:    typedef pkgconfig_outspec_t
0025:    fun fix2word_flags (fs: list[string])
0041:    gen map_package_requirements(spec:pkgconfig_inspec_t) : pkgconfig_outspec_t
0050:    gen pkgconfl(args:list[string]) : list[string]
0060:    gen pkgconfs(args:list[string]) : string
0138:    proc write_include_file(path:string, INCLUDE_FILES:list[string])

felix/flx_pkgconfig.flx
0005:  class FlxPkgConfig

felix/flx_pkgconfig_core.flx
0002:  class FlxPkgConfig_core
0006:    gen flx_pkgconfig (args:list[string]) : int * list[string]
0008:    proc print_help
0035:    proc pre_incr:&lex_iterator
0037:    fun lexit(ini:lex_iterator, finish:lex_iterator): lex_iterator * string
0082:    fun lexstr(s':string): list[string]
0123:    fun is_prefix_of(p:string,w:string)
0125:    fun xfind(flags: string, c: string)
0132:    proc parse_args(args:list[string])
0138:    fun prefix(x:string)
0211:    fun reattach_drive_letters : list[string] -> list[string]
0227:    fun check_id (s:string)
0233:    fun get_field(line:string):string * string
0243:    fun get_variable(line:string):string * string
0253:    proc add_val(v:string)
0258:    proc tail_val(v:string)
0263:    proc keep_val (v:string)
0267:    proc handle_pkg (pkg:string, trace:list[string])

felix/flx_pkgconfig_export.flx
0015:    gen mk_pkgconfig_query (a:FlxPkgConfigQuery_struct)

felix/flx_pkgconfig_query.flx
0004:  class FlxPkgConfig_query
0013:    fun aux (lst:list[string]) (out:list[string])

felix/flx_pkgconfig_query_interface.flx
0001:  class FlxPkgConfigQuery_interface

felix/flx_profile.flx
0001:  class FlxProfile
0003:    fun dflt_profile ()
0035:    typedef profile_type

felix/pkgtool/pkgtool_base.flx
0119:    union build_behavior

pkgtool_base.flx - PkgTool Core Author Mike Maul See README.md for more details #### Color output formatting #### Presentation Formatting Collection of functional display codes, with a display proc. Display for program activation of major section Display of current phast (e.g. build,test,install...) Header to indicate a group of related tasks Task display Similar for task_group but for tests Identifies related tests Displays name of test Fatal or unhandlable problem, abort program Fatal or unhandlable problem, abort program Indicator of invalid options passed to program Indicator of invalid command passed to program Indication of successful completion of phase or task_group Convey a warning in test, task, task group or phase

0162:    general_fail$ "HOME environment variable is not set.  Please set HOME before building."

### Core definitions

0218:  class PkgTool

### Globals parameters Package parameters var names below should be keys in cfg strdict #### Options populated from command line

0221:    fun join_list (strings:list[string],s:string)

### Helpers

0224:    fun join_list (strings:list[string])
0227:    gen fopen_append: string -> ofile
0237:    noinline  fun read_cfg(fn:string)

#### Package configuration file processing Process package definition which should be package README.md Pull parameter definitions of matching format KEY: VALUE Ignoreing any lines not matching format and stopping at first occurance of line starting with 5 or more dashes returns strdict[string] with keys/values

0261:    proc phase(label:string,step_p:unit->void)
0265:    proc task(task_s:string,task_p:unit->void)
0269:    proc task (s:string)
0271:    proc warning (s:string)
0273:    proc setup_fail(s:string)
0278:    proc general_fail(s:string)
0285:    proc test_result (status:bool)

Indication of test failure or success

0293:    noinline  proc imply(name:string)

#### Testing Reachability test if executed implies success

0299:    noinline  proc assert_true(result:bool,name:string,fail_message:string)

if result argument true test is successful, fail message if present is output on failure

0304:    proc assert_true(result:bool,name:string)
0307:    proc assert_true(result:bool)
0312:    noinline proc run_test(name:string,noheader:bool)

Test invocation

0316:    noinline  proc run_test(name:string,noheader:bool,fail_not_fatal:bool)
0339:    proc run_test(name:string)

See run_test:string*bool

0344:    proc test_fail(s:string)

Fatal or Sever test failure, aborts program

0349:    gen realpath: string->string

### Utilities

0352:    noinline  proc cp_root(s:string,p:string)

See cp_root:string*string*string

0357:    noinline  proc cp_root(s:string,p:string,dest:string)

Copy files using flx_cp

0371:    noinline  proc check_pkgconfig_path (unit)

Ensure user has PKG_CONFIG_PATH ser

0387:    fun WIFEXITED(x:process_status_t)
0388:    fun WEXITSTATUS(x:process_status_t)
0392:    fun run_cmd(cmd:string)

See run_cmd:string*string*bool

0397:    fun run_cmd (cmd:string,on_error:string)

See run_cmd:string*string*bool

0400:    noinline  fun run_cmd (cmd:string,on_error:string,echo:bool)
0406:    noinline  fun run_cmd (cmd:string,on_error:string,echo:bool,fail_not_fatal:bool)

Execute command string specified in command in shell consuming output. Redirects output to log. Non-zero result codes call setup_fail output from command is returned.

0430:    fun default_run_flx(file:string,on_error:string)
0434:    virtual fun run_flx(file:string,on_error:string)
0444:    noinline fun prompt(q:string,a:string)

Displays Question 'q' and acceptable single character answers 'a' of characters in a only alpha and numeric values will be considered a valid response and will be returned. If the first character of a is an uppercase character it will be considered the default answer and propmpt will return the first character in awnser if only a newline is recieved.

0461:    proc log(message:string)

#### Logging and console output Write output to file specified in SETUP_LOG

0466:    noinline  proc log(message:string,log_file:string)

Write output to file specified in log_file argument

0477:    proc display(message:string,log_file:string)

Write to console and log

0481:    proc display(message:string)
0492:    noinline  fun redir_err (cmd:string,to_file:string):string

Wrap command in shell redirection to append output to file specified in to_file arg Wrap command in shell redirection to append STDERR to file specified in to_file arg

0506:    noinline  fun find_path_to(name:string,paths:list[string])

#### Felix Package Config Utilities Locates path to to 'name' given list of 'paths'

0519:    noinline  proc create_fpc(name:string,description:string,ccflags:list[string],includes:list[string],

Creates 'name'.fpc file with 'description', 'cflags' and list of dynamic libraries 'dlibs' and static libraries 'slibs'

0543:    general_fail("Failed creating "+fpc_name)
0550:    noinline  proc create_config(name:string,includes:list[string],libs:list[string],

Determines proper configuration given package 'name', list of C/C++ 'includes' and list of C/C++ 'libs'. Then generates config/'name'.fpc Felix Package Config file

0558:    noinline  proc create_config(name:string,includes:list[string],libs:list[string],

Determines proper configuration given package 'name', list of C/C++ 'includes' and list of C/C++ 'libs'. Then generates config/'name'.fpc Felix Package Config file

0572:    general_fail("Unable to find " + inc +
0605:    noinline  proc test_config(name:string,reqs:list[string])
0636:    noinline  fun is_installed(name:string)

#### Package Utilities return opt version of package installed

0650:    noinline  proc handle_dependency(dependency:string)

Handle dependency specification in package README.md If a dependency is declared in DEPENDENCIES in the package README.md then handle_dependency will invoke 'scoop install to satisfy the dependency

0662:    general_fail(msg)
0674:    noinline  proc git_get(dest:string)

Request clone or pull from git repo specified in PKG_URL

0682:    noinline  proc git_get(url:string,dest:string)

Request clone or pull from git repo specified in PKG_URL

0714:    noinline  proc check_dependencies()

Phases/Command Implementations

0730:    noinline  proc default_build()

implementaion of default build behavior see README.md for discussion of behavior

0794:    virtual proc build()

To preform custom build behaior create instance of build. In most cases default_build should be called in instance

0804:    noinline  proc default_test()

implementaion of default test behavior see README.md for discussion of behavior Executes files in test directory not starting with 'C' or 'D' The 'C' prefix is reserved for functionality tests that may be used. The 'D' prefix is reserved for datafiles during build phase

0834:    virtual proc test()
0841:    noinline  proc default_install()

implementaion of default install behavior see README.md for discussion of behavior

0879:    virtual proc install()
0888:    noinline  fun study_history()

Reads package installation history. History consists of a file in the pgktool config format (see read_cfg) where keys are -\t The general idea is to have a set of records of package installations to a given felix installation

0911:    noinline  proc make_history (name:string)

Reads history, rewrites history and adds current install package to history

0919:    noinline  proc rewrite_history (prior_knowledge:strdict[string])

Reads history, rewrites history and adds current install package to history

0935:    noinline  fun dump_litterbox()

Return list of packages in litterbox

0968:    noinline  proc repeat_history()

Sometimes even those that study history are doomed to repeat it. Reinstalls package in history that do not exist in the felix installation. This is something that would be done after a new new felix installation

0989:    general_fail(msg)
1014:    noinline  proc default_clean()

implementaion of default clean behavior see README.md for discussion of behavior

1017:    proc clean_flx(file:string)
1079:    virtual proc clean()
1085:    proc help()

Help Command implementations

1133:    proc help_command (command:list[string])
1187:    noinline  fun installed()

Write list of installed packges to console

1209:    noinline  proc degitify()

See degitify:string

1214:    noinline  proc degitify(dir:string)

Strip .git directory from directory specified in dir

1225:    gen handle_global_options(options:list[string])

Argument processing

1253:    virtual proc run()

Implement instance for program run loop

1260:  class SetupTool
1264:    noinline  proc run()

Executes package phases


felix/rtti.flx
0001:  class Rtti
0004:    type collector_t

The type of the collector.

0007:    type gc_shape_t

The type of an RTTI record.

0008:    fun isNULL: gc_shape_t -> bool
0009:    typedef gc_shape_flags_t
0016:    typedef gc_finaliser_t

The type of a finalisation function.

0017:    typedef gc_encoder_t
0018:    typedef gc_decoder_t
0021:    fun next_shape: gc_shape_t -> gc_shape_t

Iterator to find the next shape after a given one.

0024:    fun cname: gc_shape_t -> +char

The C++ name of the Felix type.

0028:    fun number_of_elements: gc_shape_t -> size

The static number of elements in an array type. Note this is not the size of a varray!

0031:    fun bytes_per_element: gc_shape_t -> size

Number of bytes in one element.

0034:    fun finaliser: gc_shape_t -> gc_finaliser_t

The finaliser function.

0037:    fun encoder : gc_shape_t -> gc_encoder_t

The encoder function.

0040:    fun decoder: gc_shape_t -> gc_decoder_t

The decoder function.

0043:    fun uses_offset_table : gc_shape_t -> bool

Check for offset data

0047:    fun _unsafe_n_offsets: gc_shape_t -> size

The number of pointers in the base type. If the type is an array that's the element type.

0049:    fun n_offsets (shape: gc_shape_t) : size
0054:    fun _unsafe_offsets: gc_shape_t -> +size

Pointer to the offset table.

0056:    fun offsets (shape: gc_shape_t) : +size
0061:    fun flags: gc_shape_t -> gc_shape_flags_t

Flags.

0065:    fun shape_list_head : unit -> gc_shape_t

Global head of the compiled shape list. This is actually the first type, since they're linked together.

0068:    type type_info

C++ type_info for the type.

0071:    fun name : type_info -> string

C++ source name of the type.

0088:    fun gxx_demangle(s:string) :string

C++ Type_info of a type. For gcc only, the C++ name a mangled name represents.

0095:    proc _link_shape[T]: &gc_shape_t
0120:    gen link_shape[T]()

Put a new shape record into the global list. This routine constructs a new shape record on the heap. It fills in some of the data based on the type. It links the new record into the shape list. Then it stores the shape at the user specified address. Since the shape is represented in Felix by a pointer, subsequent modifications carry through to the linked shape object. This routine is only useful for adding a shape record for a statically known type: that's useful because not all statically known types get shape records: the compiler only generates them if the shape is required because an object of that type is allocated on the heap.


felix/serialise.fdoc
0004:  class Serialise
0011:    fun blit[T] (p: &T)

Encode binary image of a type, without length.

0012:    fun ncode [T] (var v: T)
0015:    gen unblit[T] (p: &T, s: +char, i:size) : size

Decode a type

0023:    fun encode_varray (p:address) : string
0053:    fun find_pointers (p:address) : list[address]
0083:    struct pclosure
0085:    processed: J1Array
0090:    ctor pclosure ()
0094:    proc add_pointer (self: &pclosure) (p:address)
0110:    gen iterator (self: &pclosure) () : opt[address]
0125:    fun find_closure (p:address) : list[address]
0152:    fun encode_closure (alst:list[address]) : string
0159:    fun encode_pointer_closure (p:address)
0163:    gen create_empty_varray : gc_shape_t * size -> address
0168:    proc set_used: address * size
0173:    gen decode_varray (ss:string) : address
0197:    gen decode_pointer_closure (ss:string) : address
0206:    gen create_objects () : address
0237:    proc adjust_pointer (pptr:&address)
0256:    proc adjust_all_pointers (newhead:address)

felix/sync.flx
0001:  class SyncControl
0010:    fun str: fstate_t -> string

Model of synchronous control state value. terminated: Not used. blocked: out of fthreads to run. delegated: non synchronous service call, delegate to our caller.

0026:    type fthread_list

Fthread state model. next_fthread_pos: restart scheduler by grabbing a new fthread from the active list. next_request_pos: restart scheduler by handling the service request of the currently active fthread. The type of a list of active fthreads to schedule.

0029:    ctor fthread_list: 1

Construct an empty fthread list.

0032:    proc delete : fthread_list

Delete an fthread list.

0035:    proc push_back: fthread_list * fthread

Push an fthread onto an fthread list.

0038:    ctor cont: (1->0)

Upcast a procedure closure to a continuation.

0041:    ctor fthread: cont

Create an fthread from a continuation.

0044:    type scheduler

Type of a synchronous scheduler.

0049:    ctor scheduler : fthread_list

Constructor for a synchronous scheduler. Accepts a list of fthreads to run. Uses the callers garbage collector.

0050:    proc delete: scheduler
0055:    proc run : scheduler

Invoke the scheduler and run until one of two events transpires: blocked, delegated.

0058:    fun get_scheduler_state : scheduler -> fstate_t

get the exit state of the scheduler after running.

0065:    proc run_proc (p: 1->0)

Run a single procedure as a fibre on new scheduler. This scheduler acts like a subroutine, control doesn't return to the caller until the scheduler queue is empty. This call cannot handle async I/O, so any attempt to do it will cause the program to abort.


felix/toolchain/clang_iphoneos.flx
felix/toolchain/clang_linux.flx
felix/toolchain/clang_osx.flx
felix/toolchain/gcc_linux.flx
felix/toolchain/gcc_osx.flx
felix/toolchain/msvc_win32.flx
felix/toolchain_clang_config.flx
0002:    typedef clang_config_t

felix/toolchain_interface.flx
flx_tclass.flx
0003:    typedef void
0004:    typedef unit
0005:    typedef bool
0009:  class IStream[f,t]
0010:    virtual gen read: f -> t
0013:  class OStream[f,t]
0014:    virtual proc write: f * t
0017:  class IOStream[f,t]
0024:  class IFile[f,t]
0028:  class OFile[f,t]
0030:    virtual proc close: f
0035:  class IBuffer [f]
0036:    virtual gen read: f -> address * int -> int * bool
0039:  class OBuffer [f]
0040:    virtual gen write : f -> address * int -> int * bool
0050:  class Set[c,t]
0051:    fun mem (elt:t, container:c):bool
0056:  class Container [c,v]
0059:    virtual fun len: c -> size
0060:    virtual fun empty(x: c): bool
0065:  class Monad [M: TYPE->TYPE]
0066:    virtual fun bind[a,b]: M a * (a -> M b) -> M b
0067:    virtual fun ret[a]: a -> M a
0072:  class Str [T]
0073:    virtual fun str: T -> string
0076:  class Repr [T with Str[T]]
0077:    virtual fun repr (t:T) : string
0080:  class Show [T]
0088:    fun str (x:void)
0095:    fun str (x:unit)

gc.flx
0004:  open class Gc

Generic garbage collector interface. This class provides a generic interface to the GC, that is, one that is independent of the GC representation.

0006:    fun _collect: unit -> ulong
0010:    proc collect()

Invoke the garbage collector.

0021:    fun gc_get_allocation_amt : unit -> ulong

Get the total number of bytes currently allocated.

0025:    fun gc_get_allocation_count : unit -> ulong

Get the total number of objects currently allocated.

0029:    fun gc_get_root_count : unit -> ulong

Get the total number of roots.

0032:    proc add_root: address
0035:    proc remove_root: address

glob.flx
0007:  class glob
0018:    gen glob: string * &glob_t -> bool
0019:    proc globfree: &glob_t
0021:    gen glob (pat:string): stl_vector[string]

io/__init__.flx
io/ansi_terminal.flx
0003:  class AnsiTerminal

#### Color output formatting for Ansi Terminals.

0006:    fun  NC_ ()
0007:    fun  NC_(s:string)
0008:    proc NC()
0009:    proc NC(s:string)
0010:    fun blue_()
0011:    fun blue_(s:string)
0012:    proc blue()
0013:    proc blue(s:string)
0014:    fun BLUE_()
0015:    fun BLUE_(s:string)
0016:    proc BLUE()
0017:    proc BLUE(s:string)
0018:    fun cyan_()
0019:    fun cyan_(s:string)
0020:    proc cyan()
0021:    proc cyan(s:string)
0022:    fun CYAN_()
0023:    fun CYAN_(s:string)
0024:    proc CYAN()
0025:    proc CYAN(s:string)
0026:    fun green_()
0027:    fun green_(s:string)
0028:    proc green()
0029:    proc green(s:string)
0030:    fun GREEN_()
0031:    fun GREEN_(s:string)
0032:    proc GREEN()
0033:    proc GREEN(s:string)
0034:    fun red_()
0035:    fun red_(s:string)
0036:    proc red()
0037:    proc red(s:string)
0038:    fun RED_()
0039:    fun RED_(s:string)
0040:    proc RED()
0041:    proc RED(s:string)
0042:    fun yellow_()
0043:    fun yellow_(s:string)
0044:    proc yellow()
0045:    proc yellow(s:string)
0046:    fun YELLOW_()
0047:    fun YELLOW_(s:string)
0048:    proc YELLOW()
0049:    proc YELLOW(s:string)

io/demux.flx
0002:  class Demux
0004:    type demuxer
0007:    gen mk_sys_demux: 1->demuxer

io/directory.flx
0003:  class Directory_class[os,mode_t]

File system directory services, Parametrised by operating system and mode type.

0007:    virtual gen mkdir: string * mode_t -> int

Create a directory with specified mode. Returns 0 if successful.

0011:    virtual gen mkdir: string -> int

Create a directory with default mode. Returns 0 if successful.

0015:    virtual proc mkdirs: string

Try to ensure all the directories in a path exist. Does not return any error indication.

0017:    virtual gen unlink_empty_dir: string -> int
0023:    virtual fun filesin:string -> opt[List::list[string]]

Return an option list of all the regular files in a given directory. Returns None if the directory does not exist or isn't accessible. Returns Some ?files if the directory exists and is accessible. If the directory has no regular files, the list is Empty.

0026:    virtual fun getcwd: 1 -> string

Get the absolute pathname of the current working directory.

0029:    virtual fun mk_absolute_filename: string -> string

Convert a relative filename to an absolute pathname.

0034:  class Directory

Host file system directory services. Platform dependent.


io/faio.flx
0001:  class Faio
0007:    proc faio_req[t](x:&t)
0012:    proc get_thread(thread: &fthread)
0016:    type sel_param
0017:    type sel_param_ptr
0019:    fun get_bytes_done : sel_param_ptr -> int
0020:    proc init_pb : sel_param*address*int
0023:    proc calc_eof(pb: sel_param_ptr, len: &int, eof: &bool)
0035:    type sleep_request
0036:    type alarm_clock
0038:    fun mk_alarm_clock: 1 -> alarm_clock
0039:    fun mk_sleep_request: alarm_clock * double -> sleep_request
0041:    proc sleep(clock: alarm_clock, delta: double)

io/filename.flx
0002:  class Filename_class[os]

Operations on filenames.

0005:    virtual fun sep: 1 -> string

The path separator.

0006:    virtual fun is_absolute_filename : string -> bool
0008:    virtual fun executable_extension : 1 -> string
0009:    virtual fun static_object_extension: 1 -> string
0010:    virtual fun dynamic_object_extension: 1 -> string
0011:    virtual fun static_library_extension: 1 -> string
0012:    virtual fun dynamic_library_extension: 1 -> string
0022:    fun split1(s:string)

split1 returns a pair consisting of a directory name and basename with the separator between them lost except in the special case "/x" where the "/" is kept as the directory name. If there is no separator, the path is the basename and the directory name is the empty string (NOT . !!!)

0039:    fun split(s:string)

split a filename into a list of components.

0048:    fun join(p:string, b:string)

Join two pathnames into a single pathname. split and join are logical inverses, however join is not not associative: join("x", join("","y")) = "x/y" whereas join(join("x",""),"y") = "x//y" since split pulls components off from the RHS we have to fold them back from the left

0057:    fun basename(s:string)

Get the basename of a path (last component).

0060:    fun dirname(s:string)

Get the directory name of a path (all but the last component).

0064:    fun directories (s:string) : list[string]

Return a list of all the directory names in a path. For example a/b/c gives "a", "a/b"

0072:    fun join(a:string, b:string, c:string)

Join 3 and 4 strings into a pathname.

0073:    fun join(a:string, b:string, c:string,d:string)
0076:    fun join(x:string) (y:string)

Join 2 strings into a pathname (curried form).

0079:    fun join(ps: List::list[string])

Join all the strings in a list into a pathname.

0086:    fun split_extension (s:string): string * string

Split off extension. Includes the dot. Invariant: input = basename + extension. Works backwards until it hits a dot, path separator, or end of data. If a dot, strip it and the tail of the string, otherwise return the original string.

0099:    fun strip_extension (s:string)

Remove an extension from a filename if there is one.

0102:    fun get_extension (s:string)

Get extension if there is one. Includes the dot.

0107:  class Win32Filename

Windows Filenames

0111:    fun sep()
0112:    fun executable_extension ()
0113:    fun static_object_extension()
0114:    fun dynamic_object_extension()
0115:    fun static_library_extension()
0116:    fun dynamic_library_extension()
0117:    fun is_absolute_filename (f:string)
0126:  class OsxFilename

OSX Filenames

0130:    fun sep()
0131:    fun executable_extension ()
0132:    fun static_object_extension()
0133:    fun dynamic_object_extension()
0134:    fun static_library_extension()
0135:    fun dynamic_library_extension()
0136:    fun is_absolute_filename (f:string)
0142:  class PosixFilename

Posix Filenames

0146:    fun sep()
0147:    fun executable_extension ()
0148:    fun static_object_extension()
0149:    fun dynamic_object_extension()
0150:    fun static_library_extension()
0151:    fun dynamic_library_extension()
0152:    fun is_absolute_filename (f:string)
0157:  class Filename

Host Filenames.


io/filestat.flx
0003:  class FileStat_class[OS,stat_t, mode_t]

Filesystem file kind query functions parametrised by operating system, status type and mode type.

0007:    virtual proc stat: string * &stat_t * &int

Get information about a file into a status buffer. Sets error code at argument 3 pointer.

0012:    virtual proc utime: string * double * double * &int

set access and modification time of a file. Sets error code at argument 4 pointer. Times are in seconds, nominally from Epoch (Jan 1 1970).

0018:    virtual gen chmod: string * mode_t -> int

Change read,write permissions for group, owner etc. Return 0 on success. On Windows this function may silently fail to obey unsupported operations.

0023:    virtual gen umask: mode_t -> mode_t

set mask for subsequent permissions. On Windows this function may silently fail to obey unsupported operations.

0026:    union file_type_t

Abstracted platform independent file type taxonomy.

0040:    virtual fun file_type: &stat_t -> file_type_t

Get the file type from a file stat buffer.

0043:    gen stat(file: string, statbuf:&stat_t)

Fill a stat buffer with information about a file.

0051:    fun mtime: &stat_t -> double

Get a file last modification time from a stat buffer. Time is in seconds.

0056:    fun ctime: &stat_t -> double

Get a file creation time from a stat buffer. Note: not available on Unix. Time is in seconds.

0060:    fun filetime(f:string):double

Get modification time of a file by name. Time is in seconds.

0069:    gen utime(f:string, a:double, m:double): bool

Set the last access and modification time of a file by name.

0077:    gen utime(f:string, t:double)

Set the last access and modification time of a file by name, where the two times are given by a single argument.

0080:    fun fileexists(f:string):bool

Check if a file exists.

0083:    fun filetype(f:string):file_type_t

Find the type of a file.

0097:    fun past_time ()
0098:    fun future_time ()
0100:    fun strfiletime0 (x:double)
0109:    fun strfiletime (x:double)
0114:    fun dfiletime(var f:string, dflt:double)
0126:  class FileStat

Platform dependent operations for host file system.


io/filesystem.flx
0003:  class FileSystem_class[os]

Filesystem operations parametrised by operating system. YET TO BE DONE.

0008:  class FileSystem

Platform dependent filesystem operations for host file system.

0015:    proc unlink(f:string)
0017:    proc aux (d:string) (b:string)
0045:    proc rm (f:string)
0048:    fun find_in_path(x:string, path:list[string]):opt[string]

Find a file in a list of directories.

0070:    fun regfilesin(dname:string, re:string): list[string]

Find all the files matching an RE2-regular expression in a given directory. NOTE: this search finds files in descendant directories too. The search is recursive, but the whole pathname within the specified directory must match the regexp. For example to find all *.flx files in src use: regfilesin("src", ".*[.]flx") To find the files only in the given directory, on Unix use instead regfilesin("src", "[^/]*[.]flx") to exclude files in child directories.

0073:    fun regfilesin(dname:string, re:RE2): list[string]

Find all the files matching a compiled RE2-regular expression.

0077:    proc rfi(dname2: string)

io/manymouse.flx
0001:  class ManyMouse
0014:    struct ManyMouseEvent
0024:    gen  ManyMouse_Init: 1 -> int
0025:    fun  ManyMouse_DriverName: 1 -> string
0028:    proc ManyMouse_Quit: 1
0029:    fun  ManyMouse_DeviceName: uint -> string
0032:    gen  ManyMouse_PollEvent: &ManyMouseEvent -> int

io/socket.flx
0001:  class Socket
0005:    typedef socket_t
0007:    typedef socket_t
0010:    proc mk_listener(l: &socket_t, port: &int, qlen: int)
0019:    proc accept(l: socket_t, s: &socket_t)
0033:    proc shutdown(s: socket_t, how: int)
0042:    proc connect(s: &socket_t, addr: +char, port: int, err: &int)
0058:    proc read(s: socket_t, len: &int, buf: address, eof: &bool)
0061:    proc read(s: socket_t, len: &int, buf: address, eof: &bool)
0069:    proc write(s: socket_t, len: &int, buf: address, eof: &bool)
0076:    proc write(s: socket_t, len: &int, buf: address, eof: &bool)
0086:    proc iclose (s:socket_t)
0089:    proc iclose (s:socket_t)
0097:    proc oclose (s:socket_t)
0100:    proc oclose (s:socket_t)
0108:    proc ioclose (s:socket_t)
0124:    proc ioclose (s:socket_t)

io/stream.flx
0001:  class Stream
0009:    typedef fd_t
0012:    typedef fd_t
0018:  class IByteStream[T]
0024:  class OByteStream[T]
0030:  class IOByteStream[T]
0036:  class TerminalIByteStream[T]
0044:  class TerminalOByteStream[T]
0052:  class TerminalIOByteStream[T]
0062:    union devnull_t
0067:    proc read(strm: devnull_t, len: &int, buf: address, eof: &bool)
0075:    proc write(strm: devnull_t, len: &int, buf: address, eof: &bool)
0090:    proc read(fd: fd_t, len: &int, buf: address, eof: &bool)
0101:    proc write(fd: fd_t, len: &int, buf: address, eof: &bool)
0114:    proc iclose (fd: fd_t)
0125:    proc oclose (fd: fd_t)
0136:    proc ioclose (fd: fd_t)
0148:    proc cat[istr,ostr with IByteStream[istr], OByteStream[ostr]] (
0167:    proc cat[istr,ostr with IByteStream[istr], OByteStream[ostr]] (
0181:    proc cat[istr,ostr with IByteStream[istr], OByteStream[ostr]] (
0193:    proc stream_cmp[istr1,istr2 with IByteStream[istr1], IByteStream[istr2]] (
0240:    proc cmp[istr1, istr2 with IByteStream[istr1], IByteStream[istr2]] (
0254:    proc echo[iostr with IOByteStream[iostr]] (
0264:    proc tee[istr,ostr with IByteStream[istr], OByteStream[ostr]] (
0289:    noinline proc get_line[istr with IByteStream[istr]] (
0316:    proc write_string[ostr with OByteStream[ostr]] (

io/textio.flx
0007:  class Input_text_file[input_text_file]

These classes provide simple I/O for text, primarily intended for naive use, debugging etc. This is because there is no error handling. This simplifies usage at the expense of correctness, and so these routines should not be used in production code. Abstract input file.

0010:    virtual gen fopen_input: string -> input_text_file

Open file for reading.

0013:    virtual gen valid : input_text_file -> bool

Check if the file was opened correctly.

0016:    virtual proc fclose: input_text_file

Close file.

0019:    virtual gen load: input_text_file -> string

Load the rest of an open file.

0023:    virtual gen readln: input_text_file -> string

Read one line with the trailing end-line mark included. Empty string indicates end of file.

0026:    virtual gen feof : input_text_file -> bool

Check for end of file.

0030:  class Output_text_file[output_text_file]

Abstract output file.

0033:    virtual gen fopen_output: string -> output_text_file

Open file for writing.

0036:    virtual gen valid : output_text_file -> bool

Check if the file was opened correctly.

0039:    virtual proc fclose: output_text_file

Close file.

0042:    virtual proc writeln : output_text_file * string

Write one line adding the trailing end line mark.

0045:    virtual proc write : output_text_file * string

Write a string.

0048:    virtual proc write : output_text_file * utiny

Write a byte.

0051:    virtual proc write : output_text_file * char

Write a char.

0054:    virtual proc fflush: output_text_file

Flush the buffers.

0057:    proc save (fn:string, d:string)

Save string to file

0066:    proc save (fn:string, lines:list[string])
0074:    proc space (s:output_text_file)

Write a space.

0077:    proc endl (s:output_text_file)

Write end of line mark.

0080:    proc fprint[T with Str[T]] (s:output_text_file, x:T)

Write data with conversion using Str::str.

0083:    proc fprintln[T with Str[T]] (s:output_text_file, x:T)

Write data with conversion using Str::str and end line mark.

0087:  open class Cstdio

C standard IO with FILE*.

0090:    type FILE

C file type.

0092:    pod type ifile
0093:    pod type ofile
0097:    fun load: string -> string

Load file from filename. Note: loaded in binary mode not text mode!

0122:    gen fopen_input: string -> ifile

Standard input, can be redirected by flx_run. Standard output, can be redirected by flx_run. Standard error, can be redirected by flx_run. Standard input, redirected by shell. Standard output, redirected by shell. Standard error, redirected by shell. C standard IO as instance of Input_text_file.

0123:    gen valid : ifile -> bool
0124:    proc fclose: ifile
0125:    gen load: ifile -> string
0126:    gen readln: ifile -> string
0127:    gen feof : ifile -> bool
0133:    gen fopen_output: string -> ofile

C standard IO as instance of Output_text_file.

0134:    gen valid : ofile -> bool
0135:    proc fclose: ofile
0136:    proc writeln : ofile * string
0137:    proc write : ofile * string
0138:    proc write : ofile * utiny
0139:    proc write : ofile * char
0140:    proc fflush: ofile
0148:  open class Iostream
0151:    pod type istream

istream type.

0154:    pod type ostream

ostream type.

0171:    gen fopen_input: string -> istream

Standard input, redirected by shell. Standard output, redirected by shell. Standard error, redirected by shell. Standard log, redirected by shell. C++ istream as instance of Input_text_file.

0172:    gen valid : istream -> bool
0173:    proc fclose: istream
0174:    gen load: istream -> string
0175:    gen readln: istream -> string
0176:    gen feof : istream -> bool
0182:    gen fopen_output: string -> ostream

C++ ostream as instance of Output_text_file.

0183:    gen valid : ostream -> bool
0184:    proc fclose: ostream
0185:    proc writeln : ostream * string
0186:    proc write : ostream * string
0187:    proc write : ostream * utiny
0188:    proc write : ostream * char
0189:    proc fflush: ostream
0204:    proc print  [T with Str[T]] (x:T)

DEBUG OUTPUT UTILITIES! DO NOT REQUIRE THREAD FRAME. NOT REDIRECTABLE BY DRIVER. (can be redirected by OS if OS can do it) Write string to output.

0207:    proc println[T with Str[T]] (x:T)

Write string to output with end of line.

0210:    proc endl()

Write end of line on output.

0213:    proc space()

Write space on cout.

0216:    proc fflush()

flush buffers of cout.

0219:    proc eprint  [T with Str[T]] (x:T)

Write string to cerr.

0222:    proc eprintln[T with Str[T]] (x:T)

Write string to cerr with end of line.

0225:    proc eendl()

Write end of line on cerr.

0228:    proc espace()

Write space on cerr.


io/zmq.flx
0006:  class ZeroMQ
0016:    proc zmq_version: &int * &int * &int
0017:    fun zmq_version()
0034:    fun zmq_errno : 1-> errno_t
0035:    fun zmq_strerror : errno_t -> string
0037:    gen ewrap(var x:int)
0039:    proc zmq_validate (msg:string) (var retcode: int)
0045:    proc zmq_validate (var retcode: int)
0047:    fun zmq_check (msg:string) (var retcode:int)
0054:    fun zmq_check(var retcode: int)
0060:    typedef zmq_free_fn
0066:    gen make_zmq_msg_t : 1 -> zmq_msg_t
0069:    gen zmq_msg_init: zmq_msg_t->int
0070:    gen zmq_msg_init_size: zmq_msg_t * size -> int
0071:    gen zmq_msg_init_data: zmq_msg_t * address * size * zmq_free_fn * address -> int
0072:    gen zmq_msg_close: zmq_msg_t -> int
0074:    gen zmq_msg_move: zmq_msg_t * zmq_msg_t -> int
0075:    gen zmq_msg_copy: zmq_msg_t * zmq_msg_t -> int
0076:    fun zmq_msg_data: zmq_msg_t -> address
0077:    fun zmq_msg_size : zmq_msg_t -> size
0080:    pod type zmq_message_option_code_t
0083:    fun zmq_getmsgopt: zmq_msg_t * zmq_message_option_code_t * address * &size -> int
0089:    pod type zmq_context
0092:    gen zmq_init : int  -> zmq_context
0093:    gen zmq_term : zmq_context -> int
0099:    pod type zmq_socket
0101:    ctor zmq_socket : zmq_context * zmq_socket_type_t
0102:    gen zmq_close: zmq_socket -> int
0103:    gen zmq_bind : zmq_socket * string -> int
0104:    gen zmq_connect : zmq_socket * string -> int
0105:    fun valid: zmq_socket->bool
0118:    fun str: zmq_socket_type_t -> string
0148:    fun str:zmq_sockopts_tag-> string
0176:    union zmq_socket_options
0203:    fun str: zmq_socket_options -> string
0249:    gen set_sockopt(s: zmq_socket) (o: zmq_socket_options)
0275:    proc get_sockopt[T:blobkind](s:zmq_socket, o:zmq_sockopts_tag, pd:&T, ps: &size)
0301:    gen getsockopt(s: zmq_socket, o: zmq_sockopts_tag) : zmq_socket_options
0338:    gen zmq_send : zmq_socket * address * size * zmq_xmit_options_t -> int
0339:    gen zmq_recv : zmq_socket * address * size * zmq_xmit_options_t -> int
0340:    gen zmq_sendmsg : zmq_socket * zmq_msg_t * zmq_xmit_options_t  -> int
0341:    gen zmq_recvmsg : zmq_socket * zmq_msg_t * zmq_xmit_options_t -> int
0346:    type zmq_pollitem_flag_t
0350:    ctor short: zmq_pollitem_flag_t
0353:    fun str(x:zmq_pollitem_flag_t)
0363:    type zmq_poll_item
0364:    ctor zmq_poll_item: zmq_socket * zmq_pollitem_flag_t
0365:    fun revents: zmq_poll_item -> zmq_pollitem_flag_t
0367:    gen zmq_poll: carray[zmq_poll_item] * int * long -> int
0369:    gen zmq_poll(pits : varray[zmq_poll_item], t:double)
0380:  class Checked_ZeroMQ[T]
0384:    proc init_size (x:zmq_msg_t) (n:size)
0385:    proc init (x:zmq_msg_t)
0386:    proc close (x:zmq_msg_t)
0388:    fun _ctor_zmq_msg_t ()
0390:    proc init_string (x:zmq_msg_t) (s:string)
0397:    ctor string: zmq_msg_t
0399:    fun zmq_more(m:zmq_msg_t):bool
0408:    fun zmq_more (s:zmq_socket)
0414:    proc send_msg (s:zmq_socket) (m:zmq_msg_t)
0415:    proc send_string (s:zmq_socket) (m:string)
0416:    proc send_string_part (s:zmq_socket) (m:string)
0417:    proc recv_msg (s:zmq_socket) (m:zmq_msg_t)
0418:    proc recv_msg_dontwait (s:zmq_socket) (m:zmq_msg_t)
0419:    gen recv_string (s:zmq_socket)
0428:    gen recv_string_dontwait (s:zmq_socket)
0437:    ctor zmq_context : int
0438:    proc term (x:zmq_context)
0440:    fun check_socket(var x:zmq_socket)
0441:    gen mk_socket (c: zmq_context) (t:zmq_socket_type_t)
0442:    proc set_opt(s: zmq_socket) (o: zmq_socket_options)
0443:    fun get_opt(s: zmq_socket) (o: zmq_sockopts_tag) : zmq_socket_options
0445:    proc bind(x:zmq_socket) (a:string)
0446:    proc connect(x:zmq_socket) (a:string)
0447:    proc close (s:zmq_socket)
0449:    gen poll(pits:varray[zmq_poll_item], timeout:double)
0452:    proc send_strings (s:zmq_socket) (ss:varray[string])
0462:    proc send_strings (s:zmq_socket) (ss:list[string])
0466:    gen recv_strings (s:zmq_socket) : varray[string]
0479:    type zmq_ehandler_t
0482:    fun ehandler():any
0489:  class ZMQ

linux/linux.flx
0004:    fun get_cpu_nr: 1 -> int

linux/smaps.flx
0017:  class Smaps
0019:    struct smaps_metric
0036:    fun getpid: ()->Process::pid_t
0038:    fun pid_touint: Process::pid_t->uint
0040:    fun uint_topid: uint->Process::pid_t
0042:    fun min_whitespace(s:string)
0060:    fun smaps_total(p:Process::pid_t,path:string):smaps_metric

order.flx
0003:  class Eq[t]
0011:    fun eq(x:t, y:t)
0012:    fun ne(x:t, y:t)
0016:  class Pord[t]
0028:  class Tord[t]
0043:    fun lt (x:t,y:t): bool
0044:    fun gt(x:t,y:t):bool
0045:    fun le (x:t,y:t):bool
0046:    fun ge (x:t,y:t):bool
0047:    fun max(x:t,y:t):t
0048:    fun min(x:t,y:t):t
0052:  class Forward[t]
0053:    virtual fun succ: t -> t
0054:    virtual proc pre_incr: &t
0055:    virtual proc post_incr: &t
0058:  class Bidirectional[t]
0060:    virtual fun pred: t -> t
0061:    virtual proc pre_decr: &t
0062:    virtual proc post_decr: &t

osx/__init__.flx
0001:    struct Osx

posix/__init__.flx
0001:    struct Posix

posix/directory.flx
0001:  class PosixDirectory
0004:    type dirent_t
0005:    type DIR_t
0006:    proc opendir: string * &DIR_t
0007:    fun isNULL: DIR_t -> bool
0008:    fun isNULL: dirent_t -> bool
0009:    proc readdir: DIR_t * dirent_t * &dirent_t * &int
0010:    proc closedir: DIR_t
0011:    fun filename: dirent_t -> string
0019:    gen mkdir: string * PosixFileStat::mode_t -> int
0020:    gen mkdir: string  -> int
0021:    proc mkdirs (s:string)
0031:    gen unlink_empty_dir : string -> int
0034:    fun getcwd():string
0039:    fun mk_absolute_filename(s:string)
0043:    fun filesin(dname:string): opt[List::list[string]]

posix/errno.flx
0001:  open class Errno
0003:    pod type errno_t
0004:    ctor int : errno_t
0005:    ctor errno_t : int
0021:    proc maybe_exit(var n:int)
0022:    proc maybe_exit(var n:errno_t)
0023:    proc maybe_exit()
0028:    proc strerror_r: errno_t *  carray[char] * size
0032:    proc strerror_r: errno_t * carray[char] * size
0036:    fun strerror(e:errno_t) : string
0048:    gen strerror()
0054:  class Check[T]
0056:    proc int_to_proc (var x:int)
0057:    fun int_to_int (var x:int)
0058:    fun pointer_to_pointer[U] (var p:&U)
0062:    type check_ignore
0065:    fun ehandler ():any
0067:    type check_throw
0070:    fun ehandler ():any

posix/faio_posix.flx
0001:  class Faio_posix
0014:    fun sys_job_queue_qbound()
0015:    fun sys_job_queue_nthreads()
0019:    typedef fd_t
0022:    type socket_t
0026:    type socklen_t
0027:    ctor socklen_t : int
0028:    ctor int : socklen_t
0039:    type sa_family_t
0042:    type in_port_t
0049:    type sockaddr_storage_t
0050:    fun ss_family : &sockaddr_storage_t -> sa_family_t
0053:    type sockaddr_t
0054:    fun sa_family : &sockaddr_t -> sa_family_t
0057:    fun sockaddr_p : &sockaddr_storage_t -> &sockaddr_t
0063:    type in_addr_t
0064:    type struct_in_addr
0065:    fun s_addr: struct_in_addr -> in_addr_t
0068:    type sockaddr_in_t
0069:    fun sin_family: sockaddr_in_t -> sa_family_t
0070:    fun sin_port : sockaddr_in_t -> in_port_t
0071:    fun sin_addr : sockaddr_in_t -> struct_in_addr
0072:    fun sin_addr : &sockaddr_in_t -> &struct_in_addr
0078:    type struct_in6_addr
0079:    typedef ipv6_addr
0080:    fun s6_addr: struct_in6_addr -> &ipv6_addr
0083:    type sockaddr_in6_t
0084:    fun sin6_family: sockaddr_in6_t -> sa_family_t
0085:    fun sin6_port : sockaddr_in6_t -> in_port_t
0086:    fun sin6_addr : sockaddr_in6_t -> struct_in6_addr
0087:    fun sin6_addr : &sockaddr_in6_t -> &struct_in6_addr
0095:    fun inet_ntop: sa_family_t * address * +char * socklen_t -> +char requires arpa_inet_h;
0102:    fun str: FileSystem::posix_file -> string
0106:    fun str: socket_t -> string
0109:    fun getpeername: socket_t * &sockaddr_t * &socklen_t -> int
0111:    fun getpeername (s: socket_t) : string
0173:    proc close: socket_t
0174:    proc shutdown: socket_t*int
0175:    fun bad_socket : socket_t -> bool
0179:    gen aio_ropen: string -> FileSystem::posix_file
0181:    gen aio_wopen: string -> FileSystem::posix_file
0183:    gen aio_rwopen: string -> FileSystem::posix_file
0185:    gen aio_creat: string * posix_permissions-> FileSystem::posix_file
0190:    type socketio_request
0192:    gen mk_socketio_request: demuxer * socket_t*address*int*bool -> socketio_request
0195:    fun get_pb: socketio_request -> sel_param_ptr
0198:    proc async_rw(fd: socket_t, len: &int, buf: address, eof: &bool, read_flag: bool)
0209:    proc async_read(fd: socket_t, len: &int, buf: address,
0215:    proc async_write(fd: socket_t, len: &int, buf: address, eof: &bool)
0222:    type flxfileio_request
0225:    type async_connect
0227:    fun mk_async_connect: demuxer * +char *int-> async_connect
0228:    fun get_socket: async_connect -> socket_t
0229:    fun get_err: async_connect -> int
0232:    proc connect(s: &socket_t, addr: +char, port: int, err: &int)
0240:    type accept_request
0242:    fun mk_accept: demuxer * socket_t -> accept_request
0243:    fun get_socket: accept_request -> socket_t
0246:    proc mk_listener: &socket_t* &int *int
0249:    proc accept(s: &socket_t, listener: socket_t)
0259:    fun mk_faio: job_queue * FileSystem::posix_file *address*int*int*bool -> flxfileio_request
0261:    fun get_pb: flxfileio_request -> sel_param_ptr
0263:    proc faio_rw(q:job_queue, fd: FileSystem::posix_file, len: &int, buf: address, eof: &bool, read_flag: bool)
0271:    proc faio_read(fd: FileSystem::posix_file, len: &int, buf: address,
0279:    proc faio_write(fd: FileSystem::posix_file, len: &int, buf: address, eof: &bool)

posix/filestat.flx
0001:  class PosixFileStat
0003:    pod type stat_t
0005:    pod type mode_t
0046:    fun raw_mode: &stat_t -> mode_t
0047:    fun file_type(m:mode_t)
0048:    fun file_perm(m:mode_t)
0050:    ctor uint: mode_t
0057:    proc stat: string * &stat_t * &int
0059:    proc utime: string * double * double * &int
0071:    gen chmod: string * mode_t -> int
0072:    gen umask: mode_t -> mode_t
0074:    fun file_type (s:&stat_t): file_type_t

posix/filesystem.flx
0001:  class PosixFileSystem
0006:    pod type file_perm_t
0026:    pod type posix_file
0027:    fun valid: posix_file -> bool
0028:    ctor int : posix_file
0033:    gen open: string * file_perm_t * PosixFileStat::mode_t -> posix_file
0034:    gen open: string * file_perm_t -> posix_file
0036:    gen ropen: string -> posix_file
0037:    gen wopen: string -> posix_file
0038:    gen rwopen: string -> posix_file
0039:    gen creat: string * PosixFileStat::mode_t-> posix_file
0041:    gen close: posix_file -> int
0042:    gen read: posix_file * &char * size -> size
0043:    gen write: posix_file * &char * size -> size
0045:    gen dup: posix_file -> posix_file
0046:    gen dup2: posix_file * posix_file -> posix_file
0048:    struct _piper_hack
0060:    gen pipe ()
0062:    gen fdopen_input: posix_file ->  ifile
0063:    gen fdopen_output: posix_file ->  ofile
0068:    gen unlink_file: string -> int
0074:    gen rename_file: string * string -> int
0081:    gen filecopy(src: string, dst: string) :  bool
0149:    gen tmp_filename: 1 -> string

posix/mmap.flx
0001:  class Mmap
0012:    typedef off_t
0014:    type mmap_prot
0024:    type mmap_flags
0073:    fun mmap:
0083:    fun munmap: address * size -> int
0086:    fun msync: address * size * int -> int

posix/posix_headers.flx
0001:  class Posix_headers

posix/process.flx
0001:  class PosixProcess
0006:    gen popen_in: string -> Cstdio::ifile
0007:    gen pclose: Cstdio::ifile -> process_status_t
0011:    type process_status_t
0012:    ctor int:process_status_t
0013:    ctor process_status_t : int
0014:    fun int_of_process_status_t: process_status_t -> int
0016:    fun WIFCONTINUED: process_status_t -> bool
0017:    fun WIFEXITED: process_status_t -> bool
0018:    fun WIFSIGNALED: process_status_t -> bool
0019:    fun WIFSTOPPED: process_status_t -> bool
0021:    fun WEXITSTATUS: process_status_t -> int
0022:    fun WTERMSIG: process_status_t -> signal_t
0023:    fun WSTOPSIG: process_status_t -> signal_t
0026:    fun  WCOREDUMP: process_status_t -> int
0029:    fun str(x:process_status_t)
0043:    type exec_result_t
0047:    gen execv:+char *  + +char -> exec_result_t
0048:    gen execvp:+char *  + +char -> exec_result_t
0049:    gen execve:+char *  + +char * + +char -> exec_result_t
0054:    type pid_t
0057:    fun str: pid_t -> string
0060:    ctor int: pid_t
0065:    gen fork: unit -> pid_t
0067:    union spawn_result_t
0077:    gen spawnv(file: string, argv:+ +char, setup:1->int) : spawn_result_t
0097:    gen spawnvp(file: string, argv:+ +char, setup:1->int) : spawn_result_t
0117:    gen spawnve(file: string, argv:+ +char, env: + +char, setup:1->int) : spawn_result_t
0137:    type process_status_options_t
0144:    gen waitpid: pid_t * &process_status_t * process_status_options_t -> pid_t requires Posix_headers::sys_wait_h
0146:    gen waitpid(pid:pid_t)
0157:    union ProcesStatus
0159:    gen checkpid(pid:pid_t)
0172:    gen kill: pid_t * signal_t -> int

posix/shell.flx
0064:  class Bash
0071:    fun quote_arg(s:string):string
0082:    fun quote_line_for_system (s:string)
0083:    fun quote_line_for_popen (s:string)
0085:    gen raw_get_stdout(x:string)
0099:    fun parse (s:string) : list[string]

Parse a bash command line into words.

0103:    union mode_t

posix/signal.flx
0001:  class PosixSignal
0003:    type signal_t
0004:    ctor signal_t: int
0005:    ctor int: signal_t
0007:    type sig_t
0008:    gen signal: signal_t * sig_t -> sig_t
0022:    fun str: signal_t -> string
0058:    proc ignore_signal(s:signal_t)
0064:    struct sigaction sa
0075:    proc trap_ctrl_c: unit requires ctrl_c_handling

posix/time.flx
0001:  class PosixTime
0021:    gen time () : double

program/__init__.flx
program/cmdopt.flx
0001:  open class CmdOpt
0005:    noinline fun cvt-key-arg (keys: list[string * string]) (x:list[string])
0027:    noinline gen parse-key-multi-value (keys:list[string]) (d:strdict[list[string]]) (x:list[string])
0052:    noinline gen parse-key-single-value (keys:list[string]) (d:strdict[string]) (x:list[string])
0080:    noinline gen parse-key (keys:list[string]) (d:strdict[int]) (x:list[string])
0106:    noinline gen parse-switches (switchmap: list[char * string] ) (d:strdict[int]) (x:list[string])
0129:    typedef cmdspec_t
0137:    typedef cmdopt-parse-result_t
0144:    ctor cmdopt-parse-result_t ()
0152:    noinline gen parse-cmdline (spec:cmdspec_t) (x:list[string]) : cmdopt-parse-result_t

program/dynlink.fdoc
0058:  class Dynlink
0072:    type flx_link_failure_t

Exception thrown if dynamic linkage fails.

0075:    ctor flx_link_failure_t : string * string * string

Constructor for dynamic linkage exception.

0078:    fun filename : flx_link_failure_t -> string

Extractors.

0079:    fun operation : flx_link_failure_t -> string
0080:    fun what : flx_link_failure_t -> string
0083:    proc delete : cptr[flx_link_failure_t]

Delete returned exception.

0086:    fun get_debug_driver_flag : 1 -> bool

This doesn't belong here but it will do for now

0102:    fun create_library_handle: bool ->flx_library

Type of a DLL (dynamic link library) object. Create a fresh DLL object.

0111:    proc dlopen:flx_library * string

Link a DLL using given filename. May throw flx_link_failure_t.

0115:    proc modopen:flx_library * string * string

Link a DLL using given filename and modulename. May throw flx_link_failure_t.

0120:    proc set_entry_points : flx_library * string * address * address

Link static

0127:    typedef module_dictionary_t
0128:    typedef registry_t
0129:    fun get_module_registry_address_address: 1 -> &®istry_t
0137:    gen get_module_registry  () :registry_t
0148:    noinline proc regopen (registry:registry_t) (lib:flx_library, modulename:string)
0175:    fun filename : flx_library -> string

Get the filename of a DLL.

0178:    fun modulename : flx_library -> string

Get the modulename of a DLL.

0181:    fun get_thread_frame_creator_as_address: flx_library -> address

Get the threadframe creator function

0184:    fun get_start_as_address: flx_library -> address

Get start function

0186:    noinline proc add_symbol  (modulename:string, symbolname:string, adr:address)
0221:    generation, it is very hard to ensure there are no references
0229:    proc dlclose:flx_library

Unlink a DLL. Unsafe! Use with extreme caution. May cause pointers into the DLL code segment to dangle.

0250:    fun raw_dlsym:flx_library * string->address

Find raw address of a symbol in a DLL. This function now ALWAYS does a dlsym (or Windows equivalent) even for static linkage: after all statically linked executables can still load DLLs at run time.

0253:    noinline fun find_sym(lib:flx_library, sym:string) : address
0287:    fun create_instance_handle: bool->flx_instance

Type of a DLL (dynamic link library) instance. Conceptually this is a pair consisting of a library object and a global data frame object. Create a fresh DLL instance object.

0300:    proc create: flx_library * flx_instance

Create a DLL instance from a DLL. This is a procedure, so maybe the caller is too which means the thread frame must be available.

0305:    proc create_with_args: flx_library * flx_instance * int * + +char
0310:    proc create_with_args (lib:flx_library, inst:flx_instance, args:list[string])
0316:    gen myget(i:size)
0325:    fun filename : flx_instance -> string

Get the filename of a DLL from an instance of it.

0340:    procedure.
0351:    fun get_init: flx_instance -> cont

Get the initialisation continuation of an instance.

0356:    fun get_library: flx_instance -> flx_library

Get the DLL associated with an instance.

0363:    fun get_thread_frame: flx_instance -> address

Get the thread frame (global data object) of an instance.

0377:    noinline gen prepare_lib(modulename:string):flx_instance

Create, link, and prepare a DLL instance from a modulename. NOTE: libraries created here do not need to be roots

0387:    noinline gen prepare_lib_with_args(modulename:string, args:list[string]):flx_instance

Create, link, and prepare a DLL instance from a modulename.

0398:    noinline gen init_lib(modulename:string):flx_instance

Create, link, and initialise a DLL instance from a modulename.

0406:    noinline gen init_lib_with_args(modulename:string, args:list[string]):flx_instance

Create, link, and initialise a DLL instance from a modulename.

0418:    proc run_lib(modulename:string)

Run a Felix program from a filename.

0425:    proc run_program(args:list[string])
0444:    noinline fun flx_dlsym[T] (linst: flx_instance, sym:string)

Find typed address of a symbol in a DLL.

0480:    noinline fun func0[R] (linst: flx_instance, sym:string)

Return a closure representing a symbol in a DLL instance of a function of no arguments.

0487:    noinline fun func1[R,A0] (linst: flx_instance, sym:string)

Return a closure representing a symbol in a DLL instance of a function of one argument.

0494:    noinline fun func2[R,A0,A1] (linst: flx_instance, sym:string)

Return a closure representing a symbol in a DLL instance of a function of two arguments.

0501:    noinline fun proc0 (linst: flx_instance, sym:string)

Return a closure representing a symbol in a DLL instance of a procedure of no arguments.

0508:    noinline fun proc1[A0] (linst: flx_instance, sym:string)

Return a closure representing a symbol in a DLL instance of a procedure of one argument.

0515:    noinline fun proc2[A0,A1] (linst: flx_instance, sym:string)

Return a closure representing a symbol in a DLL instance of a procedure of two arguments.

0562:    noinline gen  load-plugin-func0[iftype] (

Specialised routine(s) to load stylised plugin. Two entry points:

setup: string -> int

is called to initialise the instance globals.

entry-point: arg -> iftype

is the primary entry point, typically an object factory, when called with an argument of type arg_t it returns //$ an object of type iftype.

This function returns the object factory. setup is called automatically with the supplied string.

There are 3 variants where the factory function accepts 0, 1 and 2 arguments.

0576:    noinline gen  load-plugin-func1[iftype, arg_t] (
0590:    noinline gen  load-plugin-func2[iftype, arg1_t, arg2_t] (
0614:    fun bind_proc: flx_instance * address * address -> cont

Execute an address representing a top level exported felix procedure's C wrapper, this creates a 'read to run' continuation object by both constructing the object using the thread frame of the instance as an argument, and calling it to fix a null return address and an arbitrary client data pointer as arguments to the call method.

0619:    fun dlib_of : flx_library -> address

Get the OS dependent handle representing a loaded DLL. Return as an address.

0623:    proc dlsym_err:flx_library*string

Throw an exception indicating the failure to find a symbol in a DLL.

0629:    noinline proc run_proc (linstance:flx_instance, p: string, data: address)

Run a procedure represented by a string name with given thread frame.


program/env.flx
0002:  class Env_class[os]

Access environment variables.

0005:    virtual fun pathsep: 1 -> string

Separator for filename lists

0009:    fun getenv:string -> string

Get the value of a given variable. Returns empty string if the variable doesn't exist.

0015:    fun getenv(name:string,dflt:string):string

Get the value of a given variable. Returns specified default if the variable doesn't exist.

0019:    fun getenvlist (name:string) : list[string]
0027:  class Env

program/process.flx
0003:  class Process_class[os, process_status_t]
0005:    virtual gen popen_in : string -> Cstdio::ifile
0006:    virtual gen pclose: Cstdio::ifile -> process_status_t
0009:  class Process

program/shell.flx
0004:  class Shell_class[OS, process_status_t]
0008:    virtual fun quote_arg:string->string
0011:    virtual fun quote_line_for_system: string->string
0012:    virtual fun quote_line_for_popen: string -> string
0014:    virtual fun parse: string -> list[string]
0017:    gen raw_system: string -> int

System command is ISO C and C++ standard.

0022:    virtual gen raw_get_stdout : string -> int * string

get_stdout is a synchronous version of popen_in/pclose pair.

0025:    fun create_system_command (s:list[string]) : string

create prototype command strings from arg list.

0028:    fun create_popen_command (s:list[string]) : string
0033:    gen basic_system (cmd: string) :int

basic command with line quoting.

0036:    gen basic_get_stdout (cmd: string) : int * string
0041:    gen system (cmd:string)
0048:    gen get_stdout (cmd:string) : int * string
0056:    gen system (args:list[string]) : int
0060:    gen system[T with Streamable[T,string]] (args:T) : int
0071:    gen get_stdout (args:list[string]) : int * string
0075:    gen get_stdout[T with Streamable[T,string]] (args:T) : int * string
0086:  class Shell

program/signal.flx
0008:  class Signal_class [os]
0009:    gen get_ctrl_c_flag: 1 -> bool requires ctrl_c_flag
0010:    proc set_ctrl_c_flag: int requires ctrl_c_flag
0011:    virtual proc trap_ctrl_c: 1
0015:  class Signal

program/system.flx
0001:  class System
0006:    fun argv:int -> string
0007:    fun argv_dflt (x:int) (y:string)
0009:    fun args ()
0011:    proc setargs : + +char * size
0012:    proc setargs[N] (a:string^N)
0014:    gen myget(i:size)
0019:    gen system (cmd:string) : int
0020:    gen exit: int -> any
0021:    gen abort: 1 -> any
0039:    proc pexit(e:int)

pexit examines the return code from a system call. If the code is 0 it exists with 0. On Windows: if the code is -1, it exits with errno. otherwise code 3 On Unix: if the code is non-zero then if the callout aborted, return its abort code. if the callout died due to a signal, exit with code 2 otherwise exit with code 3 In both these cases a non-zero return causes a message to be printed on stderr.

0054:    proc pexit(e:int)
0074:    gen get_stdout(x:string) : int * string

rawc.flx
0017:  class Raw_C
0020:    typedef ntbs
0023:    gen malloc:size -> address
0024:    proc free:address
0025:    gen realloc:address * size -> address
0026:    proc calloc:size
0029:    gen memset:address * int * size -> address
0030:    gen memcpy:address * address * size -> address
0031:    gen memmove:address * address * size -> address
0034:    gen strlen: ntbs -> size
0035:    gen strcpy:ntbs * ntbs -> ntbs
0036:    gen strncpy:ntbs * ntbs * size -> ntbs
0037:    gen strdup:ntbs -> ntbs
0038:    gen strcat:ntbs * ntbs -> ntbs
0039:    gen strchr:ntbs * int -> ntbs
0040:    gen strcmp:ntbs * ntbs-> int

scalar/__init__.flx
scalar/address.flx
0002:  open class Address

Core operations on addresses.

0004:    ctor[T] address: &T

Construct from Felix object pointer.

0007:    ctor[T] address: cptr[T]

Construct from possibly NULL pointer.

0010:    ctor[T] address: +T

Construct from possibly array element pointer.

0013:    ctor[D,C] address: D --> C

Construct from C function

0017:    fun isNULL: address -> bool

Check is an address is NULL.

0029:    fun str (t:T) : string

Define NULL address.


scalar/bool.flx
0004:  open class Bool

Standard operations on boolean type. Note bool = 2 defined in std/flx_tclass.flx. Literals true and false defined in grammer/expressions.flxh.

0007:    fun land: bool * bool -> bool

Disjunction: logical and.

0010:    fun nand: bool * bool -> bool

Negated and.

0013:    fun lor: bool * bool -> bool

Conjunction: logical or.

0016:    fun nor: bool * bool -> bool

Negated or.

0019:    fun xor: bool * bool -> bool

Logical exclusive or.

0022:    fun lnot: bool -> bool

Logical negation.

0025:    fun implies: bool * bool -> bool

Logical implication.

0044:    fun zero ()

Mutating or. Mutating and.

0052:    fun str (b:bool) : string

Convert bool to string.


scalar/char.flx
0002:  open class Char

Standard C operations on C character set.

0005:    fun ord: char -> int

Ordinal value as int.

0011:    fun toupper : char -> char requires C89_headers::ctype_h

Constructor from any integer type. Convert to upper case.

0014:    fun tolower : char -> char requires C89_headers::ctype_h

Convert to lower case.

0017:    fun isupper : char -> bool requires C89_headers::ctype_h

Test if upper case [A-Z].

0020:    fun islower : char -> bool requires C89_headers::ctype_h

Test if lower case [a-z].

0023:    fun isalnum : char -> bool requires C89_headers::ctype_h

Test if alphanumeric [A-Za-z0-9].

0026:    fun isalpha : char -> bool requires C89_headers::ctype_h

Test if alphabetic [A-Za-z]

0029:    fun isdigit : char -> bool requires C89_headers::ctype_h

Test if digit [0-9].

0032:    fun isxdigit : char -> bool requires C89_headers::ctype_h

Test if hex digit [0-9A-Fa-f].

0035:    fun iscntrl : char -> bool requires C89_headers::ctype_h

Test if control character 0x0 - 0x20, 0x7F

0038:    fun isspace : char -> bool requires C89_headers::ctype_h

Test if space x020.

0041:    fun isblank : char -> bool requires C89_headers::ctype_h

Test if space 0x20 or tab 0x09

0044:    fun isprint : char -> bool requires C89_headers::ctype_h

Test if printable 0x20-0x7e

0047:    fun ispunct : char -> bool requires C89_headers::ctype_h

Test if punctuation character.

0058:    fun isidstart(x:char)
0059:    fun iscamlidcont(x:char)
0060:    fun isidcont(x:char)
0061:    fun isnumeric(x:char)
0062:    fun isalphanum(x:char)
0063:    fun isletter (x:char)
0065:    fun issq(x:char)
0066:    fun isdq(x:char)
0067:    fun isslosh(x:char)
0068:    fun isnull(x:char)
0069:    fun iseol(x:char)
0074:    fun str: T -> string
0078:    fun repr[with Str[T]] (c:T) : string

scalar/ctypedefs.flx
0001:    pod type byte
0005:    pod type char
0007:    pod type tiny
0008:    pod type short
0009:    pod type int
0010:    pod type long
0011:    pod type vlong
0012:    pod type utiny
0013:    pod type ushort
0014:    pod type uint
0015:    pod type ulong
0016:    pod type uvlong
0018:    pod type float
0019:    pod type double
0020:    pod type ldouble
0021:    pod type fcomplex
0022:    pod type dcomplex
0023:    pod type lcomplex
0031:    pod type ptrdiff
0032:    pod type size
0033:    pod type ssize
0035:    pod type intmax
0036:    pod type uintmax
0037:    pod type intptr
0038:    pod type uintptr
0039:    pod type int8
0040:    pod type int16
0041:    pod type int32
0042:    pod type int64
0043:    pod type uint8
0044:    pod type uint16
0045:    pod type uint32
0046:    pod type uint64
0050:    typedef addressing

Types associated with raw address calculations.

0056:    typedef chars

Character types.

0060:    typedef fast_sints

"natural" sized signed integer types. These correspond to C/C++ core types.

0065:    typedef exact_sints

Exact sized signed integer types. In C these are typedefs. In Felix they're distinct types.

0069:    typedef fast_uints

"natural" sized unsigned integer types. These correspond to C/C++ core types.

0074:    typedef exact_uints

Exact sized unsigned integer types. In C these are typedefs. In Felix they're distinct types.

0078:    typedef weird_sints

Weirdo signed integers types corresponding to typedefs in C.

0082:    typedef weird_uints

Weirdo unsigned integers types corresponding to typedefs in C.

0085:    typedef sints

All the signed integers.

0088:    typedef uints

All the usigned integers.

0091:    typedef fast_ints

All the fast integers.

0094:    typedef exact_ints

All the exact integers.

0097:    typedef ints

All the integers.

0100:    typedef floats

All the core floating point types.

0103:    typedef reals

All the core approximations to real types.

0106:    typedef complexes

All the core approximations to complex types.

0109:    typedef numbers

All the core approximations to numbers.

0112:    typedef basic_types

All the basic scalar types.


scalar/float_format.flx
0002:  open class float_format

Functions to format floating point numbers.

0008:    union mode

Style of formatting. default (w,d) : like C "w.dG" format fixed (w,d) : like C "w.dF" format scientific (w,d) : like C "w.dE" format

0015:    fun fmt[t in reals] (v:t, m: mode)

Format a real number v with format m.

0025:    fun fmt[t,r with Complex[t,r]] (v:t, m: mode)

Format a complex number v in x + iy form, with format m for x and y.

0034:    fun fmt_default[t] : t * int * int -> string

Format default.

0037:    fun fmt_fixed[t] : t * int * int -> string

Format fixed.

0040:    fun fmt_scientific[t] : t * int * int -> string

Format scientfic.

0044:    fun xstr: float -> string
0047:    fun str(x:float):string

Default format float, also supports nan, +inf, -inf.

0057:    fun xstr: double -> string
0060:    fun str(x:double):string

Default format double, also supports nan, +inf, -inf.

0070:    fun xstr: ldouble -> string
0073:    fun str(x:ldouble):string

Default format long double, also supports nan, +inf, -inf.


scalar/float_math.flx
0006:  open class Fcomplex
0011:    fun str (z:fcomplex)
0015:  open class Dcomplex
0020:    fun str (z:dcomplex)
0024:  open class Lcomplex
0029:    fun str (z:lcomplex)
0034:    fun real : complex[t] -> t
0035:    fun imag : complex[t] -> t
0036:    fun abs: complex[t] -> t
0037:    fun arg : complex[t] -> t
0051:    fun zero: 1 -> complex[t]
0052:    fun one: 1 -> complex[t]
0057:    fun sin: t -> t
0058:    fun cos: t -> t
0059:    fun tan: t -> t
0060:    fun asin: t -> t
0061:    fun acos: t -> t
0062:    fun atan: t -> t
0063:    fun sinh: t -> t
0064:    fun cosh: t -> t
0065:    fun tanh: t -> t
0066:    fun asinh: t -> t
0067:    fun acosh: t -> t
0068:    fun atanh: t -> t
0069:    fun exp: t -> t
0070:    fun log: t -> t
0071:    fun pow: t * t -> t
0076:    fun abs: t -> t
0077:    fun log10: t -> t
0078:    fun sqrt: t -> t
0079:    fun ceil: t -> t
0080:    fun floor: t -> t
0081:    fun trunc: t -> t
0082:    fun embed: int -> t
0085:  class CartComplex[r]
0086:    typedef t
0090:    typedef complex[t in floats]
0097:    ctor complex[float] (x:float, y:float)
0098:    ctor complex[double] (x:double, y:double)
0099:    ctor complex[ldouble] (x:ldouble, y:ldouble)
0101:    ctor complex[float] (x:float)
0102:    ctor complex[double] (x:double)
0103:    ctor complex[ldouble] (x:ldouble)
0105:    typedef polar[t in floats]

scalar/int.flx
0001:    typedef fun integral_promotion: TYPE -> TYPE
0014:  open class Tiny
0016:    ctor tiny: string
0020:  open class Short
0022:    ctor short: string
0026:  open class Int
0028:    ctor int: string
0030:    ctor int : int
0032:    ctor int(x:bool)
0035:  open class Long
0037:    ctor long: string
0041:  open class Vlong
0043:    ctor vlong: string
0047:  open class Utiny
0049:    ctor utiny: string
0053:  open class Ushort
0055:    ctor ushort: string
0059:  open class Uint
0061:    ctor uint: string
0065:  open class Ulong
0067:    ctor ulong: string
0071:  open class Uvlong
0073:    ctor uvlong: string
0077:  open class Int8
0079:    ctor int8: string
0083:  open class Int16
0085:    ctor int16: string
0089:  open class Int32
0091:    ctor int32: string
0095:  open class Int64
0097:    ctor int64: string
0101:  open class Uint8
0103:    ctor uint8: string
0107:  open class Uint16
0109:    ctor uint16: string
0113:  open class Uint32
0115:    ctor uint32: string
0119:  open class Uint64
0121:    ctor uint64: string
0125:  open class Size
0127:    ctor size: string
0129:    ctor size: size
0136:  open class Ptrdiff
0138:    ctor ptrdiff: string
0142:  open class Intptr
0144:    ctor intptr: string
0148:  open class Uintptr
0150:    ctor uintptr: string
0154:  open class Intmax
0156:    ctor intmax: string
0160:  open class Uintmax
0162:    ctor uintmax: string
0168:    fun str: tiny -> string
0172:    fun str: utiny -> string
0183:    fun str: T -> string
0231:    fun succ: t -> t
0232:    proc pre_incr: &t
0233:    proc post_incr: &t
0237:    fun pred: t -> t
0238:    proc pre_decr: &t
0239:    proc post_decr: &t
0248:    fun sgn: t -> int
0249:    fun abs: t -> t

scalar/number.flx
0003:    fun zero: unit -> t
0012:    fun one: unit -> t

scalar/quaternion.flx
0001:  class Quaternion
0003:    type quaternion
0004:    ctor quaternion (x:double^4)
0006:    fun r(x:q)
0007:    fun i(x:q)
0008:    fun j(x:q)
0009:    fun k(x:q)
0011:    ctor q (x:double)
0026:    fun conj (a:q):q
0027:    fun norm (a:q):double
0032:    fun reciprocal (a:q):q

scalar/real.flx
semaphore.flx
0001:  open class Semaphore
0004:    type semaphore
0005:    ctor semaphore
0006:    ctor semaphore * int
0007:    proc destroy : semaphore
0008:    proc post: semaphore
0009:    proc wait: semaphore
0010:    gen trywait: semaphore -> int

strings/__init__.fdoc
strings/lexer.flx
0001:  class Lexer
0003:    pod type lex_iterator
0004:    fun start_iterator : string -> lex_iterator
0005:    fun end_iterator: string -> lex_iterator
0006:    fun bounds (x:string): lex_iterator * lex_iterator
0012:    fun string_between: lex_iterator * lex_iterator -> string
0018:    fun deref: lex_iterator -> char

strings/re2.flx
0004:  open class Re2

Binding of Google RE2 regexp library.

0033:    gen _ctor_RE2 : string -> RE2
0036:    type StringPiece
0037:    ctor StringPiece: string
0038:    ctor StringPiece: unit
0039:    ctor string: StringPiece
0040:    fun len: StringPiece -> size
0041:    fun data: StringPiece -> +char
0045:    fun len: StringPiece -> size
0054:    fun str: StringPiece -> string
0057:    type Arg
0059:    type Encoding
0063:    type RE2Options
0065:    proc Copy: RE2Options * RE2Options
0067:    fun encoding: RE2Options -> Encoding
0068:    proc set_encoding: RE2Options * Encoding
0070:    fun posix_syntax: RE2Options -> bool
0071:    proc set_posix_syntax: RE2Options * bool
0073:    fun longest_match: RE2Options -> bool
0074:    proc set_longest_match: RE2Options * bool
0076:    fun log_errors: RE2Options -> bool
0077:    proc set_log_errors: RE2Options * bool
0079:    fun max_mem: RE2Options -> int
0080:    proc set_max_mem: RE2Options * int
0082:    fun literal: RE2Options -> bool
0083:    proc set_literal: RE2Options * bool
0085:    fun never_nl: RE2Options -> bool
0086:    proc set_never_nl: RE2Options * bool
0088:    fun case_sensitive: RE2Options -> bool
0089:    proc set_case_sensitive: RE2Options * bool
0091:    fun perl_classes: RE2Options -> bool
0092:    proc set_perl_classes: RE2Options * bool
0094:    fun word_boundary: RE2Options -> bool
0095:    proc set_word_boundary: RE2Options * bool
0097:    fun one_line: RE2Options -> bool
0098:    proc set_one_line: RE2Options * bool
0100:    fun ParseFlags: RE2Options -> int
0102:    type ErrorCode
0119:    type Anchor
0124:    fun pattern: RE2 -> string
0125:    fun error: RE2 -> string
0126:    fun error_code: RE2 -> ErrorCode
0127:    fun error_arg: RE2 -> string
0128:    fun ok: RE2 -> bool
0129:    fun ProgramSize: RE2 -> int
0131:    gen GlobalReplace: &string * RE2 * StringPiece -> int
0132:    gen Extract: StringPiece * RE2 * StringPiece * &string -> bool
0134:    fun QuoteMeta: StringPiece -> string
0136:    fun PossibleMatchRange: RE2 * &string * &string * int -> bool
0137:    fun NumberOfCapturingGroups: RE2 -> int
0138:    fun NamedCapturingGroups: RE2 -> Stl_Map::stl_map[string, int]
0141:    gen Match: RE2 * StringPiece * int * Anchor * +StringPiece * int -> bool
0145:    noinline gen Match(re:RE2, var s:string) : opt[varray[string]]
0158:    gen apply (re:RE2, s:string)
0160:    fun CheckRewriteString: RE2 * StringPiece * &string -> bool
0168:    gen iterator (re2:string, var target:string)
0171:    gen iterator (r:RE2, var target:string) () : opt[varray[string]]
0196:    fun extract (re2:string, target:string) : opt[varray[string]]
0197:    fun extract (re2:RE2, target:string) : opt[varray[string]]

strings/regdef.flx
0001:  class Regdef
0002:    union regex
0045:    fun ngrp (s:string)
0048:    fun render: regex -> string

strings/string.fdoc
0010:    typedef cstring
0011:    type string
0017:    typedef strings
0028:  open class String
0050:    fun len: string -> size
0073:    fun apply (x:string, y:string):string
0074:    fun apply (x:string, y:int):string
0079:    ctor char (x:string)
0082:    ctor string (c:char)
0083:    ctor string: +char
0084:    ctor string: +char  * !ints
0085:    fun utf8: int -> string
0089:    fun subscript: string * !ints -> char
0091:    fun copyfrom: string * !ints -> string
0093:    fun copyto: string * !ints -> string
0095:    fun substring: string * !ints * !ints -> string
0098:    fun subscript (x:string, s:slice[int]):string
0108:    proc store: &string * !ints * char
0112:    fun map (f:char->char) (var x:string): string
0128:    fun stl_find: string * string -> int
0129:    fun stl_find: string * string * int -> int
0130:    fun stl_find: string * +char -> int
0131:    fun stl_find: string * +char * int -> int
0132:    fun stl_find: string * char -> int
0133:    fun stl_find: string * char * int -> int
0135:    fun find (s:string, e:string) : opt[int]
0136:    fun find (s:string, e:string, i:int) : opt[int]
0137:    fun find (s:string, e:+char) : opt[int]
0138:    fun find (s:string, e:+char, i:int) : opt[int]
0139:    fun find (s:string, e:char) : opt[int]
0140:    fun find (s:string, e:char, i:int) : opt[int]
0142:    fun stl_rfind: string * string -> int
0143:    fun stl_rfind: string * string * int -> int
0144:    fun stl_rfind: string * +char-> int
0145:    fun stl_rfind: string * +char * int -> int
0146:    fun stl_rfind: string * char -> int
0147:    fun stl_rfind: string * char * int -> int
0149:    fun rfind (s:string, e:string) : opt[int]
0150:    fun rfind (s:string, e:string, i:int) : opt[int]
0151:    fun rfind (s:string, e:+char) : opt[int]
0152:    fun rfind (s:string, e:+char, i:int) : opt[int]
0153:    fun rfind (s:string, e:char) : opt[int]
0154:    fun rfind (s:string, e:char, i:int) : opt[int]
0156:    fun stl_find_first_of: string * string -> int
0157:    fun stl_find_first_of: string * string * int -> int
0158:    fun stl_find_first_of: string * +char -> int
0159:    fun stl_find_first_of: string * +char * int -> int
0160:    fun stl_find_first_of: string * char -> int
0161:    fun stl_find_first_of: string * char * int -> int
0163:    fun find_first_of (s:string, e:string) : opt[int]
0164:    fun find_first_of (s:string, e:string, i:int) : opt[int]
0165:    fun find_first_of (s:string, e:+char) : opt[int]
0166:    fun find_first_of (s:string, e:+char, i:int) : opt[int]
0167:    fun find_first_of (s:string, e:char) : opt[int]
0168:    fun find_first_of (s:string, e:char, i:int) : opt[int]
0170:    fun stl_find_first_not_of: string * string -> int
0171:    fun stl_find_first_not_of: string * string * int -> int
0172:    fun stl_find_first_not_of: string * +char -> int
0173:    fun stl_find_first_not_of: string * +char * int -> int
0174:    fun stl_find_first_not_of: string * char -> int
0175:    fun stl_find_first_not_of: string * char * int -> int
0177:    fun find_first_not_of (s:string, e:string) : opt[int]
0178:    fun find_first_not_of (s:string, e:string, i:int) : opt[int]
0179:    fun find_first_not_of (s:string, e:+char) : opt[int]
0180:    fun find_first_not_of (s:string, e:+char, i:int) : opt[int]
0181:    fun find_first_not_of (s:string, e:char) : opt[int]
0182:    fun find_first_not_of (s:string, e:char, i:int) : opt[int]
0184:    fun stl_find_last_of: string * string -> int
0185:    fun stl_find_last_of: string * string * int -> int
0186:    fun stl_find_last_of: string * +char -> int
0187:    fun stl_find_last_of: string * +char * int -> int
0188:    fun stl_find_last_of: string * char -> int
0189:    fun stl_find_last_of: string * char * int -> int
0191:    fun find_last_of (s:string, e:string) : opt[int]
0192:    fun find_last_of (s:string, e:string, i:int) : opt[int]
0193:    fun find_last_of (s:string, e:+char) : opt[int]
0194:    fun find_last_of (s:string, e:+char, i:int) : opt[int]
0195:    fun find_last_of (s:string, e:char) : opt[int]
0196:    fun find_last_of (s:string, e:char, i:int) : opt[int]
0198:    fun stl_find_last_not_of: string * string -> int
0199:    fun stl_find_last_not_of: string * string * int -> int
0200:    fun stl_find_last_not_of: string * +char -> int
0201:    fun stl_find_last_not_of: string * +char * int -> int
0202:    fun stl_find_last_not_of: string * char -> int
0203:    fun stl_find_last_not_of: string * char * int -> int
0205:    fun find_last_not_of (s:string, e:string) : opt[int]
0206:    fun find_last_not_of (s:string, e:string, i:int) : opt[int]
0207:    fun find_last_not_of (s:string, e:+char) : opt[int]
0208:    fun find_last_not_of (s:string, e:+char, i:int) : opt[int]
0209:    fun find_last_not_of (s:string, e:char) : opt[int]
0210:    fun find_last_not_of (s:string, e:char, i:int) : opt[int]
0222:    gen iterator(var x:string) ()
0231:    fun prefix(arg:string,key:string)
0235:    fun suffix (arg:string,key:string)
0240:    fun startswith (x:string) (e:string) : bool
0243:    fun endswith (x:string) (e:string) : bool
0245:    fun startswith (x:string) (e:char) : bool
0246:    fun endswith (x:string) (e:char) : bool
0250:    fun ltrim (x:string) (e:string) : string
0258:    fun rtrim (x:string) (e:string) : string
0266:    fun trim (x:string) (e:string) : string
0270:    fun lstrip (x:string, e:string) : string
0289:    fun rstrip (x:string, e:string) : string
0308:    fun strip (x:string, e:string) : string
0310:    fun lstrip (x:string) : string
0311:    fun rstrip (x:string) : string
0312:    fun strip (x:string) : string
0316:    fun ljust(x:string, width:int) : string
0323:    fun rjust(x:string, width:int) : string
0332:    fun split (x:string, d:char): List::list[string]
0334:    fun rev_split (x:string, d:char): List::list[string]
0335:    fun aux (x:string,y:List::list[string])
0344:    fun split (x:string, d:string): List::list[string]
0346:    fun rev_split (x:string, d:string): List::list[string]
0347:    fun aux (x:string,y:List::list[string])
0356:    fun split (x:string, d:+char): List::list[string]
0358:    fun rev_split (x:string, d:+char): List::list[string]
0359:    fun aux (x:string,y:List::list[string])
0368:    fun split_first (x:string, d:string): opt[string*string]
0380:  class RespectfulParser

Split a string on whitespace but respecting double quotes, single quotes, and slosh escapes.

0381:    union quote_action_t
0386:    union dquote_action_t
0391:    union escape_action_t
0396:    typedef action_t
0398:    union mode_t
0399:    typedef state_t
0527:    fun respectful_split (action:RespectfulParser::action_t) (s:string) : list[string]
0547:    fun respectful_split (s:string) : list[string]
0569:    proc erase: &string * int * int

mutators

0570:    proc insert: &string * int * string
0571:    proc replace: &string * int * int * string
0574:    fun erase: string * int * int -> string

functional

0575:    fun insert: string * int * string -> string
0576:    fun replace: string * int * int * string -> string
0582:    fun search_and_replace (x:string, var spos:size, s:string, r:string) : string
0595:    fun search_and_replace (x:string, s:string, r:string) : string
0597:    fun search_and_replace (vs:list[string * string]) (var v:string)
0608:    fun subst(s:string, v:varray[StringPiece]): string
0658:    fun search_and_replace (x:string, var spos: size, re:Re2::RE2, r:string) : string
0676:    fun atoi: string -> int
0677:    fun atol: string -> long
0678:    fun atoll: string -> long
0679:    fun atof: string -> double
0683:    proc reserve: &string * !ints
0688:    fun _unsafe_cstr: string -> +char
0691:    fun stl_begin: &string -> +char
0692:    fun stl_end: &string -> +char
0696:    fun cstr (x:string) : +char
0700:    fun vsprintf[t]: +char  * t -> string
0704:    fun vsprintf[t]: string * t -> string
0711:    fun toupper(s:string):string
0713:    fun tolower(s:string):string
0721:    fun str (s:string) : string
0725:    fun str: +char -> string
0729:    fun repr (x:string) : string

strings/tre.flx
0001:  class Tre
0005:    type tre_regex_t
0013:    fun tre_regcomp (x:string): opt[tre_regex_t]
0021:    fun nsub: &tre_regex_t -> int
0029:    fun add: +char * regoff_t -> +char
0030:    fun sub: regoff_t * regoff_t -> int
0031:    ctor int : regoff_t
0043:    fun tre_regexec (re_in: tre_regex_t) (x:string): int * int * +regmatch_t

time.flx
0001:  class Time_class [os]
0002:    virtual gen time: 1 -> double
0005:  open class Time

typing.flx
0001:  open class Typing
0003:    typedef fun dom(t:TYPE):TYPE
0004:    typematch t with
0009:    typedef fun cod(t:TYPE):TYPE
0010:    typematch t with
0015:    typedef fun prj1(t:TYPE):TYPE
0016:    typematch t with
0021:    typedef fun prj2(t:TYPE):TYPE
0022:    typematch t with
0027:    typedef fun type_land(x:TYPE, y:TYPE):TYPE
0028:    typematch (x,  y) with
0035:    typedef fun type_lor(x:TYPE, y:TYPE):TYPE
0036:    typematch (x,  y) with
0042:    typedef fun eq(x:TYPE, y:TYPE):TYPE
0043:    typematch x with
0049:    typedef fun
0050:    typematch x with

win32/__init__.flx
0001:    struct Win32

win32/directory.flx
0001:  class Win32Directory
0005:    type DIR_t
0006:    type FINDDATA_t
0008:    proc findfirst: string * &FINDDATA_t * &DIR_t
0009:    proc findnext: DIR_t * &FINDDATA_t * &int
0010:    proc findclose : DIR_t
0012:    fun findfailed : DIR_t -> bool
0013:    fun filename : FINDDATA_t -> string
0028:    gen mkdir: string * Win32FileStat::mode_t -> int
0029:    gen mkdir: string  -> int
0030:    proc mkdirs (s:string)
0041:    fun getcwd():string
0055:    fun mk_absolute_filename(s:string)
0062:    fun filesin(dname:string): opt[list[string]]

win32/faio_win32.flx
0013:    type WFILE
0014:    typedef fd_t
0019:    type SOCKET
0020:    typedef socket_t
0023:    fun str: socket_t -> string
0029:    fun GetLastError: 1 -> int
0034:    fun cmk_socket : unit -> SOCKET
0039:    proc mk_socket(s: &SOCKET)
0046:    type wasync_accept
0048:    fun mk_accept: demuxer *  SOCKET*SOCKET -> wasync_accept
0050:    fun get_success[t]: t -> bool
0055:    fun eq : SOCKET*SOCKET -> bool
0058:    proc Accept(success: &bool, listener: SOCKET, accepted: SOCKET)
0065:    type connect_ex
0066:    fun mk_connect_ex: demuxer * SOCKET*+char*int -> connect_ex
0070:    proc Connect(s: SOCKET, addr: +char, port: int, err: &int)
0078:    proc Connect(s: &SOCKET, addr: +char, port: int, err: &int)
0085:    proc cmk_listener: &SOCKET*&int*int
0088:    proc mk_listener(listener: &SOCKET, port: &int, backlog: int)
0095:    proc closesocket: SOCKET
0101:    proc shutdown: SOCKET*int
0103:    type wasync_transmit_file
0111:    gen OpenFile: string -> WFILE
0116:    gen OpenFileDuplex: string -> WFILE
0121:    proc CloseFile: WFILE
0127:    fun mk_transmit_file : demuxer * SOCKET*WFILE -> wasync_transmit_file
0131:    proc TransmitFile(s: SOCKET, f: WFILE)
0142:    fun mk_reuse_socket : demuxer * SOCKET -> wasync_transmit_file
0145:    proc ReuseSocket(s: SOCKET)
0151:    type wsa_socketio
0152:    gen mk_wsa_socketio: demuxer * SOCKET*sel_param_ptr*bool->wsa_socketio
0157:    proc WSARecv(s: SOCKET, len: &int, buf: address, eof: &bool)
0169:    proc WSASend(s: SOCKET, len: &int, buf: address, eof: &bool)
0180:    type winfile_io
0182:    fun mk_winfile_io: demuxer * WFILE*address*int*bool->winfile_io
0185:    fun get_pb: winfile_io -> sel_param_ptr
0187:    proc ReadFile(f: WFILE, len: &int, buf: address, eof: &bool)
0195:    proc WriteFile(f: WFILE, len: &int, buf: address, eof: &bool)
0205:    type iocp_associator
0206:    fun mk_iocp_associator: demuxer * SOCKET -> iocp_associator
0211:    proc associate_with_iocp(s: SOCKET)

win32/filestat.flx
0001:  class Win32FileStat
0013:    pod type mode_t
0014:    pod type stat_t
0032:    fun raw_mode: &stat_t -> mode_t
0033:    fun file_type(m:mode_t)
0034:    fun file_perm(m:mode_t)
0036:    ctor uint: mode_t
0043:    proc stat: string * &stat_t * &int
0045:    proc utime: string * double * double * &int
0057:    gen chmod: string * mode_t -> int
0058:    gen umask: mode_t -> mode_t
0060:    fun file_type (s:&stat_t): file_type_t

win32/filesystem.flx
0001:  class Win32FileSystem
0006:    pod type file_perm_t
0026:    pod type posix_file
0027:    fun valid: posix_file -> bool
0028:    ctor int : posix_file
0033:    gen open: string * file_perm_t * Win32FileStat::mode_t -> posix_file
0034:    gen open: string * file_perm_t -> posix_file
0036:    gen ropen: string -> posix_file
0037:    gen wopen: string -> posix_file
0038:    gen rwopen: string -> posix_file
0039:    gen creat: string * Win32FileStat::mode_t-> posix_file
0041:    gen close: posix_file -> int
0042:    gen read: posix_file * &char * size -> size
0043:    gen write: posix_file * &char * size -> size
0045:    gen dup: posix_file -> posix_file
0046:    gen dup2: posix_file * posix_file -> posix_file
0048:    struct _piper_hack
0060:    gen pipe ()
0062:    gen fdopen_input: posix_file ->  ifile
0063:    gen fdopen_output: posix_file ->  ofile
0068:    gen unlink_file: string -> int
0073:    gen rename_file: string * string -> int
0079:    gen filecopy(src: string, dst: string) :  bool
0147:    gen tmp_filename: 1 -> string

win32/process.flx
0001:  class Win32Process
0006:    gen popen_in: string -> Cstdio::ifile
0007:    gen pclose: Cstdio::ifile -> process_status_t
0010:    type process_status_t
0011:    ctor intptr:process_status_t
0012:    ctor int:process_status_t
0013:    ctor process_status_t : intptr
0014:    fun int_of_process_status_t: process_status_t -> int
0018:    fun WIFCONTINUED: process_status_t -> bool
0019:    fun WIFEXITED: process_status_t -> bool
0020:    fun WIFSIGNALED: process_status_t -> bool
0021:    fun WIFSTOPPED: process_status_t -> bool
0023:    fun WEXITSTATUS: process_status_t -> int
0024:    fun WTERMSIG: process_status_t -> signal_t
0025:    fun WSTOPSIG: process_status_t -> signal_t
0028:    fun  WCOREDUMP: process_status_t -> int
0031:    fun str(x:process_status_t)
0045:    type exec_result_t
0049:    gen execv:+char *  + +char -> exec_result_t
0050:    gen execvp:+char *  + +char -> exec_result_t
0051:    gen execve:+char *  + +char * + +char -> exec_result_t
0056:    type pid_t
0057:    ctor intptr: pid_t
0062:    fun str: pid_t -> string
0065:    union spawn_result_t
0075:    gen spawnv:+char *  + +char -> pid_t
0076:    gen spawnvp:+char *  + +char -> pid_t
0077:    gen spawnve:+char *  + +char * + +char -> pid_t
0079:    gen spawnv(file: string, argv:+ +char, setup:1->int) : spawn_result_t
0088:    gen spawnvp(file: string, argv:+ +char, setup:1->int) : spawn_result_t
0097:    gen spawnve(file: string, argv:+ +char, env: + +char, setup:1->int) : spawn_result_t
0106:    type process_status_options_t
0114:    gen waitpid: pid_t * &process_status_t * process_status_options_t -> pid_t requires Posix_headers::sys_wait_h
0116:    gen waitpid(pid:pid_t)
0127:    union ProcesStatus
0129:    gen checkpid(pid:pid_t)
0142:    gen kill: pid_t * signal_t -> int

win32/shell.flx
0036:  class CmdExe
0040:    fun quote_arg(s:string):string
0041:    fun quote_line_for_system(s:string)
0042:    fun quote_line_for_popen(s:string)
0044:    gen get_stdout(x:string)
0057:    fun parse (s:string) : list[string]

Parse a CMD.EXE command line into words.

0061:    union mode_t

win32/signal.flx
0001:  class Win32Signal
0003:    type signal_t
0004:    ctor signal_t: int
0005:    ctor int: signal_t
0008:    type sig_t
0009:    gen signal: signal_t * sig_t -> sig_t
0022:    fun str: signal_t -> string
0036:    proc ignore_signal(s:signal_t)
0049:    proc trap_ctrl_c: unit requires ctrl_c_handling

win32/time.flx
0001:  class Win32Time
0019:    gen time () : double

win32/win32_headers.flx
0001:  class Win32_headers