mntmn hace 9 años
padre
commit
fd4e772f2f
Se han modificado 3 ficheros con 11 adiciones y 1 borrados
  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
 build/*.elf
 newlib
+.#*

+ 2 - 1
sledge/compiler_new.c

@@ -359,6 +359,7 @@ int compile_expr(Cell* expr, Frame* frame, int return_type) {
         if (argi>0) {
           // save registers
           // FIXME RETHINK
+
           jit_push(ARGR0,ARGR0+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].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;
           //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
 
 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;
   Cell* read_fn = s->fs->read_fn;
   //char debug_buf[256];
@@ -128,6 +132,10 @@ Cell* stream_read(Cell* stream) {
 }
 
 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;
   Cell* write_fn = s->fs->write_fn;
   //char debug_buf[256];