What it has to do.
Input files:
i1) classnames file: names of all classes known to VM, one per line; ends
with ~
i2) number of input files containing interface functions (pseudo)code
Output files:
o1) number of files containing valid C++ function created from input (i2)
(check detailed example later on)
o2) include file for Xlang parser, valid XLang function definitions for all
interface funs
o3) file with C++ table with all function entries, laid in struct
struct
{
const char * mangled_name;
const char * base_name;
const char * signature;
interface_function_pointer * ptr;
long allowance;
};
Example of parsing (comments are not parsed)
INTERFACE BUILDER | WIZARD // pseudo code, newline terminated
int add_numbers( int a, int b ) // fake prototype
{
vm->push_int(a+b); // here is a 'return' for vm
return; // here is C++ return;
}
have to be converted to
.cpp file with
void add_numbers_P_i_i( VMachine * vm )
{
vmstack * args = vm->initp(2);
int a = args[0].val.i;
int b = args[1].val.i;
vm->push_int(a+b);
return;
}
entry in .mh file
int add_numbers(int a, int b);
and entry in table
{ "add_numbers_P_i_i", "add_numbers", "i_i", add_numbers_P_i_i, BUILDER | WIZARD }
----
It has to recognize basic types int, float and string and convert them in
proper way.
int x -> int x = args[n].val.i;
float x -> float x = args[n].val.f;
string x -> String * x = args[n].val.s;
ObjName x -> ObjName * x = args[n].val.o;
Secondary possibilities:
- adding of #line directives to allow quick finding of offending function
in (i2) files not (o1)
- would be nice to allow ommision of not-needed paramters - just like in C
fun( PC, string x, int y) - we do not need PC pointer, so it is not generated.
- there will be also problem with arrays - but this will appear later