#34: MPFR lib, first attempt

This commit is contained in:
Louis Rubet 2017-04-17 23:10:53 +02:00
parent ccca25ab24
commit 4670aa77c0
19 changed files with 694 additions and 572 deletions

View file

@ -16,6 +16,7 @@ rpn_SOURCES = src/rpn.cpp \
src/rpn-trig.h \ src/rpn-trig.h \
src/stack.h src/stack.h
rpn_LDFLAGS = -Wl,--no-as-needed -lreadline rpn_CFLAGS = -g
rpn_LDFLAGS = -Wl,--no-as-needed -lreadline -lmpfr
dist_noinst_SCRIPTS = autogen.sh dist_noinst_SCRIPTS = autogen.sh

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.14.1 from Makefile.am. # Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@ # @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc. # Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -16,7 +16,17 @@
VPATH = @srcdir@ VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \ am__make_running_with_option = \
case $${target_option-} in \ case $${target_option-} in \
?) ;; \ ?) ;; \
@ -79,15 +89,13 @@ PRE_UNINSTALL = :
POST_UNINSTALL = : POST_UNINSTALL = :
bin_PROGRAMS = rpn$(EXEEXT) bin_PROGRAMS = rpn$(EXEEXT)
subdir = . subdir = .
DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/configure $(am__configure_deps) \
$(srcdir)/config.h.in $(dist_noinst_SCRIPTS) depcomp COPYING \
TODO install-sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
$(am__configure_deps) $(dist_noinst_SCRIPTS) \
$(am__DIST_COMMON)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d mkinstalldirs = $(install_sh) -d
@ -173,6 +181,9 @@ ETAGS = etags
CTAGS = ctags CTAGS = ctags
CSCOPE = cscope CSCOPE = cscope
AM_RECURSIVE_TARGETS = cscope AM_RECURSIVE_TARGETS = cscope
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in AUTHORS \
COPYING ChangeLog INSTALL NEWS README TODO depcomp install-sh \
missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION) distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir) top_distdir = $(distdir)
@ -266,6 +277,7 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@
@ -289,7 +301,8 @@ rpn_SOURCES = src/rpn.cpp \
src/rpn-trig.h \ src/rpn-trig.h \
src/stack.h src/stack.h
rpn_LDFLAGS = -Wl,--no-as-needed -lreadline rpn_CFLAGS = -g
rpn_LDFLAGS = -Wl,--no-as-needed -lreadline -lmpfr
dist_noinst_SCRIPTS = autogen.sh dist_noinst_SCRIPTS = autogen.sh
all: config.h all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am $(MAKE) $(AM_MAKEFLAGS) all-am
@ -311,7 +324,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
$(am__cd) $(top_srcdir) && \ $(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile $(AUTOMAKE) --gnu Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \ @case '$?' in \
*config.status*) \ *config.status*) \
@ -539,15 +551,15 @@ dist-xz: distdir
$(am__post_remove_distdir) $(am__post_remove_distdir)
dist-tarZ: distdir dist-tarZ: distdir
@echo WARNING: "Support for shar distribution archives is" \ @echo WARNING: "Support for distribution archives compressed with" \
"deprecated." >&2 "legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir) $(am__post_remove_distdir)
dist-shar: distdir dist-shar: distdir
@echo WARNING: "Support for distribution archives compressed with" \ @echo WARNING: "Support for shar distribution archives is" \
"legacy program 'compress' is deprecated." >&2 "deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir) $(am__post_remove_distdir)
@ -583,17 +595,17 @@ distcheck: dist
esac esac
chmod -R a-w $(distdir) chmod -R a-w $(distdir)
chmod u+w $(distdir) chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_inst mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
chmod a-w $(distdir) chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \ test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \ && am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \ && $(am__cd) $(distdir)/_build/sub \
&& ../configure \ && ../../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=.. --prefix="$$dc_install_base" \ --srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) check \
@ -776,6 +788,8 @@ uninstall-am: uninstall-binPROGRAMS
mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am uninstall-binPROGRAMS uninstall-am uninstall-binPROGRAMS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded. # Otherwise a system limit (for SysV at least) may be exceeded.

0
README Normal file
View file

58
aclocal.m4 vendored
View file

@ -1,6 +1,6 @@
# generated automatically by aclocal 1.14.1 -*- Autoconf -*- # generated automatically by aclocal 1.15 -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc. # Copyright (C) 1996-2014 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely. If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])]) To do so, use the procedure documented by the package, typically 'autoreconf'.])])
# Copyright (C) 2002-2013 Free Software Foundation, Inc. # Copyright (C) 2002-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -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. # generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.) # (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION], AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.14' [am__api_version='1.15'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to 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. dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.14.1], [], m4_if([$1], [1.15], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
]) ])
@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.14.1])dnl [AM_AUTOMAKE_VERSION([1.15])dnl
m4_ifndef([AC_AUTOCONF_VERSION], m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*- # AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc. # Copyright (C) 2001-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -103,15 +103,14 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# configured tree to be moved without reconfiguration. # configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND], AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
AC_PREREQ([2.50])dnl # Expand $ac_aux_dir to an absolute path.
# expand $ac_aux_dir to an absolute path am_aux_dir=`cd "$ac_aux_dir" && pwd`
am_aux_dir=`cd $ac_aux_dir && pwd`
]) ])
# AM_CONDITIONAL -*- Autoconf -*- # AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997-2013 Free Software Foundation, Inc. # Copyright (C) 1997-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -142,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE(
Usually this means the macro was only invoked conditionally.]]) Usually this means the macro was only invoked conditionally.]])
fi])]) fi])])
# Copyright (C) 1999-2013 Free Software Foundation, Inc. # Copyright (C) 1999-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -333,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
# Generate code to set up dependency tracking. -*- Autoconf -*- # Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999-2013 Free Software Foundation, Inc. # Copyright (C) 1999-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -409,7 +408,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# Do all the work for Automake. -*- Autoconf -*- # Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc. # Copyright (C) 1996-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -499,8 +498,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
AC_SUBST([mkdir_p], ['$(MKDIR_P)']) AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
# We need awk for the "check" target. The system "awk" is bad on # We need awk for the "check" target (and possibly the TAP driver). The
# some platforms. # system "awk" is bad on some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl
@ -574,6 +573,9 @@ END
AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
fi fi
fi fi
dnl The trailing newline in this macro's definition is deliberate, for
dnl backward compatibility and to allow trailing 'dnl'-style comments
dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
]) ])
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
@ -603,7 +605,7 @@ for _am_header in $config_headers :; do
done done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001-2013 Free Software Foundation, Inc. # Copyright (C) 2001-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -614,7 +616,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
# Define $install_sh. # Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH], AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
if test x"${install_sh}" != xset; then if test x"${install_sh+set}" != xset; then
case $am_aux_dir in case $am_aux_dir in
*\ * | *\ *) *\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@ -624,7 +626,7 @@ if test x"${install_sh}" != xset; then
fi fi
AC_SUBST([install_sh])]) AC_SUBST([install_sh])])
# Copyright (C) 2003-2013 Free Software Foundation, Inc. # Copyright (C) 2003-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -645,7 +647,7 @@ AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*- # Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc. # Copyright (C) 2001-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -695,7 +697,7 @@ rm -f confinc confmf
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997-2013 Free Software Foundation, Inc. # Copyright (C) 1997-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -734,7 +736,7 @@ fi
# Helper functions for option handling. -*- Autoconf -*- # Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc. # Copyright (C) 2001-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -765,7 +767,7 @@ AC_DEFUN([_AM_IF_OPTION],
# Check to make sure that the build environment is sane. -*- Autoconf -*- # Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc. # Copyright (C) 1996-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -846,7 +848,7 @@ AC_CONFIG_COMMANDS_PRE(
rm -f conftest.file rm -f conftest.file
]) ])
# Copyright (C) 2009-2013 Free Software Foundation, Inc. # Copyright (C) 2009-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -906,7 +908,7 @@ AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
]) ])
# Copyright (C) 2001-2013 Free Software Foundation, Inc. # Copyright (C) 2001-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -934,7 +936,7 @@ fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])]) AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006-2013 Free Software Foundation, Inc. # Copyright (C) 2006-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
@ -953,7 +955,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*- # Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004-2013 Free Software Foundation, Inc. # Copyright (C) 2004-2014 Free Software Foundation, Inc.
# #
# This file is free software; the Free Software Foundation # This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,

26
configure vendored
View file

@ -651,6 +651,7 @@ infodir
docdir docdir
oldincludedir oldincludedir
includedir includedir
runstatedir
localstatedir localstatedir
sharedstatedir sharedstatedir
sysconfdir sysconfdir
@ -723,6 +724,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc' sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com' sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var' localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include' includedir='${prefix}/include'
oldincludedir='/usr/include' oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@ -975,6 +977,15 @@ do
| -silent | --silent | --silen | --sile | --sil) | -silent | --silent | --silen | --sile | --sil)
silent=yes ;; silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;; ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@ -1112,7 +1123,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \ datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir libdir localedir mandir runstatedir
do do
eval ac_val=\$$ac_var eval ac_val=\$$ac_var
# Remove trailing slashes. # Remove trailing slashes.
@ -1265,6 +1276,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var] --localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib] --libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include] --includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include] --oldincludedir=DIR C header files for non-gcc [/usr/include]
@ -1786,7 +1798,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
am__api_version='1.14' am__api_version='1.15'
ac_aux_dir= ac_aux_dir=
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
@ -1987,8 +1999,8 @@ test "$program_suffix" != NONE &&
ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
# expand $ac_aux_dir to an absolute path # Expand $ac_aux_dir to an absolute path.
am_aux_dir=`cd $ac_aux_dir && pwd` am_aux_dir=`cd "$ac_aux_dir" && pwd`
if test x"${MISSING+set}" != xset; then if test x"${MISSING+set}" != xset; then
case $am_aux_dir in case $am_aux_dir in
@ -2007,7 +2019,7 @@ else
$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
fi fi
if test x"${install_sh}" != xset; then if test x"${install_sh+set}" != xset; then
case $am_aux_dir in case $am_aux_dir in
*\ * | *\ *) *\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@ -2326,8 +2338,8 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
mkdir_p='$(MKDIR_P)' mkdir_p='$(MKDIR_P)'
# We need awk for the "check" target. The system "awk" is bad on # We need awk for the "check" target (and possibly the TAP driver). The
# some platforms. # system "awk" is bad on some platforms.
# Always define AMTAR for backward compatibility. Yes, it's still used # Always define AMTAR for backward compatibility. Yes, it's still used
# in the wild :-( We should find a proper way to deprecate it ... # in the wild :-( We should find a proper way to deprecate it ...
AMTAR='$${TAR-tar}' AMTAR='$${TAR-tar}'

View file

@ -3,7 +3,7 @@
scriptversion=2013-05-30.07; # UTC scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc. # Copyright (C) 1999-2014 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# install - install a program, script, or datafile # install - install a program, script, or datafile
scriptversion=2011-11-20.07; # UTC scriptversion=2014-09-12.12; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was # This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the # later released in X11R6 (xc/config/util/install.sh) with the
@ -41,19 +41,15 @@ scriptversion=2011-11-20.07; # UTC
# This script is compatible with the BSD install script, but was written # This script is compatible with the BSD install script, but was written
# from scratch. # from scratch.
tab=' '
nl=' nl='
' '
IFS=" "" $nl" IFS=" $tab$nl"
# set DOITPROG to echo to test this script # Set DOITPROG to "echo" to test this script.
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-} doit=${DOITPROG-}
if test -z "$doit"; then doit_exec=${doit:-exec}
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path; # Put in absolute file names if you don't have them in your path;
# or use environment vars. # or use environment vars.
@ -68,17 +64,6 @@ mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm} rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip} stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir= posix_mkdir=
# Desired mode of installed file. # Desired mode of installed file.
@ -97,7 +82,7 @@ dir_arg=
dst_arg= dst_arg=
copy_on_change=false copy_on_change=false
no_target_directory= is_target_a_directory=possibly
usage="\ usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@ -143,8 +128,7 @@ while test $# -ne 0; do
-m) mode=$2 -m) mode=$2
case $mode in case $mode in
*' '* | *' '* | *' *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2 echo "$0: invalid mode: $mode" >&2
exit 1;; exit 1;;
esac esac
@ -155,14 +139,16 @@ while test $# -ne 0; do
-s) stripcmd=$stripprog;; -s) stripcmd=$stripprog;;
-t) dst_arg=$2 -t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities. # Protect names problematic for 'test' and other utilities.
case $dst_arg in case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;; -* | [=\(\)!]) dst_arg=./$dst_arg;;
esac esac
shift;; shift;;
-T) no_target_directory=true;; -T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;; --version) echo "$0 $scriptversion"; exit $?;;
@ -177,6 +163,16 @@ while test $# -ne 0; do
shift shift
done done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create. # When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified. # When -t is used, the destination is already specified.
@ -207,6 +203,15 @@ if test $# -eq 0; then
exit 0 exit 0
fi fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret' do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1 trap "ret=129; $do_exit" 1
@ -269,7 +274,7 @@ do
# If destination is a directory, append the input filename; won't work # If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored. # if double slashes aren't ignored.
if test -d "$dst"; then if test -d "$dst"; then
if test -n "$no_target_directory"; then if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2 echo "$0: $dst_arg: Is a directory" >&2
exit 1 exit 1
fi fi
@ -277,33 +282,7 @@ do
dst=$dstdir/`basename "$src"` dst=$dstdir/`basename "$src"`
dstdir_status=0 dstdir_status=0
else else
# Prefer dirname, but fall back on a substitute if dirname fails. dstdir=`dirname "$dst"`
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir" test -d "$dstdir"
dstdir_status=$? dstdir_status=$?
fi fi
@ -345,34 +324,41 @@ do
# is incompatible with FreeBSD 'install' when (umask & 300) != 0. # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;; ;;
*) *)
# $RANDOM is not portable (e.g. dash); use it when possible to
# lower collision chance
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
# As "mkdir -p" follows symlinks and we work in /tmp possibly; so
# create the $tmpdir first (and fail if unsuccessful) to make sure
# that nobody tries to guess the $tmpdir name.
if (umask $mkdir_umask && if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 $mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then then
if test -z "$dir_arg" || { if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m. # Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't. # other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"` test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;; d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;; d????-?--*) different_mode=755;;
*) false;; *) false;;
esac && esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && { $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"` ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
} }
} }
then posix_mkdir=: then posix_mkdir=:
fi fi
rmdir "$tmpdir/d" "$tmpdir" rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else else
# Remove any dirs left behind by ancient mkdir implementations. # Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi fi
trap '' 0;; trap '' 0;;
esac;; esac;;
@ -396,14 +382,12 @@ do
*) prefix='';; *) prefix='';;
esac esac
eval "$initialize_posix_glob"
oIFS=$IFS oIFS=$IFS
IFS=/ IFS=/
$posix_glob set -f set -f
set fnord $dstdir set fnord $dstdir
shift shift
$posix_glob set +f set +f
IFS=$oIFS IFS=$oIFS
prefixes= prefixes=
@ -474,13 +458,10 @@ do
if $copy_on_change && if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set X $old && old=:$2:$4:$5:$6 && set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f && set +f &&
test "$old" = "$new" && test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then then

View file

@ -3,7 +3,7 @@
scriptversion=2013-10-28.13; # UTC scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996-2013 Free Software Foundation, Inc. # Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify

View file

@ -336,22 +336,21 @@ static bool get_program(const string& entry, object*& obj, unsigned int& obj_len
static bool get_float(const string& entry, object*& obj, unsigned int& obj_size, string& remaining_entry) static bool get_float(const string& entry, object*& obj, unsigned int& obj_size, string& remaining_entry)
{ {
static number new_number; static number new_number;
floating_t val; char* endptr;
stringstream token;
bool ret = false; bool ret = false;
token<<entry; if (entry.size() > 0)
token>>val; {
if ((mpfr_strtofr(&new_number._value.mpfr, entry.c_str(), &endptr, 0, MPFR_DEF_RND) != -1) && (endptr != entry.c_str()))
if ( (!token.fail()) && (!token.bad()) )
{ {
new_number.set(val);
obj = &new_number; obj = &new_number;
obj_size = sizeof(number); obj_size = sizeof(number);
ret = true; ret = true;
// remaining string if any // remaining string if any
token>>remaining_entry; if (endptr != NULL)
remaining_entry = endptr;
}
} }
return ret; return ret;
@ -563,8 +562,16 @@ static ret_value parse(const char* entry, program& prog)
// this remaining entry is treated as an entry // this remaining entry is treated as an entry
if(_obj_from_string(main_entry, obj, obj_size, type, remaining_entry)) if(_obj_from_string(main_entry, obj, obj_size, type, remaining_entry))
{ {
cout<<"parse->obj = "<<obj<<endl;
prog.push_back(obj, obj_size, type); prog.push_back(obj, obj_size, type);
_delete_obj_from_string(obj); if (((object*)prog.back())->_type == cmd_number)
{
cout<<"((number*)prog.back())="<<(void*)prog.back()<<endl;
cout<<" (((number*)prog.back())->_value.mpfr._mpfr_d = "<<((number*)prog.back())->_value.mpfr._mpfr_d<<")"<<endl;
((number*)prog.back())->_value.mpfr._mpfr_d = (mp_limb_t*)((number*)prog.back())->_value.significand;
cout<<" -> (((number*)prog.back())->_value.mpfr._mpfr_d = "<<((number*)prog.back())->_value.mpfr._mpfr_d<<")"<<endl;
}
//_delete_obj_from_string(obj);
} }
else else
{ {

View file

@ -20,19 +20,20 @@ void bin()
void rtob() void rtob()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
binary bin;
bin.set(((integer_t)getf()));
_stack->push_back(&bin, bin.size(), cmd_binary);
//binary bin;
//bin.set(((integer_t)getf()));
//_stack->push_back(&bin, bin.size(), cmd_binary);
} }
void btor() void btor()
{ {
MIN_ARGUMENTS(1); // TODO
ARG_MUST_BE_OF_TYPE(0, cmd_binary); //MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_binary);
putf((floating_t)getb()); //putf((floating_t)getb());
} }

View file

@ -5,7 +5,12 @@ int rpn_if(branch& myobj)
// myobj.arg1 = 'if' condition evaluation value // myobj.arg1 = 'if' condition evaluation value
MIN_ARGUMENTS_RET(1, -1); MIN_ARGUMENTS_RET(1, -1);
ARG_MUST_BE_OF_TYPE_RET(0, cmd_number, -1); ARG_MUST_BE_OF_TYPE_RET(0, cmd_number, -1);
myobj.arg1 = ((getf() != 0) ? 1 : 0);
if (mpfr_cmp_si(&((number*)_stack->get_obj(0))->_value.mpfr, 0UL) != 0)
myobj.arg1 = 1;
else
myobj.arg1 = 0;
_stack->pop_back();
return -1; return -1;
} }
@ -89,7 +94,7 @@ int rpn_next(branch& myobj)
} }
// increment then test // increment then test
myobj.farg1++; mpfr_add_si(&myobj.farg1.mpfr, &myobj.farg1.mpfr, 1UL, MPFR_DEF_RND);
// for command: increment symbol too // for command: increment symbol too
if (start_or_for->arg1 != -1) if (start_or_for->arg1 != -1)
@ -134,7 +139,7 @@ int rpn_step(branch& myobj)
} }
// increment then test // increment then test
myobj.farg1 += step; mpfr_add(&myobj.farg1.mpfr, &myobj.farg1.mpfr, &step.mpfr, MPFR_DEF_RND);
// for command: increment symbol too // for command: increment symbol too
if (start_or_for->arg1 != -1) if (start_or_for->arg1 != -1)

View file

@ -15,7 +15,7 @@ void verbose()
{ {
MIN_ARGUMENTS(1); MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number); ARG_MUST_BE_OF_TYPE(0, cmd_number);
g_verbose = (int)getf(); g_verbose = int(getf());
} }
void help() void help()
@ -75,7 +75,7 @@ void std()
if (stack_size()>=1) if (stack_size()>=1)
{ {
ARG_MUST_BE_OF_TYPE(0, cmd_number); ARG_MUST_BE_OF_TYPE(0, cmd_number);
number::s_default_precision = (int)getf(); number::s_default_precision = int(getf());
} }
number::s_current_precision = number::s_default_precision; number::s_current_precision = number::s_default_precision;
number::s_mode = number::std; number::s_mode = number::std;
@ -89,7 +89,7 @@ void fix()
MIN_ARGUMENTS(1); MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number); ARG_MUST_BE_OF_TYPE(0, cmd_number);
number::s_current_precision = (int)getf(); number::s_current_precision = int(getf());
number::s_mode = number::fix; number::s_mode = number::fix;
cout << setprecision(number::s_current_precision) << fixed; cout << setprecision(number::s_current_precision) << fixed;

View file

@ -3,92 +3,103 @@
// //
void rpn_e(void) void rpn_e(void)
{ {
putf(M_E); //TODO
//putf(M_E);
} }
void rpn_log() void rpn_log()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = log10(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = log10(((number*)_stack->get_obj(0))->_value);
} }
void rpn_alog() void rpn_alog()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = pow(((number*)_stack->get_obj(0))->_value, 10); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = pow(((number*)_stack->get_obj(0))->_value, 10);
} }
void rpn_ln() void rpn_ln()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = log(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = log(((number*)_stack->get_obj(0))->_value);
} }
void rpn_exp() void rpn_exp()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = exp(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = exp(((number*)_stack->get_obj(0))->_value);
} }
void rpn_sinh() void rpn_sinh()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = sinh(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = sinh(((number*)_stack->get_obj(0))->_value);
} }
void rpn_asinh() void rpn_asinh()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
floating_t value = ((number*)_stack->get_obj(0))->_value; //floating_t value = ((number*)_stack->get_obj(0))->_value;
if(value>0) //if(value>0)
value = log(value + sqrt(value * value + 1)); // value = log(value + sqrt(value * value + 1));
else //else
value = -log(-value + sqrt(value * value + 1)); // value = -log(-value + sqrt(value * value + 1));
((number*)_stack->get_obj(0))->_value = value; //((number*)_stack->get_obj(0))->_value = value;
} }
void rpn_cosh() void rpn_cosh()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = cosh(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = cosh(((number*)_stack->get_obj(0))->_value);
} }
void rpn_acosh() void rpn_acosh()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
floating_t value = ((number*)_stack->get_obj(0))->_value; //floating_t value = ((number*)_stack->get_obj(0))->_value;
if(value>0) //if(value>0)
value = log(value + sqrt(value * value - 1)); // value = log(value + sqrt(value * value - 1));
else //else
value = -log(-value + sqrt(value * value - 1)); // value = -log(-value + sqrt(value * value - 1));
((number*)_stack->get_obj(0))->_value = value; //((number*)_stack->get_obj(0))->_value = value;
} }
void rpn_tanh() void rpn_tanh()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = tanh(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = tanh(((number*)_stack->get_obj(0))->_value);
} }
void rpn_atanh() void rpn_atanh()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
floating_t value = ((number*)_stack->get_obj(0))->_value; //floating_t value = ((number*)_stack->get_obj(0))->_value;
value = (log(1 + value) - log(1 - value)) / 2; //value = (log(1 + value) - log(1 - value)) / 2;
((number*)_stack->get_obj(0))->_value = value; //((number*)_stack->get_obj(0))->_value = value;
} }

View file

@ -2,20 +2,22 @@ void plus()
{ {
MIN_ARGUMENTS(2); MIN_ARGUMENTS(2);
// float //TODO
if (IS_ARG_TYPE(0, cmd_number)) //// float
{ //if (IS_ARG_TYPE(0, cmd_number))
ARG_MUST_BE_OF_TYPE(1, cmd_number); //{
//TODO really too slow // ARG_MUST_BE_OF_TYPE(1, cmd_number);
putf(getf() + getf()); // //TODO really too slow
} // putf(getf() + getf());
// binary //}
else if (IS_ARG_TYPE(0, cmd_binary)) //// binary
{ //else if (IS_ARG_TYPE(0, cmd_binary))
ARG_MUST_BE_OF_TYPE(1, cmd_binary); //{
//TODO really too slow // ARG_MUST_BE_OF_TYPE(1, cmd_binary);
putb(getb() + getb()); // //TODO really too slow
} // putb(getb() + getb());
//}
//TODO //TODO
#if 0 #if 0
// string // string
@ -27,166 +29,177 @@ void plus()
*((ostring*)_stack->back())->_value += second; *((ostring*)_stack->back())->_value += second;
} }
#endif #endif
else //else
ERR_CONTEXT(ret_bad_operand_type); // ERR_CONTEXT(ret_bad_operand_type);
} }
void minus() void minus()
{ {
MIN_ARGUMENTS(2); MIN_ARGUMENTS(2);
// float //TODO
if (IS_ARG_TYPE(0, cmd_number)) //// float
{ //if (IS_ARG_TYPE(0, cmd_number))
ARG_MUST_BE_OF_TYPE(1, cmd_number); //{
//TODO really too slow // ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf(); // //TODO really too slow
putf(getf() - first); // floating_t first = getf();
} // putf(getf() - first);
// binary //}
else if (IS_ARG_TYPE(0, cmd_binary)) //// binary
{ //else if (IS_ARG_TYPE(0, cmd_binary))
ARG_MUST_BE_OF_TYPE(1, cmd_binary); //{
//TODO really too slow // ARG_MUST_BE_OF_TYPE(1, cmd_binary);
integer_t first = getb(); // //TODO really too slow
putb(getb() - first); // integer_t first = getb();
} // putb(getb() - first);
else //}
ERR_CONTEXT(ret_bad_operand_type); //else
// ERR_CONTEXT(ret_bad_operand_type);
} }
void mul() void mul()
{ {
// float //TODO
if (IS_ARG_TYPE(0, cmd_number)) //// float
{ //if (IS_ARG_TYPE(0, cmd_number))
ARG_MUST_BE_OF_TYPE(1, cmd_number); //{
//TODO really too slow // ARG_MUST_BE_OF_TYPE(1, cmd_number);
putf(getf() * getf()); // //TODO really too slow
} // putf(getf() * getf());
// binary //}
else if (IS_ARG_TYPE(0, cmd_binary)) //// binary
{ //else if (IS_ARG_TYPE(0, cmd_binary))
ARG_MUST_BE_OF_TYPE(1, cmd_binary); //{
//TODO really too slow // ARG_MUST_BE_OF_TYPE(1, cmd_binary);
putb(getb() * getb()); // //TODO really too slow
} // putb(getb() * getb());
else //}
ERR_CONTEXT(ret_bad_operand_type); //else
// ERR_CONTEXT(ret_bad_operand_type);
} }
void div() void div()
{ {
MIN_ARGUMENTS(2); //TODO
//MIN_ARGUMENTS(2);
// float //// float
if (IS_ARG_TYPE(0, cmd_number)) //if (IS_ARG_TYPE(0, cmd_number))
{ //{
ARG_MUST_BE_OF_TYPE(1, cmd_number); // ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO really too slow // //TODO really too slow
floating_t first = getf(); // floating_t first = getf();
// arithmetic faults are managed by c++ // // arithmetic faults are managed by c++
putf(getf() / first); // putf(getf() / first);
} //}
// binary //// binary
else if (IS_ARG_TYPE(0, cmd_binary)) //else if (IS_ARG_TYPE(0, cmd_binary))
{ //{
ARG_MUST_BE_OF_TYPE(1, cmd_binary); // ARG_MUST_BE_OF_TYPE(1, cmd_binary);
if (((binary*)_stack->get_obj(0))->_value == 0) // if (((binary*)_stack->get_obj(0))->_value == 0)
{ // {
ERR_CONTEXT(ret_div_by_zero); // ERR_CONTEXT(ret_div_by_zero);
} // }
else // else
{ // {
//TODO really too slow // //TODO really too slow
integer_t first = getb(); // integer_t first = getb();
putb(getb() / first); // putb(getb() / first);
} // }
} //}
else //else
ERR_CONTEXT(ret_bad_operand_type); // ERR_CONTEXT(ret_bad_operand_type);
} }
void neg() void neg()
{ {
MIN_ARGUMENTS(1); //TODO
//MIN_ARGUMENTS(1);
// float //// float
if (IS_ARG_TYPE(0, cmd_number)) //if (IS_ARG_TYPE(0, cmd_number))
putf(-getf()); // putf(-getf());
// binary //// binary
else if (IS_ARG_TYPE(0, cmd_binary)) //else if (IS_ARG_TYPE(0, cmd_binary))
putb(-getb()); // putb(-getb());
else //else
ERR_CONTEXT(ret_bad_operand_type); // ERR_CONTEXT(ret_bad_operand_type);
} }
void inv() void inv()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
// arithmetic faults are managed by c++ //// arithmetic faults are managed by c++
putf(1 / getf()); //putf(1 / getf());
} }
void purcent() void purcent()
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
putf((getf() * getf()) / 100); //putf((getf() * getf()) / 100);
} }
void purcentCH() void purcentCH()
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
// arithmetic faults are managed by c++ //// arithmetic faults are managed by c++
floating_t first = getf(); //floating_t first = getf();
putf((100 * first) / getf()); //putf((100 * first) / getf());
} }
void power() void power()
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
// arithmetic faults are managed by c++ //// arithmetic faults are managed by c++
floating_t first = getf(); //floating_t first = getf();
putf(powl(getf(), first)); //putf(powl(getf(), first));
} }
void squareroot() void squareroot()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
// arithmetic faults are managed by c++ //// arithmetic faults are managed by c++
putf(sqrtl(getf())); //putf(sqrtl(getf()));
} }
void square() void square()
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
floating_t first = getf(); //floating_t first = getf();
putf(first * first); //putf(first * first);
} }
void modulo() void modulo()
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
// arithmetic faults are managed by c++ //// arithmetic faults are managed by c++
floating_t first = getf(); //floating_t first = getf();
putf(fmodl(getf(), first)); //putf(fmodl(getf(), first));
} }

View file

@ -77,6 +77,6 @@ void rot(void)
void depth(void) void depth(void)
{ {
number num; number num;
num.set((floating_t)_stack->size()); num.set((long)_stack->size());
_stack->push_back(&num, num.size(), cmd_number); _stack->push_back(&num, num.size(), cmd_number);
} }

View file

@ -1,68 +1,74 @@
void sup(void) void sup(void)
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf(); //floating_t first = getf();
putf(getf() > first); //putf(getf() > first);
} }
void sup_eq(void) void sup_eq(void)
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf(); //floating_t first = getf();
putf(getf() >= first); //putf(getf() >= first);
} }
void inf(void) void inf(void)
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf(); //floating_t first = getf();
putf(getf() < first); //putf(getf() < first);
} }
void inf_eq(void) void inf_eq(void)
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf(); //floating_t first = getf();
putf(getf() <= first); //putf(getf() <= first);
} }
void diff(void) void diff(void)
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf(); //floating_t first = getf();
putf(getf() != first); //putf(getf() != first);
} }
void eq(void) void eq(void)
{ {
MIN_ARGUMENTS(2); //TODO
int type = _stack->get_type(0); //MIN_ARGUMENTS(2);
//int type = _stack->get_type(0);
if (_stack->get_type(1) == type) //if (_stack->get_type(1) == type)
{ //{
switch(type) // switch(type)
{ // {
case cmd_number: // case cmd_number:
{ // {
floating_t first = getf(); // floating_t first = getf();
putf(getf() == first); // putf(getf() == first);
} // }
break; // break;
//TODO //TODO
#if 0 #if 0
case cmd_symbol: case cmd_symbol:
@ -71,62 +77,66 @@ void eq(void)
putf(getn() == first); putf(getn() == first);
} }
#endif #endif
break; // break;
default: // default:
_stack->pop_back(); // _stack->pop_back();
_stack->pop_back(); // _stack->pop_back();
putf(0); // putf(0);
break; // break;
} // }
} //}
else //else
{ //{
_stack->pop_back(); // _stack->pop_back();
_stack->pop_back(); // _stack->pop_back();
putf(0); // putf(0);
} //}
} }
void test_and(void) void test_and(void)
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf(); //floating_t first = getf();
floating_t second = getf(); //floating_t second = getf();
putf((first != 0) && (second != 0)); //putf((first != 0) && (second != 0));
} }
void test_or(void) void test_or(void)
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf(); //floating_t first = getf();
floating_t second = getf(); //floating_t second = getf();
putf((first != 0) || (second != 0)); //putf((first != 0) || (second != 0));
} }
void test_xor(void) void test_xor(void)
{ {
MIN_ARGUMENTS(2); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(1, cmd_number); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf(); //floating_t first = getf();
floating_t second = getf(); //floating_t second = getf();
putf(((first == 0) && (second != 0)) || ((first != 0) && (second == 0))); //putf(((first == 0) && (second != 0)) || ((first != 0) && (second == 0)));
} }
void test_not(void) void test_not(void)
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
floating_t first = getf(); //floating_t first = getf();
putf((first == 0) ? 1 : 0); //putf((first == 0) ? 1 : 0);
} }
void same(void) void same(void)

View file

@ -3,61 +3,70 @@
// //
void pi(void) void pi(void)
{ {
putf(M_PI); //TODO
//putf(M_PI);
} }
void d2r(void) void d2r(void)
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value *= M_PI / 360; //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value *= M_PI / 360;
} }
void r2d(void) void r2d(void)
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value *= 360 / M_PI; //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value *= 360 / M_PI;
} }
void rpn_sin(void) void rpn_sin(void)
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = sin(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = sin(((number*)_stack->get_obj(0))->_value);
} }
void rpn_asin(void) void rpn_asin(void)
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = asin(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = asin(((number*)_stack->get_obj(0))->_value);
} }
void rpn_cos(void) void rpn_cos(void)
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = cos(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = cos(((number*)_stack->get_obj(0))->_value);
} }
void rpn_acos(void) void rpn_acos(void)
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = acos(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = acos(((number*)_stack->get_obj(0))->_value);
} }
void rpn_tan(void) void rpn_tan(void)
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = tan(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = tan(((number*)_stack->get_obj(0))->_value);
} }
void rpn_atan(void) void rpn_atan(void)
{ {
MIN_ARGUMENTS(1); //TODO
ARG_MUST_BE_OF_TYPE(0, cmd_number); //MIN_ARGUMENTS(1);
((number*)_stack->get_obj(0))->_value = atan(((number*)_stack->get_obj(0))->_value); //ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = atan(((number*)_stack->get_obj(0))->_value);
} }

View file

@ -21,6 +21,7 @@
* *
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <mpfr.h>
#include <math.h> #include <math.h>
extern "C" { extern "C" {
@ -37,6 +38,13 @@ using namespace std;
#include "stack.h" #include "stack.h"
// MPFR related constants
// 128 bits significand storing length in byters, result of mpfr_custom_get_size (128)
#define MPFR_DEF_FORMAT "%Rf"
#define MPFR_DEF_RND MPFR_RNDN
#define MPFR_128BITS_PREC 128
#define MPFR_128BITS_STORING_LENGTH 16
// //
static int g_verbose = 0; static int g_verbose = 0;
@ -81,13 +89,38 @@ const char* cmd_type_string[cmd_max] = {
"undef", "number", "binary", "string", "symbol", "program", "keyword", "keyword" "undef", "number", "binary", "string", "symbol", "program", "keyword", "keyword"
}; };
// // MPFR object
typedef long double floating_t; struct floating_t
{
__mpfr_struct mpfr;
char significand[MPFR_128BITS_STORING_LENGTH];
floating_t()
{
mpfr_custom_init(significand, MPFR_128BITS_STORING_LENGTH);
mpfr_custom_init_set(&mpfr, MPFR_NAN_KIND, 0, MPFR_128BITS_PREC, significand);
}
floating_t operator=(const long int val)
{
mpfr_custom_init(significand, MPFR_128BITS_STORING_LENGTH);
mpfr_custom_init_set(&mpfr, MPFR_ZERO_KIND, 0, MPFR_128BITS_PREC, significand);
mpfr_set_si(&mpfr, val, MPFR_DEF_RND);
}
operator int()
{
return (int)mpfr_get_si(&mpfr, MPFR_DEF_RND);
}
};
typedef long long integer_t; typedef long long integer_t;
class program; class program;
class object; class object;
class branch; class branch;
typedef void (program::*program_fn_t)(void); typedef void (program::*program_fn_t)(void);
typedef union typedef union
{ {
program_fn_t _fn; program_fn_t _fn;
@ -102,19 +135,34 @@ struct object
// //
void show(ostream& stream = cout); void show(ostream& stream = cout);
} __attribute__((packed)); };
struct number : public object struct number : public object
{ {
number() { _type = cmd_number; }
floating_t _value; floating_t _value;
// //
void set(floating_t value) void set(const floating_t& value)
{ {
_type = cmd_number; _type = cmd_number;
_value = value; _value.mpfr = value.mpfr;
(void)memcpy(_value.significand, value.significand, sizeof(_value.significand));
}
void set(long value)
{
_type = cmd_number;
_value = (long)value;
}
unsigned int size() { return (unsigned int)sizeof(floating_t); }
//
number operator=(const number& op)
{
number num;
num.set((const floating_t&)op._value);
return num;
} }
unsigned int size() { return sizeof(number); }
// representation mode // representation mode
typedef enum { typedef enum {
@ -128,7 +176,8 @@ struct number : public object
// precision // precision
static int s_default_precision; static int s_default_precision;
static int s_current_precision; static int s_current_precision;
} __attribute__((packed)); };
number::mode_enum number::s_default_mode = number::std; number::mode_enum number::s_default_mode = number::std;
number::mode_enum number::s_mode = number::s_default_mode; number::mode_enum number::s_mode = number::s_default_mode;
int number::s_default_precision = 12; int number::s_default_precision = 12;
@ -155,7 +204,7 @@ struct binary : public object
} binary_enum; } binary_enum;
static binary_enum s_default_mode; static binary_enum s_default_mode;
static binary_enum s_mode; static binary_enum s_mode;
} __attribute__((packed)); };
binary::binary_enum binary::s_default_mode = binary::dec; binary::binary_enum binary::s_default_mode = binary::dec;
binary::binary_enum binary::s_mode = binary::s_default_mode; binary::binary_enum binary::s_mode = binary::s_default_mode;
@ -180,7 +229,7 @@ struct ostring : public object
// //
unsigned int _len; unsigned int _len;
char _value[0]; char _value[0];
} __attribute__((packed)); };
struct oprogram : public object struct oprogram : public object
{ {
@ -203,7 +252,7 @@ struct oprogram : public object
// //
unsigned int _len; unsigned int _len;
char _value[0]; char _value[0];
} __attribute__((packed)); };
struct symbol : public object struct symbol : public object
{ {
@ -228,7 +277,7 @@ struct symbol : public object
bool _auto_eval; bool _auto_eval;
unsigned int _len; unsigned int _len;
char _value[0]; char _value[0];
} __attribute__((packed)); };
struct keyword : public object struct keyword : public object
{ {
@ -253,7 +302,7 @@ struct keyword : public object
program_fn_t _fn; program_fn_t _fn;
unsigned int _len; unsigned int _len;
char _value[0]; char _value[0];
} __attribute__((packed)); };
struct branch : public object struct branch : public object
{ {
@ -288,37 +337,43 @@ struct branch : public object
bool arg_bool; bool arg_bool;
unsigned int _len; unsigned int _len;
char _value[0]; char _value[0];
} __attribute__((packed)); };
void object::show(ostream& stream) void object::show(ostream& stream)
{ {
switch(_type) switch(_type)
{ {
case cmd_number: case cmd_number:
stream << ((number*)this)->_value; //TODO
//stream << ((number*)this)->_value;
stream<<"number._value.mpfr="<<&((number*)this)->_value.mpfr<<endl;
stream<<"number._value.mpfr._mpfr_d="<<(void*)((number*)this)->_value.mpfr._mpfr_d<<endl;
stream<<"number._value.significand="<<(void*)((number*)this)->_value.significand<<endl;
(void)mpfr_printf(MPFR_DEF_FORMAT, &((number*)this)->_value.mpfr);
break; break;
case cmd_binary: case cmd_binary:
{ {
cout << "# "; //TODO
switch(((binary*)this)->s_mode) //cout << "# ";
{ //switch(((binary*)this)->s_mode)
case binary::dec: stream<<std::right<<std::setw(8)<<std::dec<<((binary*)this)->_value<<" d"; break; //{
case binary::hex: stream<<std::right<<std::setw(8)<<std::hex<<((binary*)this)->_value<<" h"; break; // case binary::dec: stream<<std::right<<std::setw(8)<<std::dec<<((binary*)this)->_value<<" d"; break;
case binary::oct: stream<<std::right<<std::setw(8)<<std::oct<<((binary*)this)->_value<<" o"; break; // case binary::hex: stream<<std::right<<std::setw(8)<<std::hex<<((binary*)this)->_value<<" h"; break;
case binary::bin: // case binary::oct: stream<<std::right<<std::setw(8)<<std::oct<<((binary*)this)->_value<<" o"; break;
{ // case binary::bin:
string mybin; // {
for (int i = (int)(log((floating_t)((binary*)this)->_value) / log(2.)); i>=0; i--) // string mybin;
{ // for (int i = (int)(log((floating_t)((binary*)this)->_value) / log(2.)); i>=0; i--)
if (((binary*)this)->_value & (1 << i)) // {
mybin+='1'; // if (((binary*)this)->_value & (1 << i))
else // mybin+='1';
mybin+='0'; // else
} // mybin+='0';
stream<<std::right<<std::setw(20)<<std::oct<<mybin<<" b"; // }
} // stream<<std::right<<std::setw(20)<<std::oct<<mybin<<" b";
break; // }
} // break;
//}
} }
break; break;
case cmd_string: case cmd_string:

View file

@ -44,6 +44,7 @@ public:
_base = (char*)realloc(_base, _total_size); _base = (char*)realloc(_base, _total_size);
} }
cout<<"current = "<<(void*)_current<<", index is "<<_count<<endl;
if (!dont_copy) if (!dont_copy)
memcpy(_current, obj, size); memcpy(_current, obj, size);
_vlen.push_back(size); _vlen.push_back(size);