aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Makefile.in19
-rw-r--r--aclocal.m4122
-rw-r--r--config/open-axiom.m421
-rw-r--r--config/openaxiom-c-macros.h.in3
-rwxr-xr-xconfigure178
-rw-r--r--configure.ac1
-rw-r--r--src/ChangeLog4
-rw-r--r--src/Makefile.in4
-rw-r--r--src/algebra/Makefile.in4
-rw-r--r--src/boot/Makefile.in4
-rw-r--r--src/include/Lisp.H13
-rw-r--r--src/include/sexpr.H17
-rw-r--r--src/include/vm.H91
-rw-r--r--src/io/Makefile.in4
-rw-r--r--src/lisp/Makefile.in2
-rw-r--r--src/lisp/core.lisp.in5
-rw-r--r--src/rt/Makefile.in4
-rw-r--r--src/rt/vm.cc38
-rw-r--r--src/syntax/Makefile.in4
-rw-r--r--src/syntax/sexpr.cc58
21 files changed, 542 insertions, 59 deletions
diff --git a/ChangeLog b/ChangeLog
index 288ae518..ddfdbc27 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-16 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ * config/open-axiom.m4 (OPENAXIOM_CHECK_LLVM): New.
+ (OPENAXIOM_HOST_COMPILERS): Call it.
+
2014-08-26 Gabriel Dos Reis <gdr@integrable-solutions.net>
* config/open-axiom.m4 (OPENAXIOM_LINK_FILES): New.
diff --git a/Makefile.in b/Makefile.in
index 584a28dd..9c9c0003 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -170,7 +170,7 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
INSTALL NEWS README TODO config/compile config/config.guess \
config/config.sub config/depcomp config/install-sh \
config/missing config/mkinstalldirs config/ltmain.sh \
- $(top_srcdir)/config/config.guess \
+ $(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \
$(top_srcdir)/config/config.sub \
$(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \
$(top_srcdir)/config/missing
@@ -341,6 +341,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
+LLVM_CONFIG = @LLVM_CONFIG@
LNKEXT = @LNKEXT@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
@@ -461,6 +462,7 @@ oa_target_texdir = @oa_target_texdir@
oa_targetdir = @oa_targetdir@
oa_use_dynamic_lib = @oa_use_dynamic_lib@
oa_use_libtool_for_shared_lib = @oa_use_libtool_for_shared_lib@
+oa_use_llvm = @oa_use_llvm@
oa_use_x = @oa_use_x@
oldincludedir = @oldincludedir@
open_axiom_installdir = @open_axiom_installdir@
@@ -553,8 +555,8 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps):
config/openaxiom-c-macros.h: config/stamp-h1
- @if test ! -f $@; then rm -f config/stamp-h1; else :; fi
- @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) config/stamp-h1; else :; fi
+ @test -f $@ || rm -f config/stamp-h1
+ @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) config/stamp-h1
config/stamp-h1: $(top_srcdir)/config/openaxiom-c-macros.h.in $(top_builddir)/config.status
@rm -f config/stamp-h1
@@ -801,10 +803,16 @@ dist-xz: distdir
$(am__post_remove_distdir)
dist-tarZ: distdir
+ @echo WARNING: "Support for shar distribution archives is" \
+ "deprecated." >&2
+ @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
+ @echo WARNING: "Support for distribution archives compressed with" \
+ "legacy program 'compress' is deprecated." >&2
+ @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir)
@@ -846,9 +854,10 @@ distcheck: dist
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \
- && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+ && ../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
+ --srcdir=.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
diff --git a/aclocal.m4 b/aclocal.m4
index 73b1aefc..cdb19b8f 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.13.4 -*- Autoconf -*-
+# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
@@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.13'
+[am__api_version='1.14'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
-m4_if([$1], [1.13.4], [],
+m4_if([$1], [1.14.1], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@@ -51,7 +51,7 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.13.4])dnl
+[AM_AUTOMAKE_VERSION([1.14.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
@@ -418,6 +418,12 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
+dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
+m4_define([AC_PROG_CC],
+m4_defn([AC_PROG_CC])
+[_AM_PROG_CC_C_O
+])
+
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
@@ -526,7 +532,48 @@ dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
AC_CONFIG_COMMANDS_PRE(dnl
[m4_provide_if([_AM_COMPILER_EXEEXT],
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
-])
+
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes. So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+ cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present. This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake@gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message. This
+can help us improve future automake versions.
+
+END
+ if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+ echo 'Configuration will proceed anyway, since you have set the' >&2
+ echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+ echo >&2
+ else
+ cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+ AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
+ fi
+fi])
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
@@ -534,7 +581,6 @@ dnl mangled by Autoconf and run in a shell conditional statement.
m4_define([_AC_COMPILER_EXEEXT],
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
-
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
@@ -716,6 +762,70 @@ AC_DEFUN([_AM_SET_OPTIONS],
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_CC_C_O
+# ---------------
+# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC
+# to automatically call this.
+AC_DEFUN([_AM_PROG_CC_C_O],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+AC_LANG_PUSH([C])dnl
+AC_CACHE_CHECK(
+ [whether $CC understands -c and -o together],
+ [am_cv_prog_cc_c_o],
+ [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
+ # Make sure it works both with $CC and with simple cc.
+ # Following AC_PROG_CC_C_O, we do the test twice because some
+ # compilers refuse to overwrite an existing .o file with -o,
+ # though they will create one.
+ am_cv_prog_cc_c_o=yes
+ for am_i in 1 2; do
+ if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
+ && test -f conftest2.$ac_objext; then
+ : OK
+ else
+ am_cv_prog_cc_c_o=no
+ break
+ fi
+ done
+ rm -f core conftest*
+ unset am_i])
+if test "$am_cv_prog_cc_c_o" != yes; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+AC_LANG_POP([C])])
+
+# For backward compatibility.
+AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_RUN_LOG(COMMAND)
+# -------------------
+# Run COMMAND, save the exit status in ac_status, and log it.
+# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
+AC_DEFUN([AM_RUN_LOG],
+[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
+ ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ (exit $ac_status); }])
+
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
diff --git a/config/open-axiom.m4 b/config/open-axiom.m4
index d16ee27e..02dccbb9 100644
--- a/config/open-axiom.m4
+++ b/config/open-axiom.m4
@@ -254,6 +254,26 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_ERROR([OpenAxiom requires a C++11 compiler])])
])
+dnl --------------------------
+dnl -- OPENAXIOM_CHECK_LLVM --
+dnl --------------------------
+dnl Do we have recent enough LLVM?
+AC_DEFUN([OPENAXIOM_CHECK_LLVM],[
+oa_use_llvm=no
+AC_CHECK_PROGS([LLVM_CONFIG],[llvm-config])
+if test -n "$LLVM_CONFIG"; then
+ case `$LLVM_CONFIG --version` in
+ 3.[[5-9]].*)
+ oa_use_llvm=yes
+ ;;
+ *)
+ ;;
+ esac
+ AC_DEFINE_UNQUOTED([OPENAXIOM_HOST_HAS_LLVM],[],[Host has LLVM.])
+fi
+AC_SUBST(oa_use_llvm)
+])
+
dnl ------------------------------
dnl -- OPENAXIOM_HOST_COMPILERS --
dnl ------------------------------
@@ -284,6 +304,7 @@ OPENAXIOM_SATISFY_GCL_NEEDS
AC_PROG_CPP
AC_PROG_CXXCPP
OPENAXIOM_CPPFLAGS_FOR_VENDOR_LOCK_INS
+OPENAXIOM_CHECK_LLVM
])
dnl ---------------------------------
diff --git a/config/openaxiom-c-macros.h.in b/config/openaxiom-c-macros.h.in
index 26fb89f8..123648aa 100644
--- a/config/openaxiom-c-macros.h.in
+++ b/config/openaxiom-c-macros.h.in
@@ -152,6 +152,9 @@
/* Extension of executable file. */
#undef OPENAXIOM_EXEEXT
+/* Host has LLVM. */
+#undef OPENAXIOM_HOST_HAS_LLVM
+
/* The width of the host Lisp and CPU registers. */
#undef OPENAXIOM_HOST_LISP_PRECISION
diff --git a/configure b/configure
index facfa673..84bd5581 100755
--- a/configure
+++ b/configure
@@ -710,6 +710,10 @@ OA_DELAYED_FFI_FALSE
OA_DELAYED_FFI_TRUE
OA_BUILD_GCL_FALSE
OA_BUILD_GCL_TRUE
+OA_USE_LLVM_FALSE
+OA_USE_LLVM_TRUE
+oa_use_llvm
+LLVM_CONFIG
CXXCPP
CPP
oa_cflags
@@ -2958,7 +2962,7 @@ oa_c_macros='$(oa_configdir)/axiom-c-macros.h'
-am__api_version='1.13'
+am__api_version='1.14'
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
@@ -3495,6 +3499,47 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes. So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+ cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present. This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake@gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message. This
+can help us improve future automake versions.
+
+END
+ if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+ echo 'Configuration will proceed anyway, since you have set the' >&2
+ echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+ echo >&2
+ else
+ cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+ as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
+ fi
+fi
@@ -4699,6 +4744,65 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
+$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
+if ${am_cv_prog_cc_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ # Make sure it works both with $CC and with simple cc.
+ # Following AC_PROG_CC_C_O, we do the test twice because some
+ # compilers refuse to overwrite an existing .o file with -o,
+ # though they will create one.
+ am_cv_prog_cc_c_o=yes
+ for am_i in 1 2; do
+ if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
+ ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } \
+ && test -f conftest2.$ac_objext; then
+ : OK
+ else
+ am_cv_prog_cc_c_o=no
+ break
+ fi
+ done
+ rm -f core conftest*
+ unset am_i
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
+$as_echo "$am_cv_prog_cc_c_o" >&6; }
+if test "$am_cv_prog_cc_c_o" != yes; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
depcc="$CC" am_compiler_list=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
@@ -5526,6 +5630,74 @@ case $host in
esac
+oa_use_llvm=no
+for ac_prog in llvm-config
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_LLVM_CONFIG+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$LLVM_CONFIG"; then
+ ac_cv_prog_LLVM_CONFIG="$LLVM_CONFIG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_LLVM_CONFIG="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+LLVM_CONFIG=$ac_cv_prog_LLVM_CONFIG
+if test -n "$LLVM_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLVM_CONFIG" >&5
+$as_echo "$LLVM_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$LLVM_CONFIG" && break
+done
+
+if test -n "$LLVM_CONFIG"; then
+ case `$LLVM_CONFIG --version` in
+ 3.[5-9].*)
+ oa_use_llvm=yes
+ ;;
+ *)
+ ;;
+ esac
+
+cat >>confdefs.h <<_ACEOF
+#define OPENAXIOM_HOST_HAS_LLVM /**/
+_ACEOF
+
+fi
+
+
+
+ if test -n $oa_use_llvm; then
+ OA_USE_LLVM_TRUE=
+ OA_USE_LLVM_FALSE='#'
+else
+ OA_USE_LLVM_TRUE='#'
+ OA_USE_LLVM_FALSE=
+fi
+
oa_saved_cxxflags=$CXXFLAGS
@@ -19560,6 +19732,10 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${OA_USE_LLVM_TRUE}" && test -z "${OA_USE_LLVM_FALSE}"; then
+ as_fn_error $? "conditional \"OA_USE_LLVM\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${OA_BUILD_GCL_TRUE}" && test -z "${OA_BUILD_GCL_FALSE}"; then
as_fn_error $? "conditional \"OA_BUILD_GCL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/configure.ac b/configure.ac
index ffdec895..159bd9eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,6 +87,7 @@ oa_build_sharedir=$oa_builddir/share
AC_LANG([C++])
OPENAXIOM_HOST_COMPILERS
+AM_CONDITIONAL([OA_USE_LLVM], [test -n $oa_use_llvm])
OPENAXIOM_REQUIRE_CXX11
AM_CONDITIONAL([OA_BUILD_GCL], [test x$oa_include_gcl = xyes])
AM_CONDITIONAL([OA_ECL_RT], [test x$oa_lisp_flavor = xecl])
diff --git a/src/ChangeLog b/src/ChangeLog
index 0a1f925a..c78e2f3d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-15 Gabriel Dos Reis <gdr@axiomatics.org>
+
+ * llvm/: New directory.
+
2014-10-03 Gabriel Dos Reis <gdr@integrable-solutions.net>
* gui/server.cc (Server::input): Replace toAscii() with toLatin1()
diff --git a/src/Makefile.in b/src/Makefile.in
index 0c6143c5..d2c15738 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -253,6 +253,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
+LLVM_CONFIG = @LLVM_CONFIG@
LNKEXT = @LNKEXT@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
@@ -373,6 +374,7 @@ oa_target_texdir = @oa_target_texdir@
oa_targetdir = $(top_builddir)/$(target)
oa_use_dynamic_lib = @oa_use_dynamic_lib@
oa_use_libtool_for_shared_lib = @oa_use_libtool_for_shared_lib@
+oa_use_llvm = @oa_use_llvm@
oa_use_x = @oa_use_x@
oldincludedir = @oldincludedir@
open_axiom_installdir = @open_axiom_installdir@
diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in
index 5e4c5b0a..804b5ec3 100644
--- a/src/algebra/Makefile.in
+++ b/src/algebra/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -437,6 +437,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
+LLVM_CONFIG = @LLVM_CONFIG@
LNKEXT = @LNKEXT@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
@@ -557,6 +558,7 @@ oa_target_texdir = @oa_target_texdir@
oa_targetdir = @oa_targetdir@
oa_use_dynamic_lib = @oa_use_dynamic_lib@
oa_use_libtool_for_shared_lib = @oa_use_libtool_for_shared_lib@
+oa_use_llvm = @oa_use_llvm@
oa_use_x = @oa_use_x@
oldincludedir = @oldincludedir@
open_axiom_installdir = @open_axiom_installdir@
diff --git a/src/boot/Makefile.in b/src/boot/Makefile.in
index c5f9a06e..86bd3aa8 100644
--- a/src/boot/Makefile.in
+++ b/src/boot/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -282,6 +282,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
+LLVM_CONFIG = @LLVM_CONFIG@
LNKEXT = @LNKEXT@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
@@ -402,6 +403,7 @@ oa_target_texdir = @oa_target_texdir@
oa_targetdir = @oa_targetdir@
oa_use_dynamic_lib = @oa_use_dynamic_lib@
oa_use_libtool_for_shared_lib = @oa_use_libtool_for_shared_lib@
+oa_use_llvm = @oa_use_llvm@
oa_use_x = @oa_use_x@
oldincludedir = @oldincludedir@
open_axiom_installdir = @open_axiom_installdir@
diff --git a/src/include/Lisp.H b/src/include/Lisp.H
index 119d07f8..a189dd38 100644
--- a/src/include/Lisp.H
+++ b/src/include/Lisp.H
@@ -78,6 +78,16 @@ namespace OpenAxiom {
struct IntegerOverflow : Diagnostics::BasicError {
explicit IntegerOverflow(const std::string&);
};
+
+ // -- Unbound symbol
+ struct UnboundSymbol : Diagnostics::BasicError {
+ explicit UnboundSymbol(const std::string&);
+ };
+
+ // -- Unbound functiom symbol
+ struct UnboundFunctionSymbol : Diagnostics::BasicError {
+ explicit UnboundFunctionSymbol(const std::string&);
+ };
// -- Anchor maps
using AnchorTable = std::map<Ordinal, Value>;
@@ -85,14 +95,17 @@ namespace OpenAxiom {
// -- Evaluator --
struct Evaluator : VM::BasicContext {
Evaluator();
+ Value eval(const Sexpr::Syntax*);
Package* core_package() { return core; }
Package* current_package() { return ns; }
Value toplevel_form(const Sexpr::Syntax*);
Value make_value(const Sexpr::Syntax*);
+ Value* lexical_binding(String);
Environment* global_environment();
private:
Package* core;
Package* ns;
+ Symbol* feature_list;
std::list<Environment> env_stack;
AnchorTable anchor_map;
};
diff --git a/src/include/sexpr.H b/src/include/sexpr.H
index d3dafcb7..82dba2a3 100644
--- a/src/include/sexpr.H
+++ b/src/include/sexpr.H
@@ -146,6 +146,10 @@ namespace OpenAxiom {
};
SymbolSyntax(const Lexeme&, Kind);
Kind kind() const { return sort; }
+ const Byte* begin() const { return lexeme().begin(); }
+ const Byte* end() const { return lexeme().end(); }
+ std::size_t size() const { return lexeme().size(); }
+ Byte operator[](std::size_t i) const { return begin()[i]; }
void accept(Visitor&) const;
private:
const Kind sort;
@@ -386,19 +390,24 @@ namespace OpenAxiom {
};
// -- Reader --
+ struct RawInput {
+ const Byte* start;
+ const Byte* end;
+ Ordinal lineno;
+ };
+
struct Reader {
struct State {
- const Byte* start;
- const Byte* end;
+ RawInput bytes;
const Byte* cur;
const Byte* line;
- Ordinal lineno;
Allocator alloc;
};
+ explicit Reader(const RawInput&);
Reader(const Byte*, const Byte*);
const Byte* position(Ordinal);
- bool at_start() const { return st.cur == st.start; }
+ bool at_start() const { return st.cur == st.bytes.start; }
const Syntax* read();
private:
State st;
diff --git a/src/include/vm.H b/src/include/vm.H
index 9337955b..2c1eafde 100644
--- a/src/include/vm.H
+++ b/src/include/vm.H
@@ -163,14 +163,22 @@ namespace OpenAxiom {
t = 0x10, // distinguished T value
};
- constexpr bool to_bool(Value v) {
- return v != Value::nil;
+ // -- Testing for nil value.
+ constexpr Value null(Value v) {
+ return v == Value::nil ? Value::t : Value::nil;
}
+ // -- Convert VM Boolean value to C++ view
+ constexpr bool to_bool(Value v) { return v != Value::nil; }
+
+ // -- Convert a C++ Boolean value to VM view.
constexpr Value to_value(bool b) {
return b ? Value::t : Value::nil;
}
+ // -- Identity equality.
+ constexpr Value eq(Value x, Value y) { return to_value(x == y); }
+
template<typename>
struct ValueTrait {
};
@@ -194,12 +202,23 @@ namespace OpenAxiom {
return ValueBits(v) & ~ValueTrait<T>::tag_mask;
}
+ // -- Arity: number of arguments or forms taken by a function
+ // or a special operator.
+ enum class Arity : intptr_t {
+ variable = -1, // Any number of arguments.
+ zero = 0, // Exactly no argument.
+ one = 1, // Exactly one argument.
+ two = 2, // Exactly two arguments.
+ three = 3, // Exactly three arguments.
+ };
+
// -------------
// -- Dynamic --
// -------------
// Any internal value is of a class derived from this.
internal_type Dynamic {
virtual ~Dynamic();
+ virtual void format_on(std::ostream&) const = 0;
};
template<>
@@ -324,10 +343,19 @@ namespace OpenAxiom {
return Value(ValueBits(p) | ValueTrait<Pair>::tag);
}
+ // Return true if argument designates a pair.
+ constexpr Value consp(Value v) {
+ return to_value(v != Value::nil and v != Value::t and is<Pair>(v));
+ }
+
+ inline Value atom(Value v) {
+ return null(consp(v));
+ }
+
// If `v' designates a pair, return a pointer to its
// concrete representation.
inline Pair to_pair_if_can(Value v) {
- return is<Pair>(v) ? to_pair(v) : nullptr;
+ return consp(v) == Value::t ? to_pair(v) : nullptr;
}
Fixnum count_nodes(Pair);
@@ -368,14 +396,19 @@ namespace OpenAxiom {
struct Package;
- enum class SymbolAttribute {
+ enum class SymbolAttribute : ValueBits {
None = 0x0, // No particular attribute.
Constant = 0x1, // Symbol defined constant.
- SpecialBinding = 0x2, // Symbol declared special.
+ Special = 0x2, // Symbol declared special.
Keyword = 0x4, // A keyword symbol.
- SpecialConstant = Constant | SpecialBinding,
+ SpecialConstant = Constant | Special,
};
+ constexpr SymbolAttribute
+ operator&(SymbolAttribute x, SymbolAttribute y) {
+ return SymbolAttribute(ValueBits(x) & ValueBits(y));
+ }
+
// ------------
// -- Symbol --
// ------------
@@ -387,6 +420,8 @@ namespace OpenAxiom {
Package* package;
SymbolAttribute attributes;
explicit Symbol(InternedString);
+ void format_on(std::ostream&) const override;
+ bool has(SymbolAttribute x) const { return (attributes & x) == x; }
};
inline Symbol* to_symbol_if_can(Value v) {
@@ -397,6 +432,18 @@ namespace OpenAxiom {
return to_symbol_if_can(v) != nullptr;
}
+ // -- Test if a value is a symbol.
+ inline Value symbolp(Value v) {
+ return to_value(v == Value::nil or v == Value::t or is_symbol(v));
+ }
+
+ // -- Test if a value is a keyword symbol.
+ inline Value keywordp(Value v) {
+ if (auto sym = to_symbol_if_can(v))
+ return to_value(sym->has(SymbolAttribute::Keyword));
+ return Value::nil;
+ }
+
struct CmpByName {
template<typename T>
bool operator()(const T& x, const T& y) const {
@@ -421,6 +468,7 @@ namespace OpenAxiom {
~Environment();
void bind(Symbol*, Value);
+ Binding* lookup(InternedString);
private:
std::vector<Binding> lexical;
std::vector<Binding> dynamic;
@@ -434,7 +482,9 @@ namespace OpenAxiom {
std::set<Symbol, CmpByName> symbols;
explicit Package(InternedString);
+ void format_on(std::ostream&) const override;
Symbol* make_symbol(InternedString);
+ Symbol* find_symbol(InternedString);
};
// --------------
@@ -445,6 +495,7 @@ namespace OpenAxiom {
Value type;
FunctionBase(const Symbol* n, Value t = Value::nil)
: name(n), type(t) { }
+ void format_on(std::ostream&) const override;
};
// ------------------------
@@ -452,10 +503,13 @@ namespace OpenAxiom {
// ------------------------
// Types for native implementation of builtin operators.
struct BasicContext;
- using NullaryCode = Value (*)(BasicContext*);
- using UnaryCode = Value (*)(BasicContext*, Value);
- using BinaryCode = Value (*)(BasicContext*, Value, Value);
- using TernaryCode = Value (*)(BasicContext*, Value, Value, Value);
+
+ template<typename... Ts>
+ using RuntimeOperation = Value(*)(BasicContext*, Ts...);
+ using NullaryCode = RuntimeOperation<>;
+ using UnaryCode = RuntimeOperation<Value>;
+ using BinaryCode = RuntimeOperation<Value, Value>;
+ using TernaryCode = RuntimeOperation<Value, Value, Value>;
template<typename Code>
struct BuiltinFunction : FunctionBase {
@@ -470,6 +524,23 @@ namespace OpenAxiom {
using BinaryOperator = BuiltinFunction<BinaryCode>;
using TernaryOperator = BuiltinFunction<TernaryCode>;
+ // -- Operand stack.
+ struct OperandStack : private std::vector<Value> {
+ using super = std::vector<Value>;
+ using iterator = std::reverse_iterator<super::iterator>;
+ using super::size;
+ using super::empty;
+ iterator begin() { return rbegin(); }
+ iterator end() { return rend(); }
+ Value top() { return back(); }
+ void push(Value v) { push_back(v); }
+ Value pop() { auto v = back(); pop_back(); return v; }
+ void operator-=(std::size_t i) { resize(size() - i); }
+ Value operator[](std::size_t i) {
+ return super::operator[](size() - i - 1);
+ }
+ };
+
// ------------------
// -- BasicContext --
// ------------------
diff --git a/src/io/Makefile.in b/src/io/Makefile.in
index cc7e0232..49c6ade9 100644
--- a/src/io/Makefile.in
+++ b/src/io/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -250,6 +250,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
+LLVM_CONFIG = @LLVM_CONFIG@
LNKEXT = @LNKEXT@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
@@ -370,6 +371,7 @@ oa_target_texdir = @oa_target_texdir@
oa_targetdir = @oa_targetdir@
oa_use_dynamic_lib = @oa_use_dynamic_lib@
oa_use_libtool_for_shared_lib = @oa_use_libtool_for_shared_lib@
+oa_use_llvm = @oa_use_llvm@
oa_use_x = @oa_use_x@
oldincludedir = @oldincludedir@
open_axiom_installdir = @open_axiom_installdir@
diff --git a/src/lisp/Makefile.in b/src/lisp/Makefile.in
index de4f1f60..3602fe53 100644
--- a/src/lisp/Makefile.in
+++ b/src/lisp/Makefile.in
@@ -131,6 +131,7 @@ $(oa_target_lispdir)/linkset: $(oa_target_lispdir)/core.$(LNKEXT)
oa_optimize_options = @oa_optimize_options@
oa_delay_ffi = @oa_delay_ffi@
+oa_use_llvm = @oa_use_llvm@
oa_editor = @oa_editor@
@@ -161,6 +162,7 @@ edit = sed \
-e 's|@oa_standard_linking[@]|$(oa_standard_linking)|g' \
-e 's|@oa_enable_profiling[@]|$(oa_enable_lisp_profiling)|g' \
-e 's|@oa_delay_ffi[@]|$(oa_delay_ffi)|g' \
+ -e 's|@oa_use_llvm[@]|$(oa_use_llvm)|g' \
-e 's|@void_type[@]|$(void_type)|g' \
-e 's|@char_type[@]|$(char_type)|g' \
-e 's|@int_type[@]|$(int_type)|g' \
diff --git a/src/lisp/core.lisp.in b/src/lisp/core.lisp.in
index 81fd0f2f..025791f2 100644
--- a/src/lisp/core.lisp.in
+++ b/src/lisp/core.lisp.in
@@ -180,6 +180,7 @@
"$faslType"
"$delayedFFI"
+ "$useLLVM"
"$effectiveFaslType"
"$NativeModuleExt"
"$systemInstallationDirectory"
@@ -437,6 +438,10 @@
(defconstant |$delayedFFI|
(eq '@oa_delay_ffi@ 'yes))
+;; True if the host has usable framework
+(defconstant |$useLLVM|
+ (eq '@oa_use_llvm@ 'yes))
+
;; The top level read-eval-print loop function of the base
;; Lisp system we are using. This is a very brittle way
;; of achieving something conceptually simple.
diff --git a/src/rt/Makefile.in b/src/rt/Makefile.in
index f1dfdf20..61aa22ba 100644
--- a/src/rt/Makefile.in
+++ b/src/rt/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -250,6 +250,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
+LLVM_CONFIG = @LLVM_CONFIG@
LNKEXT = @LNKEXT@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
@@ -370,6 +371,7 @@ oa_target_texdir = @oa_target_texdir@
oa_targetdir = @oa_targetdir@
oa_use_dynamic_lib = @oa_use_dynamic_lib@
oa_use_libtool_for_shared_lib = @oa_use_libtool_for_shared_lib@
+oa_use_llvm = @oa_use_llvm@
oa_use_x = @oa_use_x@
oldincludedir = @oldincludedir@
open_axiom_installdir = @open_axiom_installdir@
diff --git a/src/rt/vm.cc b/src/rt/vm.cc
index 7f5cd5fc..4cedc030 100644
--- a/src/rt/vm.cc
+++ b/src/rt/vm.cc
@@ -33,6 +33,9 @@
// --% Author: Gabriel Dos Reis
#include <open-axiom/vm>
+#include <iterator>
+#include <algorithm>
+#include <ostream>
namespace OpenAxiom {
namespace VM {
@@ -46,6 +49,15 @@ namespace OpenAxiom {
p->symbol->value = p->value;
}
+ Environment::Binding*
+ Environment::lookup(InternedString name) {
+ for (auto& b : lexical) {
+ if (b.symbol->name == name)
+ return &b;
+ }
+ return nullptr;
+ }
+
// -- Dynamic
Dynamic::~Dynamic() { }
@@ -59,11 +71,24 @@ namespace OpenAxiom {
attributes()
{ }
+ void Symbol::format_on(std::ostream& os) const {
+ // FIXME: handle escapes.
+ std::copy(name->begin(), name->end(),
+ std::ostream_iterator<char>(os));
+ }
+
// -- Package
Package::Package(InternedString s)
: name(s)
{ }
+ void Package::format_on(std::ostream& os) const {
+ os << "#<PACKAGE \"";
+ std::copy(name->begin(), name->end(),
+ std::ostream_iterator<char>(os));
+ os << '"' << '>';
+ }
+
Symbol*
Package::make_symbol(InternedString s) {
auto sym = const_cast<Symbol*>(&*symbols.insert(Symbol(s)).first);
@@ -71,6 +96,19 @@ namespace OpenAxiom {
return sym;
}
+ Symbol*
+ Package::find_symbol(InternedString s) {
+ auto p = symbols.find(Symbol(s));
+ return p == symbols.end() ? nullptr : const_cast<Symbol*>(&*p);
+ }
+
+ // -- FunctionBase
+ void FunctionBase::format_on(std::ostream& os) const {
+ os << "#<FUNCTION ";
+ name->format_on(os);
+ os << '>';
+ }
+
Fixnum
count_nodes(Pair p) {
FixnumBits n = 1;
diff --git a/src/syntax/Makefile.in b/src/syntax/Makefile.in
index a22f7613..8a9c93c5 100644
--- a/src/syntax/Makefile.in
+++ b/src/syntax/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -250,6 +250,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
+LLVM_CONFIG = @LLVM_CONFIG@
LNKEXT = @LNKEXT@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
@@ -370,6 +371,7 @@ oa_target_texdir = @oa_target_texdir@
oa_targetdir = @oa_targetdir@
oa_use_dynamic_lib = @oa_use_dynamic_lib@
oa_use_libtool_for_shared_lib = @oa_use_libtool_for_shared_lib@
+oa_use_llvm = @oa_use_llvm@
oa_use_x = @oa_use_x@
oldincludedir = @oldincludedir@
open_axiom_installdir = @open_axiom_installdir@
diff --git a/src/syntax/sexpr.cc b/src/syntax/sexpr.cc
index 97413935..f9d76825 100644
--- a/src/syntax/sexpr.cc
+++ b/src/syntax/sexpr.cc
@@ -44,7 +44,7 @@ namespace OpenAxiom {
namespace Sexpr {
static void
invalid_character(Reader::State& s) {
- auto line = std::to_string(s.lineno);
+ auto line = std::to_string(s.bytes.lineno);
auto column = std::to_string(s.cur - s.line);
auto msg = "invalid character on line " + line +
" and column " + column;
@@ -77,10 +77,10 @@ namespace OpenAxiom {
// return true if there are more input characters to consider.
static bool
skip_blank(Reader::State& s) {
- for (bool done = false; s.cur < s.end and not done; )
+ for (bool done = false; s.cur < s.bytes.end and not done; )
switch (*s.cur) {
case '\n':
- ++s.lineno;
+ ++s.bytes.lineno;
s.line = ++s.cur;
break;
case ' ': case '\t': case '\v': case '\r': case '\f':
@@ -88,14 +88,14 @@ namespace OpenAxiom {
break;
default: done = true; break;
}
- return s.cur < s.end;
+ return s.cur < s.bytes.end;
}
// Move `cur' to end-of-line marker.
static void
skip_to_eol(Reader::State& s) {
// FIXME: properly handle CR+LF.
- while (s.cur < s.end and *s.cur != '\n')
+ while (s.cur < s.bytes.end and *s.cur != '\n')
++s.cur;
}
@@ -103,7 +103,7 @@ namespace OpenAxiom {
// Return true if the character was seen.
static bool
skip_to_nonescaped_char(Reader::State& s, char c) {
- for (bool saw_escape = false; s.cur < s.end; ++s.cur)
+ for (bool saw_escape = false; s.cur < s.bytes.end; ++s.cur)
if (saw_escape)
saw_escape = false;
else if (*s.cur == '\\')
@@ -125,9 +125,9 @@ namespace OpenAxiom {
template<typename Pred>
static bool
advance_while(Reader::State& s, Pred p) {
- while (s.cur < s.end and p(*s.cur))
+ while (s.cur < s.bytes.end and p(*s.cur))
++s.cur;
- return s.cur < s.end;
+ return s.cur < s.bytes.end;
}
// Return true if the character `c' be part of a non-absolute
@@ -365,7 +365,11 @@ namespace OpenAxiom {
// -- Reader --
Reader::Reader(const Byte* f, const Byte* l)
- : st{ f, l, f, f, 1, }
+ : st{ { f, l, 1 }, f, f }
+ { }
+
+ Reader::Reader(const RawInput& ri)
+ : st { ri, ri.start, ri.start }
{ }
static const Syntax* read_sexpr(Reader::State&);
@@ -376,7 +380,7 @@ namespace OpenAxiom {
auto start = s.cur++;
if (not skip_to_quote(s))
syntax_error("missing closing quote sign for string literal");
- Lexeme t = { { start, s.cur }, s.lineno };
+ Lexeme t = { { start, s.cur }, s.bytes.lineno };
return s.alloc.make_string(t);
}
@@ -386,7 +390,7 @@ namespace OpenAxiom {
auto start = ++s.cur;
if (not skip_to_nonescaped_char(s, '|'))
syntax_error("missing closing bar sign for an absolute symbol");
- Lexeme t = { { start, s.cur - 1 }, s.lineno };
+ Lexeme t = { { start, s.cur - 1 }, s.bytes.lineno };
return s.alloc.make_symbol(SymbolSyntax::absolute, t);
}
@@ -395,12 +399,12 @@ namespace OpenAxiom {
read_maybe_natural(Reader::State& s) {
auto start = s.cur;
advance_while (s, isdigit);
- if (s.cur >= s.end or is_delimiter(*s.cur)) {
- Lexeme t = { { start, s.cur }, s.lineno };
+ if (s.cur >= s.bytes.end or is_delimiter(*s.cur)) {
+ Lexeme t = { { start, s.cur }, s.bytes.lineno };
return s.alloc.make_integer(t);
}
advance_while(s, identifier_part);
- Lexeme t = { { start, s.cur }, s.lineno };
+ Lexeme t = { { start, s.cur }, s.bytes.lineno };
return s.alloc.make_symbol(SymbolSyntax::ordinary, t);
}
@@ -409,7 +413,7 @@ namespace OpenAxiom {
read_identifier(Reader::State& s) {
auto start = s.cur;
advance_while(s, identifier_part);
- Lexeme t = { { start, s.cur }, s.lineno };
+ Lexeme t = { { start, s.cur }, s.bytes.lineno };
return s.alloc.make_symbol(SymbolSyntax::ordinary, t);
}
@@ -418,15 +422,15 @@ namespace OpenAxiom {
static const Syntax*
read_maybe_signed_number(Reader::State& s) {
auto start = s.cur++;
- if (s.cur < s.end and isdigit(*s.cur)) {
+ if (s.cur < s.bytes.end and isdigit(*s.cur)) {
advance_while(s, isdigit);
- if (s.cur >= s.end or is_delimiter(*s.cur)) {
- Lexeme t = { { start, s.cur }, s.lineno };
+ if (s.cur >= s.bytes.end or is_delimiter(*s.cur)) {
+ Lexeme t = { { start, s.cur }, s.bytes.lineno };
return s.alloc.make_integer(t);
}
}
advance_while(s, identifier_part);
- Lexeme t = { { start, s.cur }, s.lineno };
+ Lexeme t = { { start, s.cur }, s.bytes.lineno };
return s.alloc.make_symbol(SymbolSyntax::ordinary, t);
}
@@ -434,7 +438,7 @@ namespace OpenAxiom {
read_keyword(Reader::State& s) {
auto start = s.cur++;
advance_while(s, identifier_part);
- Lexeme t = { { start, s.cur }, s.lineno };
+ Lexeme t = { { start, s.cur }, s.bytes.lineno };
return s.alloc.make_symbol(SymbolSyntax::keyword, t);
}
@@ -491,7 +495,7 @@ namespace OpenAxiom {
else
syntax_error("syntax error while reading vector elements");
}
- if (s.cur >= s.end)
+ if (s.cur >= s.bytes.end)
syntax_error("unfinished literal vector");
else
++s.cur;
@@ -504,12 +508,12 @@ namespace OpenAxiom {
finish_anchor_or_reference(Reader::State& s) {
auto start = s.cur;
advance_while(s, isdigit);
- if (s.cur >= s.end)
+ if (s.cur >= s.bytes.end)
syntax_error("end-of-input after sharp-number sign");
const Byte c = *s.cur;
if (c != '#' and c != '=')
syntax_error("syntax error after sharp-number-equal sign");
- Lexeme t = { { start, s.cur }, s.lineno };
+ Lexeme t = { { start, s.cur }, s.bytes.lineno };
auto n = natural_value(start, s.cur);
++s.cur;
if (c == '#')
@@ -534,7 +538,7 @@ namespace OpenAxiom {
++s.cur; // skip colon sign.
auto start = s.cur;
advance_while(s, identifier_part);
- Lexeme t = { { start, s.cur }, s.lineno };
+ Lexeme t = { { start, s.cur }, s.bytes.lineno };
return s.alloc.make_symbol(SymbolSyntax::uninterned, t);
}
@@ -552,7 +556,7 @@ namespace OpenAxiom {
++s.cur; // skip backslash sign
auto start = s.cur;
advance_while(s, identifier_part);
- Lexeme t = { { start, s.cur }, s.lineno };
+ Lexeme t = { { start, s.cur }, s.bytes.lineno };
return s.alloc.make_character(t);
}
@@ -574,7 +578,7 @@ namespace OpenAxiom {
static const Syntax*
read_sharp_et_al(Reader::State& s) {
- if (++s.cur >= s.end)
+ if (++s.cur >= s.bytes.end)
syntax_error("end-of-input reached after sharp sign");
switch (*s.cur) {
case '(': return finish_literal_vector(s);
@@ -655,7 +659,7 @@ namespace OpenAxiom {
const Byte*
Reader::position(Ordinal p) {
- st.cur = st.start + p;
+ st.cur = st.bytes.start + p;
st.line = st.cur;
// while (st.line > st.start and st.line[-1] != '\n')
// --st.line;