mntmn 9 years ago
parent
commit
fd4e772f2f
3 changed files with 11 additions and 1 deletions
  1. 1 0
      .gitignore
  2. 2 1
      sledge/compiler_new.c
  3. 8 0
      sledge/stream.c

+ 1 - 0
.gitignore

@@ -8,3 +8,4 @@ os/rootfs/grumpy.data
 sledge/sledge
 sledge/sledge
 build/*.elf
 build/*.elf
 newlib
 newlib
+.#*

+ 2 - 1
sledge/compiler_new.c

@@ -359,6 +359,7 @@ int compile_expr(Cell* expr, Frame* frame, int return_type) {
         if (argi>0) {
         if (argi>0) {
           // save registers
           // save registers
           // FIXME RETHINK
           // FIXME RETHINK
+
           jit_push(ARGR0,ARGR0+argi-1);
           jit_push(ARGR0,ARGR0+argi-1);
           frame->sp+=(1+argi-1);
           frame->sp+=(1+argi-1);
         }
         }
@@ -410,7 +411,7 @@ int compile_expr(Cell* expr, Frame* frame, int return_type) {
         argdefs[argi].slot = argi-1;
         argdefs[argi].slot = argi-1;
         argdefs[argi].type = ARGT_CELL;
         argdefs[argi].type = ARGT_CELL;
 
 
-        if (given_tag == TAG_INT || given_tag == TAG_STR || given_tag == TAG_BYTES) {
+        if (given_tag == TAG_SYM || given_tag == TAG_CONS || given_tag == TAG_INT || given_tag == TAG_STR || given_tag == TAG_BYTES) {
           argdefs[argi].type = ARGT_CONST;
           argdefs[argi].type = ARGT_CONST;
           //printf("const arg of type %d at %p\n",arg->tag,arg);
           //printf("const arg of type %d at %p\n",arg->tag,arg);
         }
         }

+ 8 - 0
sledge/stream.c

@@ -119,6 +119,10 @@ Cell* wrap_in_lambda(void* cfunc) {
 // TODO: pass stream (context) to handlers
 // TODO: pass stream (context) to handlers
 
 
 Cell* stream_read(Cell* stream) {
 Cell* stream_read(Cell* stream) {
+  if (!stream || stream->tag!=TAG_STREAM) {
+    printf("[fs] error: non-stream passed to recv\r\n");
+    return alloc_nil();
+  }
   Stream* s = (Stream*)stream->addr;
   Stream* s = (Stream*)stream->addr;
   Cell* read_fn = s->fs->read_fn;
   Cell* read_fn = s->fs->read_fn;
   //char debug_buf[256];
   //char debug_buf[256];
@@ -128,6 +132,10 @@ Cell* stream_read(Cell* stream) {
 }
 }
 
 
 Cell* stream_write(Cell* stream, Cell* arg) {
 Cell* stream_write(Cell* stream, Cell* arg) {
+  if (!stream || stream->tag!=TAG_STREAM) {
+    printf("[fs] error: non-stream passed to send\r\n");
+    return alloc_nil();
+  }
   Stream* s = (Stream*)stream->addr;
   Stream* s = (Stream*)stream->addr;
   Cell* write_fn = s->fs->write_fn;
   Cell* write_fn = s->fs->write_fn;
   //char debug_buf[256];
   //char debug_buf[256];