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 := #(
|
2019-10-26 02:04:36 +00:00
|
|
|
"no error"
|
|
|
|
"generic error"
|
2016-12-27 18:15:35 +00:00
|
|
|
|
2019-10-26 02:04:36 +00:00
|
|
|
"not implemented"
|
|
|
|
"subsystem error"
|
|
|
|
"internal error that should never have happened"
|
|
|
|
"insufficient system memory"
|
|
|
|
"insufficient object memory"
|
|
|
|
"invalid class/type"
|
2016-12-27 18:15:35 +00:00
|
|
|
|
2019-10-26 02:04:36 +00:00
|
|
|
"invalid parameter or argument"
|
|
|
|
"data not found"
|
|
|
|
"existing/duplicate data"
|
|
|
|
"busy"
|
|
|
|
"access denied"
|
|
|
|
"operation not permitted"
|
|
|
|
"not directory"
|
|
|
|
"interrupted"
|
|
|
|
"pipe error"
|
|
|
|
"resource temporarily unavailable"
|
|
|
|
"bad system handle"
|
2016-12-27 18:15:35 +00:00
|
|
|
|
2019-10-26 02:04:36 +00:00
|
|
|
"*** undefined error ***"
|
|
|
|
"message receiver error"
|
|
|
|
"message sending error"
|
|
|
|
"wrong number of arguments"
|
|
|
|
"range error"
|
|
|
|
"byte-code full"
|
|
|
|
"dictionary full"
|
|
|
|
"processor full"
|
|
|
|
"too many semaphores"
|
|
|
|
"*** undefined error ***"
|
|
|
|
"divide by zero"
|
|
|
|
"I/O error"
|
|
|
|
"encoding conversion error"
|
|
|
|
"insufficient data for encoding conversion"
|
|
|
|
"buffer full"
|
2016-12-27 18:15:35 +00:00
|
|
|
).
|
2018-10-09 15:21:58 +00:00
|
|
|
|
2016-12-28 19:12:14 +00:00
|
|
|
synerrmsgs := #(
|
2019-10-26 02:04:36 +00:00
|
|
|
"no error"
|
|
|
|
"illegal character"
|
|
|
|
"comment not closed"
|
|
|
|
"string not closed"
|
|
|
|
"no character after $"
|
|
|
|
"no valid character after #"
|
|
|
|
"no valid character after #\\"
|
|
|
|
"wrong character literal"
|
|
|
|
"colon expected"
|
|
|
|
"string expected"
|
|
|
|
"invalid radix"
|
|
|
|
"invalid integer literal"
|
|
|
|
"invalid fixed-point decimal scale"
|
|
|
|
"invalid fixed-point decimal literal"
|
|
|
|
"byte too small or too large"
|
|
|
|
"wrong error literal"
|
|
|
|
"wrong smptr literal"
|
|
|
|
"{ expected"
|
|
|
|
"} expected"
|
|
|
|
"( expected"
|
|
|
|
") expected"
|
|
|
|
"] expected"
|
|
|
|
". expected"
|
|
|
|
", expected"
|
|
|
|
"| expected"
|
|
|
|
"> expected"
|
|
|
|
":= expected"
|
|
|
|
"identifier expected"
|
|
|
|
"integer expected"
|
|
|
|
"primitive: expected"
|
|
|
|
"wrong directive"
|
|
|
|
"wrong name"
|
|
|
|
"duplicate name"
|
|
|
|
"undefined name"
|
|
|
|
"contradictory class definition"
|
|
|
|
"class not conforming to interface"
|
|
|
|
"invalid non-pointer instance size"
|
|
|
|
"prohibited inheritance"
|
|
|
|
"variable declaration not allowed"
|
|
|
|
"modifier expected"
|
|
|
|
"wrong modifier"
|
|
|
|
"disallowed modifier"
|
|
|
|
"duplicate modifier"
|
|
|
|
"method name expected"
|
|
|
|
"duplicate method name"
|
|
|
|
"invalid variadic method definition"
|
|
|
|
"variable name expected"
|
|
|
|
"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"
|
|
|
|
"too many instance/class variables"
|
|
|
|
"inaccessible super"
|
|
|
|
"wrong expression primary"
|
|
|
|
"too many temporaries"
|
|
|
|
"too many arguments"
|
|
|
|
"too many block temporaries"
|
|
|
|
"too many block arguments"
|
|
|
|
"array expression too large"
|
|
|
|
"instruction data too large"
|
|
|
|
"wrong primitive function number"
|
|
|
|
"wrong primitive function identifier"
|
|
|
|
"wrong primitive function argument definition"
|
|
|
|
"wrong primitive value identifier"
|
|
|
|
"primitive value load from module not allowed"
|
|
|
|
"failed to import module"
|
|
|
|
"#include error"
|
|
|
|
"wrong pragma name"
|
|
|
|
"wrong namespace name"
|
|
|
|
"wrong pooldic import name"
|
|
|
|
"duplicate pooldic import name"
|
|
|
|
"literal expected"
|
|
|
|
"break or continue not within a loop"
|
|
|
|
"break or continue within a block"
|
|
|
|
"while expected"
|
|
|
|
"invalid goto target"
|
|
|
|
"label at end"
|
2016-12-28 19:12:14 +00:00
|
|
|
).
|
2016-12-27 18:15:35 +00:00
|
|
|
|
2019-10-26 02:04:36 +00:00
|
|
|
f := Stdio open: "generr.out" for: "w".
|
|
|
|
[ f isError ] ifTrue: [ System logNl: "Cannot open generr.out". thisProcess terminate. ].
|
2016-12-27 18:15:35 +00:00
|
|
|
|
2019-10-26 02:04:36 +00:00
|
|
|
self emitMessages: errmsgs named: "errstr" on: f.
|
|
|
|
self emitMessages: synerrmsgs named: "synerrstr" on: f.
|
2016-12-28 19:12:14 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
f puts("static moo_ooch_t* ", name, "[] =\n{\n").
|
2016-12-27 18:15:35 +00:00
|
|
|
0 to: c do: [:i |
|
2019-06-27 08:06:33 +00:00
|
|
|
((i rem: 8) = 0) ifTrue: [ f putc(C"\t") ].
|
2017-03-31 14:21:22 +00:00
|
|
|
f puts(prefix, (i asString)).
|
2019-06-27 08:06:33 +00:00
|
|
|
(i = c) ifFalse: [f puts(",") ].
|
|
|
|
(((i + 1) rem: 8) = 0) ifTrue: [ f putc(C"\n") ] ifFalse: [ f putc(C' ') ].
|
2016-12-27 18:15:35 +00:00
|
|
|
].
|
2019-06-27 08:06:33 +00:00
|
|
|
(((c + 1) rem: 8) = 0) ifFalse: [ f putc(C"\n") ].
|
|
|
|
f puts("};\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.
|
|
|
|
|
2019-06-27 08:06:33 +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
|
|
|
].
|
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
f puts(",\'\\0\'};\n").
|
2016-12-27 18:15:35 +00:00
|
|
|
}
|
|
|
|
}
|