Skip to content

Commit

Permalink
global rename: s/PXLL/IRK
Browse files Browse the repository at this point in the history
For Issue #33.
  • Loading branch information
samrushing committed Aug 29, 2018
1 parent 9e560af commit 61f558e
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 76 deletions.
6 changes: 3 additions & 3 deletions demo/c1.scm
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

(define (make-in-addr ip port)
(let ((ss (%callocate (struct sockaddr_in) 1)))
(%%cexp ((buffer (struct sockaddr_in)) -> undefined) "(%0->sin_family = PF_INET, PXLL_UNDEFINED)" ss)
(%%cexp ((buffer (struct sockaddr_in)) int -> undefined) "(%0->sin_port = htons(%1), PXLL_UNDEFINED)" ss port)
(%%cexp ((buffer (struct sockaddr_in)) -> undefined) "(%0->sin_family = PF_INET, IRK_UNDEFINED)" ss)
(%%cexp ((buffer (struct sockaddr_in)) int -> undefined) "(%0->sin_port = htons(%1), IRK_UNDEFINED)" ss port)
(trysys (inet_pton AF_INET ip ss))
ss))

Expand All @@ -49,7 +49,7 @@
(define (accept fd)
(let ((sockaddr (%callocate (struct sockaddr_in) 1))
(address-len (%callocate socklen_t 1)))
(%%cexp ((buffer socklen_t) -> undefined) "(*%0 = sizeof(struct sockaddr_in), PXLL_UNDEFINED)" address-len)
(%%cexp ((buffer socklen_t) -> undefined) "(*%0 = sizeof(struct sockaddr_in), IRK_UNDEFINED)" address-len)
(%%cexp (int (buffer (struct sockaddr_in)) (buffer socklen_t) -> int)
"accept (%0, (struct sockaddr *) %1, %2)"
fd sockaddr address-len)))
Expand Down
4 changes: 2 additions & 2 deletions demo/kqueue.scm
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ set_nonblocking (int fd)

(define (make-in-addr ip port)
(let ((ss (%callocate (struct sockaddr_in) 1)))
(%%cexp ((buffer (struct sockaddr_in)) -> undefined) "(%0->sin_family = PF_INET, PXLL_UNDEFINED)" ss)
(%%cexp ((buffer (struct sockaddr_in)) int -> undefined) "(%0->sin_port = htons(%1), PXLL_UNDEFINED)" ss port)
(%%cexp ((buffer (struct sockaddr_in)) -> undefined) "(%0->sin_family = PF_INET, IRK_UNDEFINED)" ss)
(%%cexp ((buffer (struct sockaddr_in)) int -> undefined) "(%0->sin_port = htons(%1), IRK_UNDEFINED)" ss port)
(trysys (inet_pton AF_INET ip ss))
ss))

Expand Down
48 changes: 24 additions & 24 deletions include/header1.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ dump_object (object * ob, int depth)
// indent (depth);
if (depth > 100) {
fprintf (stdout , "...");
return (object *) PXLL_UNDEFINED;
return (object *) IRK_UNDEFINED;
}
if (!ob) {
fprintf (stdout, "<null>");
Expand Down Expand Up @@ -256,7 +256,7 @@ dump_object (object * ob, int depth)
break;
}
}
return (object *) PXLL_UNDEFINED;
return (object *) IRK_UNDEFINED;
}

// 'magic' comparison function.
Expand Down Expand Up @@ -404,7 +404,7 @@ object *
irk_putc (object * ch)
{
fputc (GET_CHAR (ch), stdout);
return PXLL_UNDEFINED;
return IRK_UNDEFINED;
}

object *
Expand Down Expand Up @@ -460,7 +460,7 @@ print_list (pxll_pair * l)
object * car = l->car;
object * cdr = l->cdr;
dump_object (car, 0);
if (cdr == PXLL_NIL) {
if (cdr == IRK_NIL) {
fprintf (stdout, ")");
break;
} else if (!is_immediate (cdr) && GET_TYPECODE (*cdr) == TC_PAIR) {
Expand Down Expand Up @@ -560,20 +560,20 @@ void
clear_space (object * p, pxll_int n)
{
while (n--) {
*p++ = PXLL_NIL;
*p++ = IRK_NIL;
}
}
#else
void
clear_space (object * p, pxll_int n)
{
memset (p, (int) PXLL_NIL, sizeof(object) * n);
memset (p, (int) IRK_NIL, sizeof(object) * n);
}
#endif

object * lenv = PXLL_NIL;
object * k = PXLL_NIL;
object * top = PXLL_NIL; // top-level (i.e. 'global') environment
object * lenv = IRK_NIL;
object * k = IRK_NIL;
object * top = IRK_NIL; // top-level (i.e. 'global') environment
object * limit; // = heap0 + (heap_size - head_room);
object * freep; // = heap0;
static object * t = 0; // temp - for swaps & building tuples
Expand All @@ -596,7 +596,7 @@ get_stack_depth()
{
int result = 0;
object * k0 = k;
while (k0 != PXLL_NIL) {
while (k0 != IRK_NIL) {
result++;
k0 = (object*) k0[1];
}
Expand Down Expand Up @@ -644,7 +644,7 @@ allocate (pxll_int tc, pxll_int size)
// in gc_flip() to 'pre-clear' the heap... probably a cache effect...
while (size--) {
// this keeps gc from being confused by partially-filled objects.
*(++freep) = PXLL_NIL;
*(++freep) = IRK_NIL;
}
++freep;
#else
Expand Down Expand Up @@ -751,7 +751,7 @@ free_foreign (object * foreign)
if (GET_TUPLE_LENGTH (*foreign) == 1) {
free (foreign[1]);
}
return (object*) PXLL_UNDEFINED;
return (object*) IRK_UNDEFINED;
}

object *
Expand Down Expand Up @@ -849,7 +849,7 @@ DENV0 (object * env)
{
pxll_tuple * t = (pxll_tuple *) env;
fprintf (stdout, "ENV@%p: [", env);
while (t != (pxll_tuple*)PXLL_NIL) {
while (t != (pxll_tuple*)IRK_NIL) {
pxll_int n = get_tuple_size ((object *) t);
fprintf (stdout, "%" PRIdPTR " ", n);
t = t->next;
Expand Down Expand Up @@ -901,7 +901,7 @@ void exit_continuation (object * result)
#if USE_CYCLECOUNTER
program_end_time = rdtsc();
#endif
if ((result != (object*) PXLL_UNDEFINED) && !IS_INTEGER(result)) {
if ((result != (object*) IRK_UNDEFINED) && !IS_INTEGER(result)) {
// only print the result object if it's "interesting".
dump_object ((object *) result, 0);
fprintf (stdout, "\n");
Expand Down Expand Up @@ -992,10 +992,10 @@ invoke_closure (object * closure, object * args)
void invoke_closure_1 (void)
{
lenv = (object*) k[2]; k = (object *)k[1];
// Note: no PXLL_RETURN here. that's because we want to return (in the C sense)
// Note: no IRK_RETURN here. that's because we want to return (in the C sense)
// to invoke_closure so the result can be returned to the original C caller,
// e.g. vm_go().
// if there *was* a PXLL_RETURN here, it would actually call exit_continuation(),
// if there *was* a IRK_RETURN here, it would actually call exit_continuation(),
// and exit the entire program.
}
#endif
Expand Down Expand Up @@ -1045,7 +1045,7 @@ object *
irk_set_verbose_gc (object * data)
{
pxll_int r = verbose_gc;
verbose_gc = PXLL_IS_TRUE (data);
verbose_gc = IRK_IS_TRUE (data);
return (object*) r;
}

Expand Down Expand Up @@ -1085,7 +1085,7 @@ irk_mul2 (pxll_int a, pxll_int b, object * rvo)
r = ((__int128_t) a) * ((__int128_t) b);
rv->val[0] = box ((int64_t) (r >> 60));
rv->val[1] = box ((int64_t) (r & mask));
return (object*) PXLL_UNDEFINED;
return (object*) IRK_UNDEFINED;
}

// divide two digits by one digit.
Expand All @@ -1100,7 +1100,7 @@ irk_div2b1 (pxll_int ah, pxll_int al, pxll_int b, object * rvo)
__int128_t r = a % b;
rv->val[0] = box ((int64_t) (q & mask));
rv->val[1] = box ((int64_t) (r & mask));
return (object*) PXLL_UNDEFINED;
return (object*) IRK_UNDEFINED;
}

#else
Expand All @@ -1115,7 +1115,7 @@ irk_mul2 (pxll_int a, pxll_int b, object * rvo)
r = ((int64_t) a) * ((int64_t) b);
rv->val[0] = box ((int32_t) (r >> 28));
rv->val[1] = box ((int32_t) (r & mask));
return (object*) PXLL_UNDEFINED;
return (object*) IRK_UNDEFINED;
}

// divide two digits by one digit.
Expand All @@ -1130,7 +1130,7 @@ irk_div2b1 (pxll_int ah, pxll_int al, pxll_int b, object * rvo)
int64_t r = a % b;
rv->val[0] = box ((int32_t) (q & mask));
rv->val[1] = box ((int32_t) (r & mask));
return (object*) PXLL_UNDEFINED;
return (object*) IRK_UNDEFINED;
}

#endif
Expand Down Expand Up @@ -1181,8 +1181,8 @@ main (int argc, char * argv[])
limit = heap0 + (heap_size - head_room);
freep = heap0;
k = allocate (TC_SAVE, 3);
k[1] = (object *) PXLL_NIL; // top of stack
k[2] = (object *) PXLL_NIL; // null environment
k[1] = (object *) IRK_NIL; // top of stack
k[2] = (object *) IRK_NIL; // null environment
k[3] = (object *) exit_continuation;
#if USE_CYCLECOUNTER
program_start_time = rdtsc();
Expand All @@ -1192,7 +1192,7 @@ main (int argc, char * argv[])
}
}

#define PXLL_RETURN(d) ((kfun)(k[3]))(r##d);
#define IRK_RETURN(d) ((kfun)(k[3]))(r##d);
#define O object *

// With the C backend, generated code follow this point.
Expand Down
20 changes: 10 additions & 10 deletions include/pxll.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef PXLL_H
#define PXLL_H
#ifndef IRK_H
#define IRK_H

#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -50,11 +50,11 @@ object * heap1 = NULL;
// leaving a max of 59 variants in any one type.

// immediate constants
#define PXLL_FALSE (object *) (0x000 | TC_BOOL)
#define PXLL_TRUE (object *) (0x100 | TC_BOOL)
#define PXLL_MAYBE (object *) (0x200 | TC_BOOL) // just kidding
#define PXLL_NIL (object *) (0x000 | TC_NIL)
#define PXLL_UNDEFINED (object *) (0x000 | TC_UNDEFINED)
#define IRK_FALSE (object *) (0x000 | TC_BOOL)
#define IRK_TRUE (object *) (0x100 | TC_BOOL)
#define IRK_MAYBE (object *) (0x200 | TC_BOOL) // just kidding
#define IRK_NIL (object *) (0x000 | TC_NIL)
#define IRK_UNDEFINED (object *) (0x000 | TC_UNDEFINED)

// XXX make these inline functions rather than macros

Expand Down Expand Up @@ -86,8 +86,8 @@ object * heap1 = NULL;
#define CONS_HEADER ((2<<8)|TC_PAIR)

// these make the C output more compact & readable
#define PXLL_TEST(x) ((x) ? PXLL_TRUE : PXLL_FALSE)
#define PXLL_IS_TRUE(x) ((x) != PXLL_FALSE)
#define IRK_TEST(x) ((x) ? IRK_TRUE : IRK_FALSE)
#define IRK_IS_TRUE(x) ((x) != IRK_FALSE)

#define UOBJ_GET(o,i) (((pxll_vector*)(o))->val[i])
#define UOBJ_SET(o,i,v) (((pxll_vector*)(o))->val[i] = v)
Expand Down Expand Up @@ -213,5 +213,5 @@ get_safe_typecode (object * ob)
}
}

#endif // PXLL_H
#endif // IRK_H

2 changes: 1 addition & 1 deletion lib/malloc.scm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

(define free
(malloc:t r)
-> (%%cexp (int -> undefined) "(free((void*)%0), PXLL_UNDEFINED)" r)
-> (%%cexp (int -> undefined) "(free((void*)%0), IRK_UNDEFINED)" r)
)

(define malloc/addr
Expand Down
18 changes: 9 additions & 9 deletions self/c.scm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(type:pred name predargs _)
-> (match name with
'int -> (format "UNBOX_INTEGER(" arg ")")
'bool -> (format "PXLL_IS_TRUE(" arg ")")
'bool -> (format "IRK_IS_TRUE(" arg ")")
'string -> (format "((pxll_string*)(" arg "))->data")
'cstring -> (format "(char*)" arg)
'buffer -> (format "(" (irken-type->c-type type) "(((pxll_vector*)" arg ")+1))")
Expand Down Expand Up @@ -74,11 +74,11 @@
(define (wrap-out type exp)
(match type with
(type:pred 'int _ _) -> (format "BOX_INTEGER((pxll_int)" exp ")")
(type:pred 'bool _ _) -> (format "PXLL_TEST(" exp ")")
(type:pred 'bool _ _) -> (format "IRK_TEST(" exp ")")
(type:pred 'cstring _ _) -> (format "(object*)" exp)
(type:pred 'cref _ _) -> (format "(make_foreign((void*)" exp "))")
(type:pred '* _ _) -> (format "(make_foreign((void*)" exp "))")
(type:pred 'void _ _) -> (format "((" exp "), PXLL_UNDEFINED)")
(type:pred 'void _ _) -> (format "((" exp "), IRK_UNDEFINED)")
(type:pred kind _ _) -> (if (member-eq? kind c-int-types)
(format "box((pxll_int)" exp ")")
exp)
Expand Down Expand Up @@ -147,7 +147,7 @@
(declared (set2-maker string-compare)))

(define emit
(insn:return target) -> (o.write (format "PXLL_RETURN(" (int target) ");"))
(insn:return target) -> (o.write (format "IRK_RETURN(" (int target) ");"))
(insn:literal lit k) -> (begin (emit-literal lit k.target) (emit k.insn))
(insn:litcon i kind k) -> (begin (emit-litcon i kind k.target) (emit k.insn))
(insn:test reg jn k0 k1 k) -> (emit-test reg jn k0 k1 k)
Expand Down Expand Up @@ -205,7 +205,7 @@

(define (emit-test reg jn k0 k1 k)
(push-jump-continuation k jn)
(o.write (format "if PXLL_IS_TRUE(r" (int reg)") {"))
(o.write (format "if IRK_IS_TRUE(r" (int reg)") {"))
(o.indent)
(emit k0)
(o.dedent)
Expand All @@ -224,7 +224,7 @@
(args1 (map2 wrap-in arg-types args0))
(exp (wrap-out result-type (cexp-subst template args1))))
(push-jump-continuation k jn)
(o.write (format "if PXLL_IS_TRUE(" exp ") {"))
(o.write (format "if IRK_IS_TRUE(" exp ") {"))
(o.indent)
(emit k0)
(o.dedent)
Expand Down Expand Up @@ -495,8 +495,8 @@
(define (get-uitag dtname altname index)
(match dtname altname with
'list 'nil -> "TC_NIL"
'bool 'true -> "(pxll_int)PXLL_TRUE"
'bool 'false -> "(pxll_int)PXLL_FALSE"
'bool 'true -> "(pxll_int)IRK_TRUE"
'bool 'false -> "(pxll_int)IRK_FALSE"
_ _ -> (format "UITAG(" (int index) ")")))

(define (emit-primop name parm type args k)
Expand Down Expand Up @@ -638,7 +638,7 @@
(define (prim-free args)
(o.write (format "free_foreign (r" (int (car args)) ");"))
(when (>= k.target 0)
(o.write (format "O r" (int k.target) " = PXLL_UNDEFINED;"))))
(o.write (format "O r" (int k.target) " = IRK_UNDEFINED;"))))

(define (prim-exit args)
(o.write (format "exit_continuation(r" (int (car args)) ");"))
Expand Down
2 changes: 1 addition & 1 deletion tests/f_match5.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

(define (error x)
(%%cexp (-> 'a) "goto Lreturn")
(%%cexp (-> 'a) "PXLL_UNDEFINED")
(%%cexp (-> 'a) "IRK_UNDEFINED")
)

;; without a default case this should raise a match error
Expand Down
2 changes: 1 addition & 1 deletion tests/t15.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(%%cexp (-> int) "random()"))

(define (srandom n)
(%%cexp (int -> undefined) "(srandom (%0), PXLL_UNDEFINED)" n))
(%%cexp (int -> undefined) "(srandom (%0), IRK_UNDEFINED)" n))

(define (fun p)
;; takes and returns an identity function
Expand Down
2 changes: 1 addition & 1 deletion tests/t17.scm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(%%cexp (int -> int) "(pxll_int)malloc(%0)" n))

(define (free n)
(%%cexp (int -> undefined) "free((void*)%0); PXLL_UNDEFINED" n))
(%%cexp (int -> undefined) "free((void*)%0); IRK_UNDEFINED" n))

(define (write-int p n)
(%%cexp (int int -> undefined) "(*(pxll_int *)(%0)) = %1" p n))
Expand Down
4 changes: 2 additions & 2 deletions tests/t6.scm
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
;; r1 = (object *) 1;
;; if (unbox(r0)==unbox(r1)) {
;; r0 = top[2];
;; PXLL_RETURN(0);
;; IRK_RETURN(0);
;; } else {
;; r0 = varref (0,0);
;; r1 = (object *) 3;
;; r0 = box(unbox(r0)-unbox(r1));
;; lenv[2] = r0;
;; goto FUN_146loop_7;
;; }
;; PXLL_RETURN(0);
;; IRK_RETURN(0);

;; gcc -O3 compiles *that* to:
;; L130:
Expand Down
2 changes: 1 addition & 1 deletion tests/t_nvcase0.scm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(define (error x)
(printn x)
(%%cexp (-> 'a) "exit_continuation();")
(%%cexp (-> 'a) "PXLL_UNDEFINED")
(%%cexp (-> 'a) "IRK_UNDEFINED")
)

(define (thing x)
Expand Down
Loading

0 comments on commit 61f558e

Please sign in to comment.