Dear David,
So far I've been able to generate Poly/ML style codetree for a subset
of Spad language used in OpenAxiom. The codetree is written into a
text file. As an example, for the following spad function:
foo (a : Integer) : Integer ==
a := a + 1
a
I currently generate the following intermediate code:
DECL #1{0 uses} =
LAMBDA(
foo(2)
CL=false CR=0 LEV=0 LOCALS=0
ARGS=G
ARGLIVES=
RES=G CLOS=()
BLOCK(BLOCK(DECL #2{0 uses} = RECCONSTR(PARAM(0,1), PARAM(0,2));
BLOCK(DECL #3{0 uses} =
GLOBAL (FUN "run_call2(1)",
LAMBDAINLINE(
runcall2(1)
CL=false CR=0 LEV=0 LOCALS=0
ARGS=G
ARGLIVES=
RES=G CLOS=()
LOCAL(1,1) G
$(INDIRECT(0, PARAM(0,1)) G, INDIRECT(1, PARAM(0,1)) G)){LAMBDA}
) (*GLOBAL*){early} G $(INDIRECT(0, LOCAL(0, 2)), LIT1 G);
DECL #4{0 uses} = LOCAL(0, 3);
LOCAL(0, 4)
)
)
)){LAMBDA}"
I also wrote a ML library which reads in and parses the codetree
string. Does my current approach look sensible to you? What would you
suggest if improvements are needed?
I'm thinking that the next step for me is to call Poly/ML middle
functions that would take the codetree and evaluate the entire
codetree for a Spad function (and then hopefully a Spad domain.) I've
read the code and the documentation in the codetree source code files.
Is there any way for me to call the codetree functions as a library in
my ML code?
Thanks,
Yue