Mercurial > repos > tabletprog
annotate runtime/proghead.inc @ 331:61f5b794d939
Breaking change: method call syntax now always uses the syntactic receiver as the actual receiver. This makes its behavior different from function call syntax, but solves some problems with methods being shadowed by local variables and the like.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 28 Mar 2015 14:21:04 -0700 |
parents | 632667d95d35 |
children |
rev | line source |
---|---|
31
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include "object.h" |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include <stddef.h> |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #include <stdlib.h> |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 #include <stdio.h> |
78
abc6f3d644a4
Use Boehm-GC for garbage collection. Also make no_impl print on stderr rather than standard in and return a non-zero error code.
Mike Pavone <pavone@retrodev.com>
parents:
45
diff
changeset
|
5 #include <gc/gc.h> |
31
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 |
34
a10f1b049193
Working closures, but need to rethink method call strategy
Mike Pavone <pavone@retrodev.com>
parents:
31
diff
changeset
|
7 object * main_module; |
a10f1b049193
Working closures, but need to rethink method call strategy
Mike Pavone <pavone@retrodev.com>
parents:
31
diff
changeset
|
8 |
182
ab7c142090a0
Make method names available at runtime so they can be included in method not implemented error messages
Mike Pavone <pavone@retrodev.com>
parents:
78
diff
changeset
|
9 char * methodNames[]; |
ab7c142090a0
Make method names available at runtime so they can be included in method not implemented error messages
Mike Pavone <pavone@retrodev.com>
parents:
78
diff
changeset
|
10 |
35
bf5e88f6419d
Use a function/method call strategy that actually works
Mike Pavone <pavone@retrodev.com>
parents:
34
diff
changeset
|
11 object * no_impl(uint32_t method_id, uint32_t num_args, object * self, va_list args) |
31
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 { |
269
632667d95d35
Improve message not implemented error message
Michael Pavone <pavone@retrodev.com>
parents:
182
diff
changeset
|
13 uint32_t *cur; |
632667d95d35
Improve message not implemented error message
Michael Pavone <pavone@retrodev.com>
parents:
182
diff
changeset
|
14 int slot; |
182
ab7c142090a0
Make method names available at runtime so they can be included in method not implemented error messages
Mike Pavone <pavone@retrodev.com>
parents:
78
diff
changeset
|
15 fprintf(stderr, "method %s(%d) is not implemented on object %p\n", methodNames[method_id], method_id, self); |
269
632667d95d35
Improve message not implemented error message
Michael Pavone <pavone@retrodev.com>
parents:
182
diff
changeset
|
16 fputs("Object implements:\n", stderr); |
632667d95d35
Improve message not implemented error message
Michael Pavone <pavone@retrodev.com>
parents:
182
diff
changeset
|
17 for (slot = 0; slot < 16; slot++) { |
632667d95d35
Improve message not implemented error message
Michael Pavone <pavone@retrodev.com>
parents:
182
diff
changeset
|
18 if (self->meta->methods[slot]) { |
632667d95d35
Improve message not implemented error message
Michael Pavone <pavone@retrodev.com>
parents:
182
diff
changeset
|
19 for (cur = self->meta->methods[slot]; *cur != LAST_METHOD; cur++) { |
632667d95d35
Improve message not implemented error message
Michael Pavone <pavone@retrodev.com>
parents:
182
diff
changeset
|
20 fprintf(stderr, "\t%s\n", methodNames[*cur]); |
632667d95d35
Improve message not implemented error message
Michael Pavone <pavone@retrodev.com>
parents:
182
diff
changeset
|
21 } |
632667d95d35
Improve message not implemented error message
Michael Pavone <pavone@retrodev.com>
parents:
182
diff
changeset
|
22 } |
632667d95d35
Improve message not implemented error message
Michael Pavone <pavone@retrodev.com>
parents:
182
diff
changeset
|
23 } |
78
abc6f3d644a4
Use Boehm-GC for garbage collection. Also make no_impl print on stderr rather than standard in and return a non-zero error code.
Mike Pavone <pavone@retrodev.com>
parents:
45
diff
changeset
|
24 exit(1); |
31
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 return NULL; |
668f533e5284
Add initial version of C backend
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 } |
78
abc6f3d644a4
Use Boehm-GC for garbage collection. Also make no_impl print on stderr rather than standard in and return a non-zero error code.
Mike Pavone <pavone@retrodev.com>
parents:
45
diff
changeset
|
27 |