32 PN vtable, obj_vt, num_vt;
104 #ifndef DISABLE_CALLCC
151 return c->method(P, cl, cl);
153 return c->method(P, cl, argv[0]);
155 return c->method(P, cl, argv[0], argv[1]);
157 return c->method(P, cl, argv[0], argv[1], argv[2]);
159 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3]);
161 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3], argv[4]);
163 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3], argv[4],
166 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3], argv[4],
169 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3], argv[4],
170 argv[5], argv[6], argv[7]);
172 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3], argv[4],
173 argv[5], argv[6], argv[7], argv[8]);
175 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3], argv[4],
176 argv[5], argv[6], argv[7], argv[8], argv[9]);
178 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3], argv[4],
179 argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]);
181 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3], argv[4],
182 argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11]);
184 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3], argv[4],
185 argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11],
188 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3], argv[4],
189 argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11],
192 return c->method(P, cl, argv[0], argv[1], argv[2], argv[3], argv[4],
193 argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11],
194 argv[12], argv[13], argv[14]);
250 "** Where: (line %ld, character %ld) %s\n",
PN_STR_PTR(e->message),
283 #define PN_EXIT_ERROR 1
284 #define PN_EXIT_FATAL 2
287 fprintf(stderr,
"** %s\n", message);
296 ((
struct PNBytes *
volatile)out)->len = 0;
300 fprintf(stderr,
"** Syntax error: %s at \"%s\", line %d\n",
PN_STR_PTR(out),
321 void potion_dump(
Potion *P,
PN data) {
326 printf(
"%s (%s)\n", d, t);
328 #define pdump(data) potion_dump(P, data)
336 #if POTION_STACK_DIR > 0
344 printf(
"-- dumping %ld stack from %p to %p --\n", n, start, end);
345 printf(
" ebp = %p, *ebp = 0x%lx\n", ebp, *ebp);
348 printf(" stack(%ld) = %p: 0x%lx", n, start, *start);
350 printf(" vt=%x prot",
PN_TYPE(o));
352 printf(" vt=%x birth",
PN_TYPE(o));
354 printf(" vt=%x OLD",
PN_TYPE(o));
359 printf(" %ld INT\n",
PN_INT(*start));
361 printf(" %s BOOL\n", *start == 2 ? "false" : "true");
PN potion_delegated(Potion *P, PN closure, PN self)
static void potion_init(Potion *P)
#define PN_FLEX_NEW(N, V, T, S)
PN potion_bytes(Potion *, size_t)
PN potion_def_method(Potion *P, PN closure, PN self, PN key, PN method)
define a method for a class
void potion_destroy(Potion *P)
PN line
PNString of src line.
#define PN_FLEX_NEEDS(X, N, V, T, S)
byte strings are raw character data, volatile, may be appended/changed.
void potion_table_init(Potion *)
unsigned long potion_rand_int(void)
generates a random number on [0,0xffffffff]-interval
#define PN_ALLOC_N(V, T, C)
PN PN_allocate
common method names in GC protected area
PN potion_error_string(Potion *P, PN cl, PN self)
struct to wrap arbitrary data that we may want to allocate from Potion.
void potion_lobby_init(Potion *P)
#define potion_method(RCV, MSG, FN, SIG)
void potion_cont_init(Potion *P)
#define IN_BIRTH_REGION(p)
void potion_num_init(Potion *P)
static PN potion_fwd(PN)
the potion type is the 't' in the vtable tuple (m,t)
struct PNMemory * mem
allocator/gc
char potion_type_char(PNType type)
valid signature types syntax.y: arg-type = ('s' | 'S' | 'n' | 'N' | 'b' | 'B' | 'k' | 't' | 'o' | 'O'...
PN_SIZE fileno
currently parsed file
void potion_file_init(Potion *P)
set Env global
static char * potion_type_name(Potion *P, PN obj)
void * cstack
machine stack start
void potion_primitive_init(Potion *)
standard objects act like C structs the fields are defined by the type and it's a fixed size...
Potion * potion_gc_boot(void *sp)
void potion_lick_init(Potion *P)
PN potion_io_error(Potion *P, const char *msg)
PN potion_type_error(Potion *P, PN obj)
void potion_syntax_error(Potion *P, struct PNSource *t, const char *fmt,...)
#define IN_OLDER_REGION(p)
void potion_object_init(Potion *P)
PN potion_error(Potion *P, PN msg, long lineno, long charno, PN excerpt)
PNFlex *volatile vts
built in types
an error, including a description, file location, a brief excerpt.
PN potion_str_format(Potion *, const char *,...) __attribute__((format(printf
void potion_esp(void **esp)
PN potion_type_new(Potion *P, PNType t, PN self)
create a non-user type, derived from self
Potion * potion_create(void *sp)
the potion API
PN potion_call(Potion *P, PN cl, PN_SIZE argc, PN *volatile argv)
PN potion_allocate(Potion *P, PN cl, PN self, PN len)
the global interpreter state P. currently singleton (not threads yet)
PN_SIZE pn_printf(Potion *, PN, const char *,...) __attribute__((format(printf
PNType potion_kind_of(PN obj)
void potion_loader_init(Potion *P)
void potion_error_init(Potion *P)
void potion_str_init(Potion *)
#define IS_GC_PROTECTED(p)
void potion_str_hash_init(Potion *)
static PNType potion_type(PN obj)
either immediate (NUM,BOOL,NIL) or a fwd
the central table type, based on core/khash.h
void potion_compiler_init(Potion *P)
PN potion_lookup(Potion *P, PN closure, PN self, PN key)
used in bind and def_method
#define potion_send(RCV, MSG, ARGS...)
method caches (more great stuff from ian piumarta)
PN potion_type_error_want(Potion *P, const char *param, PN obj, const char *type)
void potion_source_init(Potion *P)
void potion_p(Potion *P, PN x)
void potion_allocation_error(void)
struct PNSource::@1 loc
bitfield of fileno and lineno
void potion_vm_init(Potion *)
void potion_fatal(char *message)
void potion_dump_stack(Potion *)
void potion_gc_release(Potion *P)