diff --git a/ChangeLog b/ChangeLog index 959c375..0580143 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Mon Sep 15 01:19:36 2008 Minero Aoki + + * cbc -> bin/cbc + + * cbci -> bin/cbci.rb + + * bin/cbci.sh: new file. + + * lib/libcbc.cb: new file. + + * build.properties: create jar file in lib/. + + * install.sh: new file. + Mon Sep 15 00:43:29 2008 Minero Aoki * net/loveruby/cflat/compiler/Compiler.java: handle multiple diff --git a/ToDo b/ToDo index 1081bf9..cbb7a76 100644 --- a/ToDo +++ b/ToDo @@ -2,6 +2,7 @@ == Current +* write install.sh * va_list * -O (peephole optimization) * movl $0, %eax => xorl %eax, %eax diff --git a/cbc b/bin/cbc similarity index 100% rename from cbc rename to bin/cbc diff --git a/cbci b/bin/cbci.rb similarity index 100% rename from cbci rename to bin/cbci.rb diff --git a/bin/cbci.sh b/bin/cbci.sh new file mode 100755 index 0000000..46c6c61 --- /dev/null +++ b/bin/cbci.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +TMPDIR=/tmp +TMPNAME="cflatexpr$$" + +main() { + local basedir="$(expand_path "$(dirname "$0")")" + + cd "$TMPDIR" + trap "rm -f $TMPNAME*" EXIT + cat < "$TMPNAME.cb" +import stdio; + +int +main(int argc, char** argv) +{ + printf("%d\n", $1); + return 0; +} +EndSource + "$basedir/cbc" "$TMPNAME.cb" || exit 1 + "./$TMPNAME" + st=$? + echo "status: $st" 1>&2 + exit 0 +} + +expand_path() { + local path="$1" + + if [ $(expr "$path" : "/") -eq 1 ] + then + echo "$path" + else + echo "$(pwd)/$path" + fi +} + +main "$@" diff --git a/build.properties b/build.properties index 8c62eae..56ab4f9 100644 --- a/build.properties +++ b/build.properties @@ -3,7 +3,7 @@ javacc.dir=/usr/share/java src.dir=. build.dir=build build.classes.dir=build/classes -build.jar=cbc.jar +build.jar=lib/cbc.jar src.jj.file=./net/loveruby/cflat/parser/Parser.jj build.parser.dir=./net/loveruby/cflat/parser diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..f36f9d0 --- /dev/null +++ b/install.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +version=1.0.0 +prefix="${1:-/usr/local/cbc/$version}" + +invoke() { + echo "$@" + if ! "$@" + then + echo "install failed." 1>&2 + exit 1 + fi +} + +echo "version=$version" +echo "prefix=$prefix" +invoke mkdir -p "$prefix/bin" +invoke cp bin/cbc bin/cbci "$prefix/bin +invoke mkdir -p "$prefix/lib" +invoke cp cbc.jar lib/libcbc.o "$prefix/lib" +echo "cbc successfully installed as $prefix/bin/cbc" diff --git a/lib/libcbc.cb b/lib/libcbc.cb new file mode 100644 index 0000000..5ee3eb8 --- /dev/null +++ b/lib/libcbc.cb @@ -0,0 +1,18 @@ +//import stdarg; // FIXME + +typedef unsigned long va_arg_t; +typedef va_arg_t* va_list; + +va_list +va_init(void *arg) +{ + return (va_list)arg + 1; +} + +va_arg_t +va_next(va_list* ap) +{ + va_arg_t arg = **ap; + (*ap)++; + return arg; +}