Language-Eforth
view release on metacpan or search on metacpan
lib/Language/Eforth.pm view on Meta::CPAN
This module embeds a tiny embeddable Forth interpreter.
L<https://github.com/howerj/embed>
The interpreter has a 16-bit cell size, does not support floating point
values, AND CONTRARY TO THE ans fORTH SPECIFICATION REQUIRES LOWER-CASE
WORDS. Consult C<embed.fth> for details on various "Error Codes" and
other documentation.
Memory usage while not zero should not be very significant; it mostly
depends on the C<EMBED_CORE_SIZE> count of 16-bit cells allocated. And
whatever Perl needs. Assertion failures are also possible, unless the
compile was somehow done with C<-DNDEBUG>.
=head1 METHODS
These may C<croak> should something be awry with the input, or if memory
allocation fails in the constructor.
=over 4
lib/Language/Eforth.xs view on Meta::CPAN
embed_eval(self, (char *)SvPV_nolen(expr));
Language::Eforth
new( const char *class )
PREINIT:
embed_t *self;
embed_opt_t opts;
CODE:
Newxz(self, 1, embed_t);
if (!self) croak("could not allocate forth");
self->m = calloc(EMBED_CORE_SIZE * sizeof(cell_t), 1);
if (!(self->m)) croak("could not allocate memory");
embed_default(self);
opts = embed_opt_default();
opts.out = stdout;
opts.put = put_char;
opts.options = 0;
self->o = opts;
/* KLUGE prime the engine so push works from the get-go */
embed_eval(self, "\n");
RETVAL = self;
dXSBOOTARGSAPIVERCHK|5.021006||Viu
dXSBOOTARGSNOVERCHK|5.021006||Viu
dXSBOOTARGSXSAPIVERCHK|5.021006||Viu
dXSFUNCTION|5.005000||Viu
dXSI32|5.003007|5.003007|V
dXSTARG|5.006000|5.003007|poVnu
dXSUB_SYS|5.003007||Viu
edit_distance|5.023008||Vniu
EIGHT_BIT_UTF8_TO_NATIVE|5.023003||Viu
ELEMENT_RANGE_MATCHES_INVLIST|5.023002||Viu
EMBEDMYMALLOC|5.006000||Viu
emulate_cop_io|||xciu
emulate_setlocale|5.027009||Vniu
END|5.003007||Viu
END_EXTERN_C|5.005000|5.003007|pV
endgrent|5.009000||Viu
ENDGRENT_R_HAS_FPTR|5.008000||Viu
ENDGRENT_R_PROTO|5.008000|5.008000|Vn
endhostent|5.005000||Viu
ENDHOSTENT_R_PROTO|5.008000|5.008000|Vn
ENDLIKE|5.009005||Viu
( run in 1.772 second using v1.01-cache-2.11-cpan-71847e10f99 )