p2  0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
potion.h File Reference
#include <limits.h>
#include <string.h>
#include <fcntl.h>
#include "config.h"
+ Include dependency graph for potion.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PNObject
 standard objects act like C structs the fields are defined by the type and it's a fixed size, not volatile. More...
struct  PNFwd
 forwarding pointer (in case of reallocation) More...
struct  PNData
 struct to wrap arbitrary data that we may want to allocate from Potion. More...
struct  PNString
 strings are immutable UTF-8, the ID is incremental and they may be garbage collected. More...
struct  PNBytes
 byte strings are raw character data, volatile, may be appended/changed. More...
struct  PNDecimal
 decimals are floating point numbers stored as binary data. More...
struct  PNFile
 a file is wrapper around a file descriptor, non-volatile but mutable. More...
struct  PNClosure
 a closure is an anonymous function, without closed values, More...
struct  PNSource
struct  PNProto
 a prototype is compiled source code, a closure block (lambda) non-volatile. More...
class  PNTuple
 a tuple is an ordered list, volatile. More...
struct  PNWeakRef
 a weak ref is used for upvals, it acts as a memory slot, non-volatile but mutable. More...
struct  PNError
 an error, including a description, file location, a brief excerpt. More...
struct  PNLick
 a lick is a unit of generic tree data. More...
struct  PNCont
 a continuation saves the stack and all stack pointers. More...
struct  PNAsm
struct  PNTarget
 definition of the jit targets: x86 or ppc, arm later More...
struct  Potion_State
 the global interpreter state P. currently singleton (not threads yet) More...
struct  PNMemory
 the garbage collector More...

Macros

#define POTION_MAJOR   0
#define POTION_MINOR   1
#define POTION_SIG   "p\07\10n"
#define POTION_VMID   0x79
#define POTION_X86   0
#define POTION_PPC   1
#define POTION_ARM   2
#define _XSTR(s)   _STR(s)
#define _STR(s)   #s
#define POTION_VERSION   _XSTR(POTION_MAJOR) "." _XSTR(POTION_MINOR)
#define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
#define YY_DEBUG
#define __WORDSIZE   32
#define PN_TNIL   0x250000
#define PN_TNUMBER   (1+PN_TNIL)
#define PN_TBOOLEAN   (2+PN_TNIL)
#define PN_TSTRING   (3+PN_TNIL)
#define PN_TWEAK   (4+PN_TNIL)
#define PN_TCLOSURE   (5+PN_TNIL)
#define PN_TTUPLE   (6+PN_TNIL)
#define PN_TSTATE   (7+PN_TNIL)
#define PN_TFILE   (8+PN_TNIL)
#define PN_TOBJECT   (9+PN_TNIL)
#define PN_TVTABLE   (10+PN_TNIL)
#define PN_TSOURCE   (11+PN_TNIL)
#define PN_TBYTES   (12+PN_TNIL)
#define PN_TPROTO   (13+PN_TNIL)
#define PN_TLOBBY   (14+PN_TNIL)
#define PN_TTABLE   (15+PN_TNIL)
#define PN_TLICK   (16+PN_TNIL)
#define PN_TFLEX   (17+PN_TNIL)
#define PN_TSTRINGS   (18+PN_TNIL)
#define PN_TERROR   (19+PN_TNIL)
#define PN_TCONT   (20+PN_TNIL)
#define PN_TDECIMAL   (21+PN_TNIL)
#define PN_TUSER   (22+PN_TNIL)
#define PN_TYPE(x)   potion_type((PN)(x))
#define PN_VTYPE(x)   (((struct PNObject *)(x))->vt)
#define PN_TYPE_ID(t)   ((t)-PN_TNIL)
#define PN_VTABLE(t)   (PN_FLEX_AT(P->vts, PN_TYPE_ID(t)))
#define PN_TYPECHECK(t)   (PN_TYPE_ID(t) >= 0 && PN_TYPE_ID(t) < PN_FLEX_SIZE(P->vts))
#define PN_NIL   ((PN)0)
#define PN_ZERO   ((PN)1)
#define PN_FALSE   ((PN)2)
#define PN_TRUE   ((PN)6)
#define PN_PRIMITIVE   7
#define PN_REF_MASK   ~7
#define PN_NONE   ((PN_SIZE)-1)
#define POTION_FWD   0xFFFFFFFE
#define POTION_COPIED   0xFFFFFFFF
#define NIL_NAME   "nil"
#define PN_FNUMBER   1
#define PN_FBOOLEAN   2
#define PN_TEST(v)   ((PN)(v) != PN_FALSE && (PN)(v) != PN_NIL)
#define PN_BOOL(v)   (PN_TEST(v) ? PN_TRUE : PN_FALSE)
#define PN_IS_PTR(v)   (!PN_IS_NUM(v) && ((PN)(v) & PN_REF_MASK))
#define PN_IS_NIL(v)   ((PN)(v) == PN_NIL)
#define PN_IS_BOOL(v)   ((PN)(v) & PN_FBOOLEAN)
#define PN_IS_NUM(v)   ((PN)(v) & PN_FNUMBER)
#define PN_IS_TUPLE(v)   (PN_TYPE(v) == PN_TTUPLE)
#define PN_IS_STR(v)   (PN_TYPE(v) == PN_TSTRING)
#define PN_IS_TABLE(v)   (PN_TYPE(v) == PN_TTABLE)
#define PN_IS_CLOSURE(v)   (PN_TYPE(v) == PN_TCLOSURE)
#define PN_IS_DECIMAL(v)   (PN_IS_PTR(v) && PN_TYPE(v) == PN_TNUMBER)
#define PN_IS_PROTO(v)   (PN_TYPE(v) == PN_TPROTO)
#define PN_IS_REF(v)   (PN_TYPE(v) == PN_TWEAK)
#define PN_IS_METACLASS(v)   (((struct PNVtable *)v)->meta == PN_NIL)
#define PN_NUM(i)   ((PN)((((long)(i))<<1) + PN_FNUMBER))
#define PN_INT(x)   ((long)((long)(x))>>1)
#define PN_DBL(num)   (PN_IS_NUM(num) ? (double)PN_INT(num) : ((struct PNDecimal *)num)->value)
#define PN_PREC   16
#define PN_RAND()   PN_NUM(potion_rand_int())
#define PN_STR(x)   potion_str(P, x)
#define PN_STRN(x, l)   potion_str2(P, x, l)
#define PN_STRCAT(a, b)   potion_strcat(P, (a), (b))
#define PN_STR_PTR(x)   potion_str_ptr(x)
#define PN_STR_LEN(x)   ((struct PNString *)(x))->len
#define PN_STR_B(x)   potion_bytes_string(P, PN_NIL, x)
#define PN_CLOSURE(x)   ((struct PNClosure *)(x))
#define PN_CLOSURE_F(x)   ((struct PNClosure *)(x))->method
#define PN_PROTO(x)   ((struct PNProto *)(x))
#define PN_FUNC(f, s)   potion_closure_new(P, (PN_F)f, potion_sig(P, s), 0)
#define PN_DEREF(x)   ((struct PNWeakRef *)(x))->data
#define PN_TOUCH(x)   potion_gc_update(P, (PN)(x))
#define PN_ALIGN(o, x)   (((((o) - 1) / (x)) + 1) * (x))
#define PN_OBJECT_HEADER
#define PN_FLEX(N, T)   typedef struct { PN_OBJECT_HEADER; PN_SIZE len; PN_SIZE siz; T ptr[0]; } N;
#define PN_FLEX_AT(N, I)   ((PNFlex *)(N))->ptr[I]
#define PN_FLEX_SIZE(N)   ((PNFlex *)(N))->len
#define PN_NUMHASH(x)   (PNUniq)((x)>>33^(x)^(x)<<11)
#define PN_UNIQ(x)   (PN_IS_PTR(x) ? ((struct PNObject *)(x))->uniq : PN_NUMHASH(x))
#define AS_STR(x)   PN_STR_PTR(potion_send(x, PN_string))
#define DBG_t(...)   if (P->flags & DEBUG_TRACE) fprintf(stderr, __VA_ARGS__)
#define DBG_v(...)   if (P->flags & DEBUG_VERBOSE) fprintf(stderr, __VA_ARGS__)
#define DBG_vt(...)   if (P->flags & (DEBUG_VERBOSE|DEBUG_TRACE)) fprintf(stderr, __VA_ARGS__)
#define DBG_vi(...)   if (P->flags & (DEBUG_VERBOSE|DEBUG_INSPECT)) fprintf(stderr, __VA_ARGS__)
#define DBG_c(...)   if (P->flags & DEBUG_COMPILE) fprintf(stderr, __VA_ARGS__)
#define PN_IS_EMPTY(T)   (PN_GET_TUPLE(T)->len == 0)
#define PN_TUP0()   potion_tuple_empty(P)
#define PN_TUP(X)   potion_tuple_new(P, X)
#define PN_PUSH(T, X)   potion_tuple_push(P, T, (PN)X)
#define PN_GET(T, X)   potion_tuple_find(P, T, X)
#define PN_PUT(T, X)   potion_tuple_push_unless(P, T, X)
#define PN_GET_TUPLE(t)   ((struct PNTuple *)potion_fwd((PN)t))
#define PN_TUPLE_LEN(t)   PN_GET_TUPLE(t)->len
#define PN_TUPLE_AT(t, n)   PN_GET_TUPLE(t)->set[n]
#define PN_TUPLE_COUNT(T, I, B)
#define PN_TUPLE_EACH(T, I, V, B)
#define PN_MANTISSA(d, n)   d->real[1 + n]
 PN_MANTISSA the last part of ->real.
#define PN_QUICK_FWD(t, obj)
 PN_QUICK_FWD - doing a single fwd check after a possible realloc.
#define OP_MAX   64
 the jit
#define EXEC_BITS   4
 0-4
#define POTION_INIT_STACK(x)   PN __##x = 0x571FF; void *x = (void *)&__##x
#define POTION_OK   0
 internal errors
#define POTION_NO_MEM   8910
#define potion_send(RCV, MSG, ARGS...)
 method caches (more great stuff from ian piumarta)
#define potion_method(RCV, MSG, FN, SIG)   potion_send(RCV, PN_def, potion_str(P, MSG), PN_FUNC(FN, SIG))
#define potion_class_method(RCV, MSG, FN, SIG)   potion_send(((struct PNVtable *)(RCV))->meta, PN_def, potion_str(P, MSG), PN_FUNC(FN, SIG))

Typedefs

typedef unsigned long _PN
typedef unsigned int PN_SIZE
typedef unsigned int PNType
typedef unsigned int PNUniq
typedef struct Potion_State Potion
typedef volatile _PN PN
typedef PN(* PN_F )(Potion *, PN, PN,...)
typedef void(* OP_F )(Potion *P, struct PNProto *, PNAsm *volatile *,...)

Enumerations

enum  PN_AST {
  AST_CODE, AST_VALUE, AST_ASSIGN, AST_NOT,
  AST_OR, AST_AND, AST_CMP, AST_EQ,
  AST_NEQ, AST_GT, AST_GTE, AST_LT,
  AST_LTE, AST_PIPE, AST_CARET, AST_AMP,
  AST_WAVY, AST_BITL, AST_BITR, AST_PLUS,
  AST_MINUS, AST_INC, AST_TIMES, AST_DIV,
  AST_REM, AST_POW, AST_MSG, AST_PATH,
  AST_QUERY, AST_PATHQ, AST_EXPR, AST_LIST,
  AST_BLOCK, AST_LICK, AST_PROTO, AST_DEBUG
}
 An AST fragment, non-volatile. More...
enum  exec_mode_t {
  EXEC_VM = 0, EXEC_JIT, EXEC_DEBUG, EXEC_CHECK,
  EXEC_COMPILE, MAX_EXEC
}
 the interpreter (one per thread, houses its own garbage collector) More...
enum  syntax_mode_t { MODE_STD = 1<<EXEC_BITS, MAX_SYNTAX = (1<<(EXEC_BITS+2))-1 }
enum  Potion_Flags {
  DEBUG_INSPECT = 1<<(EXEC_BITS+2), DEBUG_VERBOSE = 1<<(EXEC_BITS+3), DEBUG_TRACE = 1<<(EXEC_BITS+4), DEBUG_PARSE = 1<<(EXEC_BITS+5),
  DEBUG_PARSE_VERBOSE = 1<<(EXEC_BITS+6), DEBUG_COMPILE = 1<<(EXEC_BITS+7), DEBUG_GC = 1<<(EXEC_BITS+8), DEBUG_JIT = 1<<(EXEC_BITS+9)
}

Functions

static PN potion_fwd (PN)
 the potion type is the 't' in the vtable tuple (m,t)
static PNType potion_type (PN obj)
 either immediate (NUM,BOOL,NIL) or a fwd
static char * potion_str_ptr (PN s)
 quick access to either PNString or PNByte pointer
 PN_FLEX (PNFlex, PN)
void potion_garbagecollect (Potion *, int, int)
PN_SIZE potion_type_size (Potion *, const struct PNObject *)
unsigned long potion_rand_int ()
 generates a random number on [0,0xffffffff]-interval
double potion_rand_double ()
 generates a random number on [0,1) with 53-bit resolution
static void * potion_gc_alloc (Potion *P, PNType vt, int siz)
 quick inline allocation
static void * potion_gc_calloc (Potion *P, PNType vt, int siz)
static void potion_gc_update (Potion *P, PN x)
static void * potion_gc_realloc (Potion *P, PNType vt, struct PNObject *volatile obj, PN_SIZE sz)
static struct PNDatapotion_data_alloc (Potion *P, int siz)
Potionpotion_create (void *)
 the potion API
void potion_destroy (Potion *)
PN potion_error (Potion *, PN, long, long, PN)
void potion_fatal (char *)
void potion_allocation_error (void)
void potion_syntax_error (Potion *, const char *,...)
PNType potion_kind_of (PN)
void potion_p (Potion *, PN)
PN potion_str (Potion *, const char *)
PN potion_str2 (Potion *, char *, size_t)
PN potion_strcat (Potion *P, char *str, char *str2)
PN potion_str_format (Potion *, const char *,...)
PN potion_byte_str (Potion *, const char *)
PN potion_byte_str2 (Potion *, const char *, size_t len)
PN potion_bytes (Potion *, size_t)
PN potion_bytes_string (Potion *, PN, PN)
PN_SIZE pn_printf (Potion *, PN, const char *,...)
void potion_bytes_obj_string (Potion *, PN, PN)
PN potion_bytes_append (Potion *, PN, PN, PN)
void potion_release (Potion *, PN)
PN potion_def_method (Potion *P, PN, PN, PN, PN)
PN potion_type_new (Potion *, PNType, PN)
 create a type derived from self
PN potion_type_new2 (Potion *, PNType, PN, PN)
 create a named type
void potion_type_call_is (PN, PN)
 sets the default call method of the PNVtable
void potion_type_callset_is (PN, PN)
 set default writer
void potion_type_constructor_is (PN, PN)
 set default constructor
char potion_type_char (PNType)
 valid signature types syntax.y: arg-type = ('s' | 'S' | 'n' | 'N' | 'b' | 'B' | 'k' | 't' | 'o' | 'O' | '-' | '&') valid signature modifiers: '|' optional, '.
PN potion_class (Potion *, PN, PN, PN)
 create a user-class (ie type)
PN potion_ivars (Potion *, PN, PN, PN)
PN potion_obj_get_call (Potion *, PN)
 get the default accessor (usually "at")
PN potion_obj_get_callset (Potion *, PN)
 get default writer
PN potion_obj_get (Potion *, PN, PN, PN)
 implements OP_GETPATH
PN potion_obj_set (Potion *, PN, PN, PN, PN)
 implements OP_SETPATH
PN potion_object_new (Potion *, PN, PN)
PN potion_delegated (Potion *, PN, PN)
PN potion_call (Potion *, PN, PN_SIZE, PN *volatile)
PN potion_lookup (Potion *, PN, PN, PN)
 used in bind and def_method
PN potion_bind (Potion *, PN, PN)
PN potion_message (Potion *, PN, PN)
PN potion_closure_new (Potion *, PN_F, PN, PN_SIZE)
PN potion_callcc (Potion *, PN, PN)
PN potion_ref (Potion *, PN)
PN potion_sig (Potion *, char *)
int potion_sig_find (Potion *, PN, PN)
PN potion_decimal (Potion *, char *, int)
 strtod
PN potion_pow (Potion *, PN, PN, PN)
PN potion_srand (Potion *, PN, PN, PN)
PN potion_rand (Potion *, PN, PN)
PN potion_num_rand (Potion *, PN, PN)
PN potion_real (Potion *, double)
 new PNDecimal (double)
PN potion_sig_at (Potion *, PN, int)
int potion_sig_arity (Potion *, PN)
 number of args of sig tuple, implements the potion_closure_arity method.
PN potion_closure_arity (Potion *, PN, PN)
void potion_define_global (Potion *, PN, PN)
PN potion_obj_add (Potion *, PN, PN)
PN potion_obj_sub (Potion *, PN, PN)
PN potion_obj_mult (Potion *, PN, PN)
PN potion_obj_div (Potion *, PN, PN)
PN potion_obj_rem (Potion *, PN, PN)
PN potion_obj_bitn (Potion *, PN)
PN potion_obj_bitl (Potion *, PN, PN)
PN potion_obj_bitr (Potion *, PN, PN)
PN potion_any_cmp (Potion *, PN, PN, PN)
PN potion_tuple_empty (Potion *)
PN potion_tuple_with_size (Potion *, unsigned long)
PN potion_tuple_new (Potion *, PN)
PN potion_tuple_push (Potion *, PN, PN)
PN_SIZE potion_tuple_push_unless (Potion *, PN, PN)
PN_SIZE potion_tuple_find (Potion *, PN, PN)
 Return index of found value or -1.
PN potion_tuple_at (Potion *, PN, PN, PN)
PN potion_table_empty (Potion *)
PN potion_table_put (Potion *, PN, PN, PN, PN)
PN potion_table_set (Potion *, PN, PN, PN)
 helper function for potion_table_put:"put"
PN potion_table_at (Potion *, PN, PN, PN)
PN potion_tuple_bsearch (Potion *, PN, PN, PN)
PN potion_tuple_ins_sort (Potion *, PN, PN, PN)
PN potion_lick (Potion *, PN, PN, PN)
PN potion_source_compile (Potion *, PN, PN, PN, PN)
PN potion_source_load (Potion *, PN, PN)
PN potion_source_dump (Potion *, PN, PN, PN, PN)
PN potion_source_dumpbc (Potion *, PN, PN, PN)
PN potion_greg_parse (Potion *, PN)
PN potion_sig_string (Potion *, PN, PN)
Potionpotion_gc_boot (void *)
void potion_lobby_init (Potion *)
void potion_object_init (Potion *)
void potion_error_init (Potion *)
void potion_primitive_init (Potion *)
void potion_num_init (Potion *)
void potion_str_hash_init (Potion *)
void potion_str_init (Potion *)
void potion_table_init (Potion *)
void potion_source_init (Potion *)
void potion_lick_init (Potion *)
void potion_compiler_init (Potion *)
void potion_vm_init (Potion *)
void potion_file_init (Potion *)
 set Env global
void potion_loader_init (Potion *)
void potion_cont_init (Potion *)
void potion_dump_stack (Potion *)
void potion_loader_add (Potion *, PN path)
PN potion_any_is_nil (Potion *, PN, PN)
PN potion_num_string (Potion *, PN, PN)
PN potion_gc_reserved (Potion *, PN, PN)
PN potion_gc_actual (Potion *, PN, PN)
PN potion_gc_fixed (Potion *, PN, PN)
PN potion_parse (Potion *, PN, char *)
PN potion_vm_proto (Potion *, PN, PN,...)
PN potion_vm_class (Potion *, PN, PN)
PN potion_vm (Potion *, PN, PN, PN, PN_SIZE, PN *volatile)
PN potion_eval (Potion *, PN, int)
PN potion_run (Potion *, PN, int)
PN_F potion_jit_proto (Potion *, PN)
PN potion_load (Potion *, PN, PN, PN)
PN potion_class_find (Potion *, PN)
 find class by name. At first only system metaclasses (types), no user classes yet.

Variables

PN PN_allocate
 common method names in GC protected area
PN PN_break
PN PN_call
PN PN_class
PN PN_compile
PN PN_continue
PN PN_def
PN PN_delegated
PN PN_else
PN PN_elsif
PN PN_if
PN PN_lookup
PN PN_loop
PN PN_print
PN PN_return
PN PN_self
PN PN_string
PN PN_while
PN PN_add
PN PN_sub
PN PN_mult
PN PN_div
PN PN_rem
PN PN_bitn
PN PN_bitl
PN PN_bitr
PN PN_cmp
PN PN_number
PN PN_name

Macro Definition Documentation

#define POTION_MAJOR   0

Definition at line 43 of file potion.h.

#define POTION_MINOR   1

Definition at line 44 of file potion.h.

#define POTION_SIG   "p\07\10n"

Definition at line 45 of file potion.h.

#define POTION_VMID   0x79

Definition at line 46 of file potion.h.

#define POTION_X86   0

Definition at line 48 of file potion.h.

#define POTION_PPC   1

Definition at line 49 of file potion.h.

#define POTION_ARM   2

Definition at line 50 of file potion.h.

#define _XSTR (   s)    _STR(s)

Definition at line 60 of file potion.h.

#define _STR (   s)    #s

Definition at line 61 of file potion.h.

#define POTION_VERSION   _XSTR(POTION_MAJOR) "." _XSTR(POTION_MINOR)

Definition at line 62 of file potion.h.

#define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS

Definition at line 67 of file potion.h.

#define YY_DEBUG

Definition at line 71 of file potion.h.

#define __WORDSIZE   32

Definition at line 103 of file potion.h.

#define PN_TNIL   0x250000

Definition at line 108 of file potion.h.

#define PN_TNUMBER   (1+PN_TNIL)

Definition at line 109 of file potion.h.

#define PN_TBOOLEAN   (2+PN_TNIL)

Definition at line 110 of file potion.h.

#define PN_TSTRING   (3+PN_TNIL)

Definition at line 111 of file potion.h.

#define PN_TWEAK   (4+PN_TNIL)

Definition at line 112 of file potion.h.

#define PN_TCLOSURE   (5+PN_TNIL)

Definition at line 113 of file potion.h.

#define PN_TTUPLE   (6+PN_TNIL)

Definition at line 114 of file potion.h.

#define PN_TSTATE   (7+PN_TNIL)

Definition at line 115 of file potion.h.

#define PN_TFILE   (8+PN_TNIL)

Definition at line 116 of file potion.h.

#define PN_TOBJECT   (9+PN_TNIL)

Definition at line 117 of file potion.h.

#define PN_TVTABLE   (10+PN_TNIL)

Definition at line 118 of file potion.h.

#define PN_TSOURCE   (11+PN_TNIL)

Definition at line 119 of file potion.h.

#define PN_TBYTES   (12+PN_TNIL)

Definition at line 120 of file potion.h.

#define PN_TPROTO   (13+PN_TNIL)

Definition at line 121 of file potion.h.

#define PN_TLOBBY   (14+PN_TNIL)

Definition at line 122 of file potion.h.

#define PN_TTABLE   (15+PN_TNIL)

Definition at line 123 of file potion.h.

#define PN_TLICK   (16+PN_TNIL)

Definition at line 124 of file potion.h.

#define PN_TFLEX   (17+PN_TNIL)

Definition at line 125 of file potion.h.

#define PN_TSTRINGS   (18+PN_TNIL)

Definition at line 126 of file potion.h.

#define PN_TERROR   (19+PN_TNIL)

Definition at line 127 of file potion.h.

#define PN_TCONT   (20+PN_TNIL)

Definition at line 128 of file potion.h.

#define PN_TDECIMAL   (21+PN_TNIL)

Definition at line 129 of file potion.h.

#define PN_TUSER   (22+PN_TNIL)

Definition at line 130 of file potion.h.

#define PN_TYPE (   x)    potion_type((PN)(x))

Definition at line 133 of file potion.h.

#define PN_VTYPE (   x)    (((struct PNObject *)(x))->vt)

Definition at line 134 of file potion.h.

#define PN_TYPE_ID (   t)    ((t)-PN_TNIL)

Definition at line 135 of file potion.h.

#define PN_VTABLE (   t)    (PN_FLEX_AT(P->vts, PN_TYPE_ID(t)))

Definition at line 136 of file potion.h.

#define PN_TYPECHECK (   t)    (PN_TYPE_ID(t) >= 0 && PN_TYPE_ID(t) < PN_FLEX_SIZE(P->vts))

Definition at line 137 of file potion.h.

#define PN_NIL   ((PN)0)

Definition at line 139 of file potion.h.

#define PN_ZERO   ((PN)1)

Definition at line 140 of file potion.h.

#define PN_FALSE   ((PN)2)

Definition at line 141 of file potion.h.

#define PN_TRUE   ((PN)6)

Definition at line 142 of file potion.h.

#define PN_PRIMITIVE   7

Definition at line 143 of file potion.h.

#define PN_REF_MASK   ~7

Definition at line 144 of file potion.h.

#define PN_NONE   ((PN_SIZE)-1)

Definition at line 145 of file potion.h.

#define POTION_FWD   0xFFFFFFFE

Definition at line 146 of file potion.h.

#define POTION_COPIED   0xFFFFFFFF

Definition at line 147 of file potion.h.

#define NIL_NAME   "nil"

Definition at line 149 of file potion.h.

#define PN_FNUMBER   1

Definition at line 151 of file potion.h.

#define PN_FBOOLEAN   2

Definition at line 152 of file potion.h.

#define PN_TEST (   v)    ((PN)(v) != PN_FALSE && (PN)(v) != PN_NIL)

Definition at line 158 of file potion.h.

#define PN_BOOL (   v)    (PN_TEST(v) ? PN_TRUE : PN_FALSE)

Definition at line 162 of file potion.h.

#define PN_IS_PTR (   v)    (!PN_IS_NUM(v) && ((PN)(v) & PN_REF_MASK))

Definition at line 163 of file potion.h.

#define PN_IS_NIL (   v)    ((PN)(v) == PN_NIL)

Definition at line 164 of file potion.h.

#define PN_IS_BOOL (   v)    ((PN)(v) & PN_FBOOLEAN)

Definition at line 165 of file potion.h.

#define PN_IS_NUM (   v)    ((PN)(v) & PN_FNUMBER)

Definition at line 166 of file potion.h.

#define PN_IS_TUPLE (   v)    (PN_TYPE(v) == PN_TTUPLE)

Definition at line 167 of file potion.h.

#define PN_IS_STR (   v)    (PN_TYPE(v) == PN_TSTRING)

Definition at line 168 of file potion.h.

#define PN_IS_TABLE (   v)    (PN_TYPE(v) == PN_TTABLE)

Definition at line 169 of file potion.h.

#define PN_IS_CLOSURE (   v)    (PN_TYPE(v) == PN_TCLOSURE)

Definition at line 170 of file potion.h.

#define PN_IS_DECIMAL (   v)    (PN_IS_PTR(v) && PN_TYPE(v) == PN_TNUMBER)

Definition at line 171 of file potion.h.

#define PN_IS_PROTO (   v)    (PN_TYPE(v) == PN_TPROTO)

Definition at line 172 of file potion.h.

#define PN_IS_REF (   v)    (PN_TYPE(v) == PN_TWEAK)

Definition at line 173 of file potion.h.

#define PN_IS_METACLASS (   v)    (((struct PNVtable *)v)->meta == PN_NIL)

Definition at line 174 of file potion.h.

#define PN_NUM (   i)    ((PN)((((long)(i))<<1) + PN_FNUMBER))

Definition at line 181 of file potion.h.

#define PN_INT (   x)    ((long)((long)(x))>>1)

Definition at line 182 of file potion.h.

#define PN_DBL (   num)    (PN_IS_NUM(num) ? (double)PN_INT(num) : ((struct PNDecimal *)num)->value)

Definition at line 183 of file potion.h.

#define PN_PREC   16

Definition at line 184 of file potion.h.

#define PN_RAND ( )    PN_NUM(potion_rand_int())

Definition at line 185 of file potion.h.

#define PN_STR (   x)    potion_str(P, x)

Definition at line 186 of file potion.h.

#define PN_STRN (   x,
 
)    potion_str2(P, x, l)

Definition at line 187 of file potion.h.

#define PN_STRCAT (   a,
  b 
)    potion_strcat(P, (a), (b))

Definition at line 188 of file potion.h.

#define PN_STR_PTR (   x)    potion_str_ptr(x)

Definition at line 189 of file potion.h.

#define PN_STR_LEN (   x)    ((struct PNString *)(x))->len

Definition at line 190 of file potion.h.

#define PN_STR_B (   x)    potion_bytes_string(P, PN_NIL, x)

Definition at line 191 of file potion.h.

#define PN_CLOSURE (   x)    ((struct PNClosure *)(x))

Definition at line 192 of file potion.h.

#define PN_CLOSURE_F (   x)    ((struct PNClosure *)(x))->method

Definition at line 193 of file potion.h.

#define PN_PROTO (   x)    ((struct PNProto *)(x))

Definition at line 194 of file potion.h.

#define PN_FUNC (   f,
  s 
)    potion_closure_new(P, (PN_F)f, potion_sig(P, s), 0)

Definition at line 195 of file potion.h.

#define PN_DEREF (   x)    ((struct PNWeakRef *)(x))->data

Definition at line 196 of file potion.h.

#define PN_TOUCH (   x)    potion_gc_update(P, (PN)(x))

Definition at line 197 of file potion.h.

#define PN_ALIGN (   o,
  x 
)    (((((o) - 1) / (x)) + 1) * (x))

Definition at line 198 of file potion.h.

#define PN_OBJECT_HEADER
Value:
PNType vt; \
PNUniq uniq

Definition at line 200 of file potion.h.

#define PN_FLEX (   N,
 
)    typedef struct { PN_OBJECT_HEADER; PN_SIZE len; PN_SIZE siz; T ptr[0]; } N;

Definition at line 204 of file potion.h.

#define PN_FLEX_AT (   N,
 
)    ((PNFlex *)(N))->ptr[I]

Definition at line 205 of file potion.h.

#define PN_FLEX_SIZE (   N)    ((PNFlex *)(N))->len

Definition at line 206 of file potion.h.

#define PN_NUMHASH (   x)    (PNUniq)((x)>>33^(x)^(x)<<11)

Definition at line 211 of file potion.h.

#define PN_UNIQ (   x)    (PN_IS_PTR(x) ? ((struct PNObject *)(x))->uniq : PN_NUMHASH(x))

Definition at line 213 of file potion.h.

#define AS_STR (   x)    PN_STR_PTR(potion_send(x, PN_string))

Definition at line 215 of file potion.h.

#define DBG_t (   ...)    if (P->flags & DEBUG_TRACE) fprintf(stderr, __VA_ARGS__)

Definition at line 217 of file potion.h.

#define DBG_v (   ...)    if (P->flags & DEBUG_VERBOSE) fprintf(stderr, __VA_ARGS__)

Definition at line 219 of file potion.h.

#define DBG_vt (   ...)    if (P->flags & (DEBUG_VERBOSE|DEBUG_TRACE)) fprintf(stderr, __VA_ARGS__)

Definition at line 221 of file potion.h.

#define DBG_vi (   ...)    if (P->flags & (DEBUG_VERBOSE|DEBUG_INSPECT)) fprintf(stderr, __VA_ARGS__)

Definition at line 223 of file potion.h.

#define DBG_c (   ...)    if (P->flags & DEBUG_COMPILE) fprintf(stderr, __VA_ARGS__)

Definition at line 225 of file potion.h.

#define PN_IS_EMPTY (   T)    (PN_GET_TUPLE(T)->len == 0)

Definition at line 235 of file potion.h.

#define PN_TUP0 ( )    potion_tuple_empty(P)

Definition at line 236 of file potion.h.

#define PN_TUP (   X)    potion_tuple_new(P, X)

Definition at line 237 of file potion.h.

#define PN_PUSH (   T,
 
)    potion_tuple_push(P, T, (PN)X)

Definition at line 238 of file potion.h.

#define PN_GET (   T,
 
)    potion_tuple_find(P, T, X)

Definition at line 239 of file potion.h.

#define PN_PUT (   T,
 
)    potion_tuple_push_unless(P, T, X)

Definition at line 240 of file potion.h.

#define PN_GET_TUPLE (   t)    ((struct PNTuple *)potion_fwd((PN)t))

Definition at line 241 of file potion.h.

#define PN_TUPLE_LEN (   t)    PN_GET_TUPLE(t)->len

Definition at line 242 of file potion.h.

#define PN_TUPLE_AT (   t,
  n 
)    PN_GET_TUPLE(t)->set[n]

Definition at line 243 of file potion.h.

#define PN_TUPLE_COUNT (   T,
  I,
 
)
Value:
({ \
struct PNTuple * volatile __t##I = PN_GET_TUPLE(T); \
if (__t##I->len != 0) { \
for (I = 0; I < __t##I->len; I++) B \
} \
})

Definition at line 244 of file potion.h.

#define PN_TUPLE_EACH (   T,
  I,
  V,
 
)
Value:
({ \
struct PNTuple * volatile __t##V = PN_GET_TUPLE(T); \
if (__t##V->len != 0) { \
for (I = 0; I < __t##V->len; I++) { \
PN V = __t##V->set[I]; \
B \
} \
} \
})

Definition at line 251 of file potion.h.

#define PN_MANTISSA (   d,
  n 
)    d->real[1 + n]

PN_MANTISSA the last part of ->real.

Definition at line 315 of file potion.h.

#define PN_QUICK_FWD (   t,
  obj 
)
Value:
if (((struct PNFwd *)obj)->fwd == POTION_FWD) \
obj = (t)(((struct PNFwd *)obj)->ptr);

PN_QUICK_FWD - doing a single fwd check after a possible realloc.

Definition at line 494 of file potion.h.

#define OP_MAX   64

the jit

Definition at line 520 of file potion.h.

#define EXEC_BITS   4

0-4

Definition at line 554 of file potion.h.

#define POTION_INIT_STACK (   x)    PN __##x = 0x571FF; void *x = (void *)&__##x

Definition at line 613 of file potion.h.

#define POTION_OK   0

internal errors

Definition at line 684 of file potion.h.

#define POTION_NO_MEM   8910

Definition at line 685 of file potion.h.

#define potion_send (   RCV,
  MSG,
  ARGS... 
)
Value:
({ \
PN r = (PN)(RCV); \
PN c = potion_bind(P, r, (MSG)); \
if (PN_IS_CLOSURE(c)) \
c = ((struct PNClosure *)c)->method(P, c, r, ##ARGS); \
c; \
})

method caches (more great stuff from ian piumarta)

Definition at line 691 of file potion.h.

#define potion_method (   RCV,
  MSG,
  FN,
  SIG 
)    potion_send(RCV, PN_def, potion_str(P, MSG), PN_FUNC(FN, SIG))

Definition at line 699 of file potion.h.

#define potion_class_method (   RCV,
  MSG,
  FN,
  SIG 
)    potion_send(((struct PNVtable *)(RCV))->meta, PN_def, potion_str(P, MSG), PN_FUNC(FN, SIG))

Definition at line 701 of file potion.h.

Typedef Documentation

typedef unsigned long _PN

Definition at line 78 of file potion.h.

typedef unsigned int PN_SIZE

Definition at line 79 of file potion.h.

typedef unsigned int PNType

Definition at line 79 of file potion.h.

typedef unsigned int PNUniq

Definition at line 79 of file potion.h.

typedef struct Potion_State Potion

Definition at line 80 of file potion.h.

typedef volatile _PN PN

Definition at line 81 of file potion.h.

typedef PN(* PN_F)(Potion *, PN, PN,...)

Definition at line 337 of file potion.h.

typedef void(* OP_F)(Potion *P, struct PNProto *, PNAsm *volatile *,...)

Definition at line 522 of file potion.h.

Enumeration Type Documentation

enum PN_AST

An AST fragment, non-volatile.

Enumerator:
AST_CODE 
AST_VALUE 
AST_ASSIGN 
AST_NOT 
AST_OR 
AST_AND 
AST_CMP 
AST_EQ 
AST_NEQ 
AST_GT 
AST_GTE 
AST_LT 
AST_LTE 
AST_PIPE 
AST_CARET 
AST_AMP 
AST_WAVY 
AST_BITL 
AST_BITR 
AST_PLUS 
AST_MINUS 
AST_INC 
AST_TIMES 
AST_DIV 
AST_REM 
AST_POW 
AST_MSG 
AST_PATH 
AST_QUERY 
AST_PATHQ 
AST_EXPR 
AST_LIST 
AST_BLOCK 
AST_LICK 
AST_PROTO 
AST_DEBUG 

Definition at line 355 of file potion.h.

the interpreter (one per thread, houses its own garbage collector)

Enumerator:
EXEC_VM 

bytecode (switch or cgoto)

EXEC_JIT 

JIT if detected at config-time (x86, ppc)

EXEC_DEBUG 

-d: instrumented bytecode (line stepping) or just slow runloop?

EXEC_CHECK 

-c stop after compilation

EXEC_COMPILE 

to bytecode (dumpbc)

MAX_EXEC 

sanity-check (possible stack overwrites by callcc)

Definition at line 543 of file potion.h.

Enumerator:
MODE_STD 

0x10 16 plain potion/p5

MAX_SYNTAX 

sanity-check

Definition at line 556 of file potion.h.

Enumerator:
DEBUG_INSPECT 
DEBUG_VERBOSE 
DEBUG_TRACE 
DEBUG_PARSE 
DEBUG_PARSE_VERBOSE 
DEBUG_COMPILE 
DEBUG_GC 
DEBUG_JIT 

Definition at line 566 of file potion.h.

Function Documentation

static PN potion_fwd ( PN  obj)
inlinestatic

the potion type is the 't' in the vtable tuple (m,t)

resolve forwarding pointers for mutable types (PNTuple, PNBytes, etc.)

Definition at line 499 of file potion.h.

static PNType potion_type ( PN  obj)
inlinestatic

either immediate (NUM,BOOL,NIL) or a fwd

Definition at line 478 of file potion.h.

static char* potion_str_ptr ( PN  s)
inlinestatic

quick access to either PNString or PNByte pointer

Definition at line 506 of file potion.h.

PN_FLEX ( PNFlex  ,
PN   
)
void potion_garbagecollect ( Potion ,
int  ,
int   
)

Definition at line 239 of file gc.c.

PN_SIZE potion_type_size ( Potion ,
const struct PNObject  
)

Definition at line 269 of file gc.c.

unsigned long potion_rand_int ( )

generates a random number on [0,0xffffffff]-interval

Definition at line 130 of file mt19937ar.c.

double potion_rand_double ( )

generates a random number on [0,1) with 53-bit resolution

Definition at line 146 of file mt19937ar.c.

static void* potion_gc_alloc ( Potion P,
PNType  vt,
int  siz 
)
inlinestatic

quick inline allocation

Definition at line 621 of file potion.h.

static void* potion_gc_calloc ( Potion P,
PNType  vt,
int  siz 
)
inlinestatic

Definition at line 637 of file potion.h.

static void potion_gc_update ( Potion P,
PN  x 
)
inlinestatic

Definition at line 641 of file potion.h.

static void* potion_gc_realloc ( Potion P,
PNType  vt,
struct PNObject *volatile  obj,
PN_SIZE  sz 
)
inlinestatic

Definition at line 653 of file potion.h.

static struct PNData* potion_data_alloc ( Potion P,
int  siz 
)
staticread

Definition at line 675 of file potion.h.

Potion* potion_create ( void *  )

the potion API

Definition at line 108 of file internal.c.

void potion_destroy ( Potion )

Definition at line 120 of file internal.c.

PN potion_error ( Potion ,
PN  ,
long  ,
long  ,
PN   
)

Definition at line 217 of file internal.c.

void potion_fatal ( char *  )

Definition at line 243 of file internal.c.

void potion_allocation_error ( void  )

Definition at line 259 of file internal.c.

void potion_syntax_error ( Potion ,
const char *  ,
  ... 
)

Definition at line 248 of file internal.c.

PNType potion_kind_of ( PN  )

Definition at line 182 of file internal.c.

void potion_p ( Potion ,
PN   
)

Definition at line 264 of file internal.c.

PN potion_str ( Potion ,
const char *   
)

Definition at line 33 of file string.c.

PN potion_str2 ( Potion ,
char *  ,
size_t   
)

Definition at line 47 of file string.c.

PN potion_strcat ( Potion P,
char *  str,
char *  str2 
)

Definition at line 63 of file string.c.

PN potion_str_format ( Potion ,
const char *  ,
  ... 
)

Definition at line 80 of file string.c.

PN potion_byte_str ( Potion ,
const char *   
)

Definition at line 228 of file string.c.

PN potion_byte_str2 ( Potion ,
const char *  ,
size_t  len 
)

Definition at line 232 of file string.c.

PN potion_bytes ( Potion ,
size_t   
)

Definition at line 239 of file string.c.

PN potion_bytes_string ( Potion ,
PN  ,
PN   
)
PN_SIZE pn_printf ( Potion ,
PN  ,
const char *  ,
  ... 
)

Definition at line 247 of file string.c.

void potion_bytes_obj_string ( Potion ,
PN  ,
PN   
)

Definition at line 270 of file string.c.

PN potion_bytes_append ( Potion ,
PN  ,
PN  ,
PN   
)
void potion_release ( Potion ,
PN   
)
PN potion_def_method ( Potion P,
PN  ,
PN  ,
PN  ,
PN   
)

Definition at line 282 of file objmodel.c.

PN potion_type_new ( Potion ,
PNType  ,
PN   
)

create a type derived from self

Definition at line 150 of file objmodel.c.

PN potion_type_new2 ( Potion ,
PNType  ,
PN  ,
PN   
)

create a named type

Definition at line 162 of file objmodel.c.

void potion_type_call_is ( PN  ,
PN   
)

sets the default call method of the PNVtable

Definition at line 168 of file objmodel.c.

void potion_type_callset_is ( PN  ,
PN   
)

set default writer

Definition at line 178 of file objmodel.c.

void potion_type_constructor_is ( PN  ,
PN   
)

set default constructor

Definition at line 188 of file objmodel.c.

char potion_type_char ( PNType  type)

valid signature types syntax.y: arg-type = ('s' | 'S' | 'n' | 'N' | 'b' | 'B' | 'k' | 't' | 'o' | 'O' | '-' | '&') valid signature modifiers: '|' optional, '.

' end, ':' default

Definition at line 188 of file internal.c.

PN potion_class ( Potion P,
PN  cl,
PN  self,
PN  ivars 
)

create a user-class (ie type)

Parameters
cl,:set the ctor
self,:lobby or another type
ivars,:object members

Definition at line 195 of file objmodel.c.

PN potion_ivars ( Potion ,
PN  ,
PN  ,
PN   
)

Definition at line 228 of file objmodel.c.

PN potion_obj_get_call ( Potion ,
PN   
)

get the default accessor (usually "at")

Definition at line 172 of file objmodel.c.

PN potion_obj_get_callset ( Potion ,
PN   
)

get default writer

Definition at line 182 of file objmodel.c.

PN potion_obj_get ( Potion ,
PN  ,
PN  ,
PN   
)

implements OP_GETPATH

Definition at line 258 of file objmodel.c.

PN potion_obj_set ( Potion ,
PN  ,
PN  ,
PN  ,
PN   
)

implements OP_SETPATH

Definition at line 265 of file objmodel.c.

PN potion_object_new ( Potion ,
PN  ,
PN   
)
PN potion_delegated ( Potion ,
PN  ,
PN   
)

Definition at line 124 of file internal.c.

PN potion_call ( Potion ,
PN  ,
PN_SIZE  ,
PN volatile 
)

Definition at line 130 of file internal.c.

PN potion_lookup ( Potion ,
PN  ,
PN  ,
PN   
)

used in bind and def_method

Definition at line 321 of file objmodel.c.

PN potion_bind ( Potion ,
PN  ,
PN   
)

Definition at line 332 of file objmodel.c.

PN potion_message ( Potion ,
PN  ,
PN   
)

Definition at line 352 of file objmodel.c.

PN potion_closure_new ( Potion ,
PN_F  ,
PN  ,
PN_SIZE   
)

Definition at line 17 of file objmodel.c.

PN potion_callcc ( Potion ,
PN  ,
PN   
)
PN potion_ref ( Potion ,
PN   
)
PN potion_sig ( Potion ,
char *   
)

Definition at line 5135 of file syntax.c.

int potion_sig_find ( Potion ,
PN  ,
PN   
)

Definition at line 5156 of file syntax.c.

PN potion_decimal ( Potion ,
char *  ,
int   
)

strtod

Definition at line 21 of file number.c.

PN potion_pow ( Potion ,
PN  ,
PN  ,
PN   
)
PN potion_srand ( Potion ,
PN  ,
PN  ,
PN   
)
PN potion_rand ( Potion ,
PN  ,
PN   
)
PN potion_num_rand ( Potion ,
PN  ,
PN   
)
PN potion_real ( Potion ,
double   
)

new PNDecimal (double)

Definition at line 14 of file number.c.

PN potion_sig_at ( Potion P,
PN  sig,
int  index 
)
Returns
sig tuple at index, zero-based

Definition at line 100 of file objmodel.c.

int potion_sig_arity ( Potion P,
PN  sig 
)

number of args of sig tuple, implements the potion_closure_arity method.

sigs are encoded as tuples of len 2-3, (name type|modifier [default-value]) names String, modifiers Num. types also Num, but we will switch to VTable. default-value can be a value of any type and is prefixed with ':'

Returns
number of args as integer

Definition at line 76 of file objmodel.c.

PN potion_closure_arity ( Potion ,
PN  ,
PN   
)
void potion_define_global ( Potion ,
PN  ,
PN   
)

Definition at line 494 of file objmodel.c.

PN potion_obj_add ( Potion ,
PN  ,
PN   
)

Definition at line 359 of file objmodel.c.

PN potion_obj_sub ( Potion ,
PN  ,
PN   
)

Definition at line 363 of file objmodel.c.

PN potion_obj_mult ( Potion ,
PN  ,
PN   
)

Definition at line 367 of file objmodel.c.

PN potion_obj_div ( Potion ,
PN  ,
PN   
)

Definition at line 371 of file objmodel.c.

PN potion_obj_rem ( Potion ,
PN  ,
PN   
)

Definition at line 375 of file objmodel.c.

PN potion_obj_bitn ( Potion ,
PN   
)

Definition at line 379 of file objmodel.c.

PN potion_obj_bitl ( Potion ,
PN  ,
PN   
)

Definition at line 383 of file objmodel.c.

PN potion_obj_bitr ( Potion ,
PN  ,
PN   
)

Definition at line 387 of file objmodel.c.

PN potion_any_cmp ( Potion ,
PN  ,
PN  ,
PN   
)
PN potion_tuple_empty ( Potion )

Definition at line 135 of file table.c.

PN potion_tuple_with_size ( Potion ,
unsigned  long 
)

Definition at line 140 of file table.c.

PN potion_tuple_new ( Potion ,
PN   
)

Definition at line 145 of file table.c.

PN potion_tuple_push ( Potion ,
PN  ,
PN   
)

Definition at line 151 of file table.c.

PN_SIZE potion_tuple_push_unless ( Potion ,
PN  ,
PN   
)

Definition at line 178 of file table.c.

PN_SIZE potion_tuple_find ( Potion P,
PN  tuple,
PN  value 
)

Return index of found value or -1.

Parameters
valuePN
Returns
int

Definition at line 171 of file table.c.

PN potion_tuple_at ( Potion ,
PN  ,
PN  ,
PN   
)
PN potion_table_empty ( Potion )
PN potion_table_put ( Potion ,
PN  ,
PN  ,
PN  ,
PN   
)
PN potion_table_set ( Potion P,
PN  self,
PN  key,
PN  value 
)

helper function for potion_table_put:"put"

Parameters
keyPN
valuePN
Returns
self PNTable

Definition at line 115 of file table.c.

PN potion_table_at ( Potion ,
PN  ,
PN  ,
PN   
)
PN potion_tuple_bsearch ( Potion ,
PN  ,
PN  ,
PN   
)
PN potion_tuple_ins_sort ( Potion ,
PN  ,
PN  ,
PN   
)
PN potion_lick ( Potion ,
PN  ,
PN  ,
PN   
)

Definition at line 11 of file lick.c.

PN potion_source_compile ( Potion ,
PN  ,
PN  ,
PN  ,
PN   
)
PN potion_source_load ( Potion ,
PN  ,
PN   
)
PN potion_source_dump ( Potion ,
PN  ,
PN  ,
PN  ,
PN   
)
PN potion_source_dumpbc ( Potion ,
PN  ,
PN  ,
PN   
)
PN potion_greg_parse ( Potion ,
PN   
)
PN potion_sig_string ( Potion P,
PN  cl,
PN  sig 
)
Returns
string of the sig tuple. "arg1=o,arg2=o"

Definition at line 55 of file compile.c.

Potion* potion_gc_boot ( void *  sp)
Potion's GC is a generational copying GC. This is why the volatile keyword is used so liberally throughout the source code. PN types may suddenly move during any collection phase. They move from the birth area to the old area.

Potion actually begins by allocating an old area. This is for two reasons. First, the script may be too short to require an old area, so we want to avoid allocating two areas to start with. And second, since Potion loads its core classes into GC first, we save ourselves a severe promotion step by beginning with an automatic promotion to second generation. (Oh and this allows the core Potion struct pointer to be non-volatile.)

In short, this first page is never released, since the GC struct itself is on that page.

While this may pay a slight penalty in memory size for long-running scripts, perhaps I could add some occassional compaction to solve that as well.

See Also
potion_init() which calls GC_PROTECT()

Definition at line 588 of file gc.c.

void potion_lobby_init ( Potion )

Definition at line 551 of file objmodel.c.

void potion_object_init ( Potion )

Definition at line 535 of file objmodel.c.

void potion_error_init ( Potion )

Definition at line 235 of file internal.c.

void potion_primitive_init ( Potion )

Definition at line 88 of file primitive.c.

void potion_num_init ( Potion )

Definition at line 255 of file number.c.

void potion_str_hash_init ( Potion )

Definition at line 371 of file string.c.

void potion_str_init ( Potion )

Definition at line 375 of file string.c.

void potion_table_init ( Potion )

Definition at line 626 of file table.c.

void potion_source_init ( Potion )

Definition at line 103 of file ast.c.

void potion_lick_init ( Potion )

Definition at line 68 of file lick.c.

void potion_compiler_init ( Potion )

Definition at line 1099 of file compile.c.

void potion_vm_init ( Potion )

Definition at line 105 of file vm.c.

void potion_file_init ( Potion )

set Env global

Definition at line 150 of file file.c.

void potion_loader_init ( Potion )

Definition at line 222 of file load.c.

void potion_cont_init ( Potion )

Definition at line 164 of file callcc.c.

void potion_dump_stack ( Potion )

Definition at line 280 of file internal.c.

void potion_loader_add ( Potion ,
PN  path 
)

Definition at line 218 of file load.c.

PN potion_any_is_nil ( Potion ,
PN  ,
PN   
)

Definition at line 28 of file primitive.c.

PN potion_num_string ( Potion ,
PN  ,
PN   
)
PN potion_gc_reserved ( Potion ,
PN  ,
PN   
)

Definition at line 656 of file gc.c.

PN potion_gc_actual ( Potion ,
PN  ,
PN   
)

Definition at line 638 of file gc.c.

PN potion_gc_fixed ( Potion ,
PN  ,
PN   
)

Definition at line 648 of file gc.c.

PN potion_parse ( Potion ,
PN  ,
char *   
)

Definition at line 5115 of file syntax.c.

PN potion_vm_proto ( Potion ,
PN  ,
PN  ,
  ... 
)

Definition at line 117 of file vm.c.

PN potion_vm_class ( Potion ,
PN  ,
PN   
)

Definition at line 134 of file vm.c.

PN potion_vm ( Potion ,
PN  ,
PN  ,
PN  ,
PN_SIZE  ,
PN volatile 
)

Definition at line 294 of file vm.c.

PN potion_eval ( Potion ,
PN  ,
int   
)

Definition at line 1092 of file compile.c.

PN potion_run ( Potion ,
PN  ,
int   
)

Definition at line 1076 of file compile.c.

PN_F potion_jit_proto ( Potion ,
PN   
)
PN potion_load ( Potion ,
PN  ,
PN  ,
PN   
)

Definition at line 165 of file load.c.

PN potion_class_find ( Potion ,
PN   
)

find class by name. At first only system metaclasses (types), no user classes yet.

Definition at line 218 of file objmodel.c.

Variable Documentation

PN PN_allocate

common method names in GC protected area

Definition at line 15 of file internal.c.

PN PN_break

Definition at line 15 of file internal.c.

PN PN_call

Definition at line 15 of file internal.c.

PN PN_class

Definition at line 15 of file internal.c.

PN PN_compile

Definition at line 15 of file internal.c.

PN PN_continue

Definition at line 15 of file internal.c.

PN PN_def

Definition at line 15 of file internal.c.

PN PN_delegated

Definition at line 15 of file internal.c.

PN PN_else

Definition at line 15 of file internal.c.

PN PN_elsif

Definition at line 15 of file internal.c.

PN PN_if

Definition at line 15 of file internal.c.

PN PN_lookup

Definition at line 15 of file internal.c.

PN PN_loop

Definition at line 15 of file internal.c.

PN PN_print

Definition at line 15 of file internal.c.

PN PN_return

Definition at line 15 of file internal.c.

PN PN_self

Definition at line 15 of file internal.c.

PN PN_string

Definition at line 15 of file internal.c.

PN PN_while

Definition at line 15 of file internal.c.

PN PN_add

Definition at line 18 of file internal.c.

PN PN_sub

Definition at line 18 of file internal.c.

PN PN_mult

Definition at line 18 of file internal.c.

PN PN_div

Definition at line 18 of file internal.c.

PN PN_rem

Definition at line 18 of file internal.c.

PN PN_bitn

Definition at line 18 of file internal.c.

PN PN_bitl

Definition at line 18 of file internal.c.

PN PN_bitr

Definition at line 18 of file internal.c.

PN PN_cmp

Definition at line 19 of file internal.c.

PN PN_number

Definition at line 19 of file internal.c.

PN PN_name

Definition at line 19 of file internal.c.