implemented more prechecks including the existence of the primitive function handler and the number of supported arguments when compiling primitive method defintions

This commit is contained in:
hyunghwan.chung
2017-03-31 14:21:22 +00:00
parent 0f84a115ae
commit 447670aba8
14 changed files with 172 additions and 80 deletions

View File

@ -1,7 +1,7 @@
class _FFI(Object) from 'ffi'
{
method(#primitive) open(name).
method(#primitive) close().
method(#primitive) close.
method(#primitive) getsym(name).
(* TODO: make call variadic? method(#primitive,#variadic) call (func, sig). *)

View File

@ -114,8 +114,7 @@ class MyObject(Object)
method(#class) main_xx
{
|a k|
'BEGINNING OF main...........' dump.
a :=
if ([System logNl: 'xxxx'. 'abcd' == 'bcde'. false] value)
@ -270,6 +269,8 @@ class MyObject(Object)
{
|a i|
###self main_xx.
a := 100.
## PROBLEM: the following double loop will exhaust the stack
(*

View File

@ -99,6 +99,7 @@ class MyObject(Object)
'too large array expression'
'wrong primitive function number'
'wrong primitive function identifier'
'wrong primitive function argument definition'
'wrong module name'
'#include error'
'wrong namespace name'
@ -130,18 +131,15 @@ class MyObject(Object)
].
f puts: S'static moo_ooch_t* '.
f puts: name.
f puts: S'[] =\n{\n'.
f puts(S'static moo_ooch_t* ', name, S'[] =\n{\n').
0 to: c do: [:i |
((i rem: 8) = 0) ifTrue: [ f putc: C'\t' ].
f puts: prefix.
f puts: (i asString).
(i = c) ifFalse: [f puts: S',' ].
(((i + 1) rem: 8) = 0) ifTrue: [ f putc: C'\n' ] ifFalse: [ f putc: C' ' ].
((i rem: 8) = 0) ifTrue: [ f putc(C'\t') ].
f puts(prefix, (i asString)).
(i = c) ifFalse: [f puts(S',') ].
(((i + 1) rem: 8) = 0) ifTrue: [ f putc(C'\n') ] ifFalse: [ f putc(C' ') ].
].
(((c + 1) rem: 8) = 0) ifFalse: [ f putc: C'\n' ].
f puts: S'};\n'.
(((c + 1) rem: 8) = 0) ifFalse: [ f putc(C'\n') ].
f puts(S'};\n').
}
method(#class) printString: s prefix: prefix index: index on: f
@ -149,18 +147,13 @@ class MyObject(Object)
| c |
c := s size - 1.
f puts: 'static moo_ooch_t '.
f puts: prefix.
f puts: index asString.
f puts: '[] = {'.
f puts('static moo_ooch_t ', prefix, index asString, '[] = {').
0 to: c do: [:i |
f putc: $'.
f putc: (s at: i).
f putc: $'.
(i = c) ifFalse: [f putc: $, ].
f putc($', (s at: i), $').
(i = c) ifFalse: [f putc($,) ].
].
f puts: S',\'\\0\'};\n'.
f puts(S',\'\\0\'};\n').
}
}