2017-01-09 12:52:37 +00:00
|
|
|
#include 'Moo.moo'.
|
2016-12-27 18:15:35 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
class MyObject(Object)
|
2016-12-27 18:15:35 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) main
|
2016-12-27 18:15:35 +00:00
|
|
|
{
|
2016-12-28 19:12:14 +00:00
|
|
|
| errmsgs synerrmsgs f |
|
2016-12-27 18:15:35 +00:00
|
|
|
|
2016-12-28 19:12:14 +00:00
|
|
|
errmsgs := #(
|
2016-12-27 18:15:35 +00:00
|
|
|
'no error'
|
|
|
|
'generic error'
|
|
|
|
|
|
|
|
'not implemented'
|
|
|
|
'subsystem error'
|
|
|
|
'internal error that should never have happened'
|
|
|
|
'insufficient system memory'
|
|
|
|
'insufficient object memory'
|
2017-10-18 16:15:51 +00:00
|
|
|
'invalid class/type'
|
2016-12-27 18:15:35 +00:00
|
|
|
|
|
|
|
'invalid parameter or argument'
|
|
|
|
'data not found'
|
|
|
|
'existing/duplicate data'
|
|
|
|
'busy'
|
|
|
|
'access denied'
|
|
|
|
'operation not permitted'
|
|
|
|
'not a directory'
|
|
|
|
'interrupted'
|
|
|
|
'pipe error'
|
|
|
|
'resource temporarily unavailable'
|
2017-10-30 01:11:18 +00:00
|
|
|
'bad system handle'
|
2016-12-27 18:15:35 +00:00
|
|
|
|
2017-12-28 04:58:17 +00:00
|
|
|
'*** undefined error ***'
|
2017-04-03 13:24:18 +00:00
|
|
|
'message receiver error'
|
2016-12-27 18:15:35 +00:00
|
|
|
'message sending error'
|
2017-05-08 16:00:55 +00:00
|
|
|
'wrong number of arguments'
|
2016-12-27 18:15:35 +00:00
|
|
|
'range error'
|
|
|
|
'byte-code full'
|
|
|
|
'dictionary full'
|
|
|
|
'processor full'
|
2017-12-28 04:58:17 +00:00
|
|
|
'too many semaphores'
|
|
|
|
'*** undefined error ***'
|
2016-12-27 18:15:35 +00:00
|
|
|
'divide by zero'
|
|
|
|
'I/O error'
|
|
|
|
'encoding conversion error'
|
2018-06-17 17:41:04 +00:00
|
|
|
'insufficient data for encoding conversion'
|
2017-01-12 10:06:43 +00:00
|
|
|
'buffer full'
|
2016-12-27 18:15:35 +00:00
|
|
|
).
|
2016-12-28 19:12:14 +00:00
|
|
|
|
|
|
|
synerrmsgs := #(
|
|
|
|
'no error'
|
|
|
|
'illegal character'
|
|
|
|
'comment not closed'
|
|
|
|
'string not closed'
|
|
|
|
'no character after $'
|
|
|
|
'no valid character after #'
|
2018-05-13 18:55:22 +00:00
|
|
|
'no valid character after #\'
|
2016-12-28 19:12:14 +00:00
|
|
|
'wrong character literal'
|
|
|
|
'colon expected'
|
|
|
|
'string expected'
|
|
|
|
'invalid radix'
|
|
|
|
'invalid numeric literal'
|
|
|
|
'byte too small or too large'
|
|
|
|
'wrong error literal'
|
2018-05-13 18:55:22 +00:00
|
|
|
'wrong smptr literal'
|
2016-12-28 19:12:14 +00:00
|
|
|
'{ expected'
|
|
|
|
'} expected'
|
|
|
|
'( expected'
|
|
|
|
') expected'
|
|
|
|
'] expected'
|
|
|
|
'. expected'
|
2017-04-19 16:46:44 +00:00
|
|
|
', expected'
|
2016-12-28 19:12:14 +00:00
|
|
|
'| expected'
|
|
|
|
'> expected'
|
|
|
|
':= expected'
|
|
|
|
'identifier expected'
|
|
|
|
'integer expected'
|
|
|
|
'primitive: expected'
|
|
|
|
'wrong directive'
|
|
|
|
'undefined class'
|
|
|
|
'duplicate class'
|
|
|
|
'contradictory class definition'
|
2017-01-06 09:53:40 +00:00
|
|
|
'wrong class name'
|
2018-01-07 08:00:23 +00:00
|
|
|
'invalid non-pointer instance size'
|
|
|
|
'prohibited inheritance'
|
2017-04-19 16:46:44 +00:00
|
|
|
'variable declaration not allowed'
|
2017-02-20 04:45:23 +00:00
|
|
|
'modifier expected'
|
|
|
|
'wrong modifier'
|
|
|
|
'disallowed modifier'
|
|
|
|
'duplicate modifier'
|
2017-04-19 16:46:44 +00:00
|
|
|
'method name expected'
|
2016-12-28 19:12:14 +00:00
|
|
|
'duplicate method name'
|
2017-03-23 16:14:22 +00:00
|
|
|
'invalid variadic method definition'
|
2017-04-19 16:46:44 +00:00
|
|
|
'variable name expected'
|
2016-12-28 19:12:14 +00:00
|
|
|
'duplicate argument name'
|
|
|
|
'duplicate temporary variable name'
|
|
|
|
'duplicate variable name'
|
|
|
|
'duplicate block argument name'
|
|
|
|
'undeclared variable'
|
|
|
|
'unusable variable in compiled code'
|
|
|
|
'inaccessible variable'
|
|
|
|
'ambiguous variable'
|
2018-01-07 14:59:54 +00:00
|
|
|
'too many instance/class variables'
|
2017-05-20 02:27:48 +00:00
|
|
|
'inaccessible self'
|
2016-12-28 19:12:14 +00:00
|
|
|
'wrong expression primary'
|
|
|
|
'too many temporaries'
|
|
|
|
'too many arguments'
|
|
|
|
'too many block temporaries'
|
|
|
|
'too many block arguments'
|
|
|
|
'too large block'
|
2017-02-05 13:54:52 +00:00
|
|
|
'too large array expression'
|
2016-12-28 19:12:14 +00:00
|
|
|
'wrong primitive function number'
|
|
|
|
'wrong primitive function identifier'
|
2017-03-31 14:21:22 +00:00
|
|
|
'wrong primitive function argument definition'
|
2016-12-28 19:12:14 +00:00
|
|
|
'wrong module name'
|
2017-06-08 14:39:17 +00:00
|
|
|
'failed to import module'
|
2016-12-28 19:12:14 +00:00
|
|
|
'#include error'
|
2017-11-24 17:40:20 +00:00
|
|
|
'wrong pragma name'
|
2016-12-28 19:12:14 +00:00
|
|
|
'wrong namespace name'
|
|
|
|
'wrong pool dictionary name'
|
|
|
|
'duplicate pool dictionary name'
|
|
|
|
'literal expected'
|
2017-01-29 07:14:36 +00:00
|
|
|
'break or continue not within a loop'
|
|
|
|
'break or continue within a block'
|
2017-01-30 16:48:42 +00:00
|
|
|
'while expected'
|
2016-12-28 19:12:14 +00:00
|
|
|
).
|
2016-12-27 18:15:35 +00:00
|
|
|
|
|
|
|
f := Stdio open: 'generr.out' for: 'w'.
|
|
|
|
[ f isError ] ifTrue: [ System logNl: 'Cannot open generr.out'. thisProcess terminate. ].
|
|
|
|
|
2016-12-28 19:12:14 +00:00
|
|
|
self emitMessages: errmsgs named: 'errstr' on: f.
|
|
|
|
self emitMessages: synerrmsgs named: 'synerrstr' on: f.
|
|
|
|
|
|
|
|
f close.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) emitMessages: errmsgs named: name on: f
|
2016-12-28 19:12:14 +00:00
|
|
|
{
|
|
|
|
| c prefix |
|
|
|
|
prefix := name & '_'.
|
|
|
|
|
|
|
|
c := errmsgs size - 1.
|
2016-12-27 18:15:35 +00:00
|
|
|
0 to: c do: [:i |
|
2016-12-28 19:12:14 +00:00
|
|
|
self printString: (errmsgs at: i) prefix: prefix index: i on: f.
|
2016-12-27 18:15:35 +00:00
|
|
|
].
|
|
|
|
|
2016-12-28 19:12:14 +00:00
|
|
|
|
2017-03-31 14:21:22 +00:00
|
|
|
f puts(S'static moo_ooch_t* ', name, S'[] =\n{\n').
|
2016-12-27 18:15:35 +00:00
|
|
|
0 to: c do: [:i |
|
2017-03-31 14:21:22 +00:00
|
|
|
((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' ') ].
|
2016-12-27 18:15:35 +00:00
|
|
|
].
|
2017-03-31 14:21:22 +00:00
|
|
|
(((c + 1) rem: 8) = 0) ifFalse: [ f putc(C'\n') ].
|
|
|
|
f puts(S'};\n').
|
2016-12-27 18:15:35 +00:00
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) printString: s prefix: prefix index: index on: f
|
2016-12-27 18:15:35 +00:00
|
|
|
{
|
2018-05-13 18:55:22 +00:00
|
|
|
| c |
|
2016-12-27 18:15:35 +00:00
|
|
|
c := s size - 1.
|
|
|
|
|
2017-03-31 14:21:22 +00:00
|
|
|
f puts('static moo_ooch_t ', prefix, index asString, '[] = {').
|
2016-12-27 18:15:35 +00:00
|
|
|
|
|
|
|
0 to: c do: [:i |
|
2018-05-13 18:55:22 +00:00
|
|
|
| ch |
|
|
|
|
ch := s at: i.
|
2018-05-30 15:32:09 +00:00
|
|
|
if ((ch == $\) or (ch == $"))
|
2018-05-13 18:55:22 +00:00
|
|
|
{
|
|
|
|
f putc($', $\, (s at: i), $').
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
f putc($', (s at: i), $').
|
|
|
|
}.
|
2017-03-31 14:21:22 +00:00
|
|
|
(i = c) ifFalse: [f putc($,) ].
|
2016-12-27 18:15:35 +00:00
|
|
|
].
|
|
|
|
|
2017-03-31 14:21:22 +00:00
|
|
|
f puts(S',\'\\0\'};\n').
|
2016-12-27 18:15:35 +00:00
|
|
|
}
|
|
|
|
}
|