include/comma/runtime/crt_vstack.h File Reference

Defines routines to access the "vstack", or variable stack. More...

#include <inttypes.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void _comma_vstack_alloc (int32_t size)
void _comma_vstack_push (void *data, int32_t size)
void _comma_vstack_pop ()

Variables

char * _comma_vstack

Detailed Description

Defines routines to access the "vstack", or variable stack.

Comma's vstack is a runtime stack used to return objects of variable length from Comma subroutines. The canonical example is returning a String from a function:

   function Get_String return String is
   begin
      return "Hello, world!";
   end Get_String;

The compiler generates two calls to _comma_vstack_push() in this case, populating the vstack with a bounds structure and the actual data comprising the string. Callers of Get_String retrieve the data by inspecting the _comma_vstack variable, which is a pointer to the most recently pushed data on the stack. Once the data has been retrieved (e.g. copied), _comma_vstack_push() is called to remove the top-most item from the stack.

Definition in file crt_vstack.h.


Function Documentation

void _comma_vstack_alloc ( int32_t  size  ) 

Allocates a region of size bytes on the vstack.

The allocated data is available thru the _comma_vstack pointer, and will be disposed of when a matching call to _comma_vstack_pop() is made.

Definition at line 51 of file crt_vstack.c.

void _comma_vstack_pop (  ) 

Pops the vstack and resets _comma_vstack to the next item.

Definition at line 68 of file crt_vstack.c.

void _comma_vstack_push ( void *  data,
int32_t  size 
)

Copy's size bytes from data onto the vstack.

The allocated data is available thru the _comma_vstack pointer, and will be disposed of when a matching call to _comma_vstack_pop() is made.

Definition at line 59 of file crt_vstack.c.


Variable Documentation

Pointer to the top of the vstack.

Definition at line 41 of file crt_vstack.h.


Generated on 1 Feb 2010 for Comma by  doxygen 1.6.1