blob: 53a83310fd50d37ffa61b17d2ba55ac0f6fda8bd [file] [log] [blame]
# Translating Prolog into WAM-based Intermediate Code
def pl2am(name, src, out):
from os.path import basename, dirname
genrule(
name = name,
out = out,
cmd = 'echo "go :- '
+ 'load_files(['
+ "'$SRCDIR/src/compiler/package_fx.pl',"
+ "'$SRCDIR/src/builtin/system.pl',"
+ "'$SRCDIR/src/compiler/pl2am.pl'"
+ ']),'
+ 'pl2am(['
+ "'%s'," % basename(src)
+ "'$OUT',"
+ '[ed,ac,ie,rc,idx]'
+ ']).'
+ '">$TMP/go.pl;'
+ 'cd $SRCDIR/%s;' % dirname(src)
+ 'swipl --quiet -g go,halt -t "halt(1)" $TMP/go.pl',
srcs = [
'src/compiler/package_fx.pl',
'src/compiler/pl2am.pl',
'src/builtin/system.pl',
src,
],
)
# Translating WAM-based Intermediate Code into Java
def am2j(name, am, out):
genrule(
name = name,
out = out,
cmd = 'echo "go :- '
+ 'load_files(['
+ "'$SRCDIR/src/compiler/am2j.pl'"
+ ']),'
+ 'am2j(['
+ "'$(location %s)'," % am
+ "'$TMP/java'"
+ ']).'
+ '">$TMP/go.pl;'
+ 'mkdir $TMP/java;'
+ 'swipl --quiet -g go,halt -t "halt(1)" $TMP/go.pl;'
+ 'cd $TMP/java; zip -qr $OUT .',
srcs = ['src/compiler/am2j.pl'],
)
def pl2j(name, src, out):
pl2am(
name = name + '.am',
src = src,
out = name + '.am',
)
am2j(
name = name,
am = ':' + name + '.am',
out = out,
)