Mercurial > hg > octave-lyh
changeset 15062:069c552587a0 classdef
merge source reorganization changes on default to classdef
* pt-classdef.h, pt-classdef.cc, pt-funcall.h, pt-funcall.cc: Move to
src/parse-tree subdirectory.
* ov-classdef.h, ov-classdef.cc: Move to src/octave-value
subdirectory.
* parse-tree/module.mk, octave-value/module.mk: Update file lists.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 31 Jul 2012 09:54:19 -0400 |
parents | 9aab13f6697d (current diff) 46b19589b593 (diff) |
children | 959953dba519 |
files | src/Makefile.am src/OPERATORS/module.mk src/OPERATORS/op-b-b.cc src/OPERATORS/op-b-bm.cc src/OPERATORS/op-b-sbm.cc src/OPERATORS/op-bm-b.cc src/OPERATORS/op-bm-bm.cc src/OPERATORS/op-bm-sbm.cc src/OPERATORS/op-cdm-cdm.cc src/OPERATORS/op-cdm-cm.cc src/OPERATORS/op-cdm-cs.cc src/OPERATORS/op-cdm-dm.cc src/OPERATORS/op-cdm-m.cc src/OPERATORS/op-cdm-s.cc src/OPERATORS/op-cell.cc src/OPERATORS/op-chm.cc src/OPERATORS/op-class.cc src/OPERATORS/op-cm-cdm.cc src/OPERATORS/op-cm-cm.cc src/OPERATORS/op-cm-cs.cc src/OPERATORS/op-cm-dm.cc src/OPERATORS/op-cm-m.cc src/OPERATORS/op-cm-pm.cc src/OPERATORS/op-cm-s.cc src/OPERATORS/op-cm-scm.cc src/OPERATORS/op-cm-sm.cc src/OPERATORS/op-cs-cm.cc src/OPERATORS/op-cs-cs.cc src/OPERATORS/op-cs-m.cc src/OPERATORS/op-cs-s.cc src/OPERATORS/op-cs-scm.cc src/OPERATORS/op-cs-sm.cc src/OPERATORS/op-dm-cdm.cc src/OPERATORS/op-dm-cm.cc src/OPERATORS/op-dm-cs.cc src/OPERATORS/op-dm-dm.cc src/OPERATORS/op-dm-m.cc src/OPERATORS/op-dm-s.cc src/OPERATORS/op-dm-scm.cc src/OPERATORS/op-dm-sm.cc src/OPERATORS/op-dm-template.cc src/OPERATORS/op-dms-template.cc src/OPERATORS/op-double-conv.cc src/OPERATORS/op-fcdm-fcdm.cc src/OPERATORS/op-fcdm-fcm.cc src/OPERATORS/op-fcdm-fcs.cc src/OPERATORS/op-fcdm-fdm.cc src/OPERATORS/op-fcdm-fm.cc src/OPERATORS/op-fcdm-fs.cc src/OPERATORS/op-fcm-fcdm.cc src/OPERATORS/op-fcm-fcm.cc src/OPERATORS/op-fcm-fcs.cc src/OPERATORS/op-fcm-fdm.cc src/OPERATORS/op-fcm-fm.cc src/OPERATORS/op-fcm-fs.cc src/OPERATORS/op-fcm-pm.cc src/OPERATORS/op-fcn.cc src/OPERATORS/op-fcs-fcm.cc src/OPERATORS/op-fcs-fcs.cc src/OPERATORS/op-fcs-fm.cc src/OPERATORS/op-fcs-fs.cc src/OPERATORS/op-fdm-fcdm.cc src/OPERATORS/op-fdm-fcm.cc src/OPERATORS/op-fdm-fcs.cc src/OPERATORS/op-fdm-fdm.cc src/OPERATORS/op-fdm-fm.cc src/OPERATORS/op-fdm-fs.cc src/OPERATORS/op-float-conv.cc src/OPERATORS/op-fm-fcdm.cc src/OPERATORS/op-fm-fcm.cc src/OPERATORS/op-fm-fcs.cc src/OPERATORS/op-fm-fdm.cc src/OPERATORS/op-fm-fm.cc src/OPERATORS/op-fm-fs.cc src/OPERATORS/op-fm-pm.cc src/OPERATORS/op-fs-fcm.cc src/OPERATORS/op-fs-fcs.cc src/OPERATORS/op-fs-fm.cc src/OPERATORS/op-fs-fs.cc src/OPERATORS/op-i16-i16.cc src/OPERATORS/op-i32-i32.cc src/OPERATORS/op-i64-i64.cc src/OPERATORS/op-i8-i8.cc src/OPERATORS/op-int-concat.cc src/OPERATORS/op-int-conv.cc src/OPERATORS/op-int.h src/OPERATORS/op-m-cdm.cc src/OPERATORS/op-m-cm.cc src/OPERATORS/op-m-cs.cc src/OPERATORS/op-m-dm.cc src/OPERATORS/op-m-m.cc src/OPERATORS/op-m-pm.cc src/OPERATORS/op-m-s.cc src/OPERATORS/op-m-scm.cc src/OPERATORS/op-m-sm.cc src/OPERATORS/op-pm-cm.cc src/OPERATORS/op-pm-fcm.cc src/OPERATORS/op-pm-fm.cc src/OPERATORS/op-pm-m.cc src/OPERATORS/op-pm-pm.cc src/OPERATORS/op-pm-scm.cc src/OPERATORS/op-pm-sm.cc src/OPERATORS/op-pm-template.cc src/OPERATORS/op-range.cc src/OPERATORS/op-s-cm.cc src/OPERATORS/op-s-cs.cc src/OPERATORS/op-s-m.cc src/OPERATORS/op-s-s.cc src/OPERATORS/op-s-scm.cc src/OPERATORS/op-s-sm.cc src/OPERATORS/op-sbm-b.cc src/OPERATORS/op-sbm-bm.cc src/OPERATORS/op-sbm-sbm.cc src/OPERATORS/op-scm-cm.cc src/OPERATORS/op-scm-cs.cc src/OPERATORS/op-scm-m.cc src/OPERATORS/op-scm-s.cc src/OPERATORS/op-scm-scm.cc src/OPERATORS/op-scm-sm.cc src/OPERATORS/op-sm-cm.cc src/OPERATORS/op-sm-cs.cc src/OPERATORS/op-sm-m.cc src/OPERATORS/op-sm-s.cc src/OPERATORS/op-sm-scm.cc src/OPERATORS/op-sm-sm.cc src/OPERATORS/op-str-m.cc src/OPERATORS/op-str-s.cc src/OPERATORS/op-str-str.cc src/OPERATORS/op-struct.cc src/OPERATORS/op-ui16-ui16.cc src/OPERATORS/op-ui32-ui32.cc src/OPERATORS/op-ui64-ui64.cc src/OPERATORS/op-ui8-ui8.cc src/TEMPLATE-INST/Array-jit.cc src/TEMPLATE-INST/Array-os.cc src/TEMPLATE-INST/Array-sym.cc src/TEMPLATE-INST/Array-tc.cc src/TEMPLATE-INST/module.mk src/octave-value/module.mk src/octave-value/ov-classdef.cc src/octave-value/ov-classdef.h src/octave-value/ov.cc src/ov-base-diag.cc src/ov-base-diag.h src/ov-base-int.cc src/ov-base-int.h src/ov-base-mat.cc src/ov-base-mat.h src/ov-base-scalar.cc src/ov-base-scalar.h src/ov-base-sparse.cc src/ov-base-sparse.h src/ov-base.cc src/ov-base.h src/ov-bool-mat.cc src/ov-bool-mat.h src/ov-bool-sparse.cc src/ov-bool-sparse.h src/ov-bool.cc src/ov-bool.h src/ov-builtin.cc src/ov-builtin.h src/ov-cell.cc src/ov-cell.h src/ov-ch-mat.cc src/ov-ch-mat.h src/ov-class.cc src/ov-class.h src/ov-classdef.cc src/ov-classdef.h src/ov-colon.cc src/ov-colon.h src/ov-complex.cc src/ov-complex.h src/ov-cs-list.cc src/ov-cs-list.h src/ov-cx-diag.cc src/ov-cx-diag.h src/ov-cx-mat.cc src/ov-cx-mat.h src/ov-cx-sparse.cc src/ov-cx-sparse.h src/ov-dld-fcn.cc src/ov-dld-fcn.h src/ov-fcn-handle.cc src/ov-fcn-handle.h src/ov-fcn-inline.cc src/ov-fcn-inline.h src/ov-fcn.cc src/ov-fcn.h src/ov-float.cc src/ov-float.h src/ov-flt-complex.cc src/ov-flt-complex.h src/ov-flt-cx-diag.cc src/ov-flt-cx-diag.h src/ov-flt-cx-mat.cc src/ov-flt-cx-mat.h src/ov-flt-re-diag.cc src/ov-flt-re-diag.h src/ov-flt-re-mat.cc src/ov-flt-re-mat.h src/ov-int-traits.h src/ov-int16.cc src/ov-int16.h src/ov-int32.cc src/ov-int32.h src/ov-int64.cc src/ov-int64.h src/ov-int8.cc src/ov-int8.h src/ov-intx.h src/ov-lazy-idx.cc src/ov-lazy-idx.h src/ov-mex-fcn.cc src/ov-mex-fcn.h src/ov-null-mat.cc src/ov-null-mat.h src/ov-oncleanup.cc src/ov-oncleanup.h src/ov-perm.cc src/ov-perm.h src/ov-range.cc src/ov-range.h src/ov-re-diag.cc src/ov-re-diag.h src/ov-re-mat.cc src/ov-re-mat.h src/ov-re-sparse.cc src/ov-re-sparse.h src/ov-scalar.cc src/ov-scalar.h src/ov-str-mat.cc src/ov-str-mat.h src/ov-struct.cc src/ov-struct.h src/ov-type-conv.h src/ov-typeinfo.cc src/ov-typeinfo.h src/ov-uint16.cc src/ov-uint16.h src/ov-uint32.cc src/ov-uint32.h src/ov-uint64.cc src/ov-uint64.h src/ov-uint8.cc src/ov-uint8.h src/ov-usr-fcn.cc src/ov-usr-fcn.h src/ov.cc src/ov.h src/parse-tree/module.mk src/parse-tree/pt-all.h src/parse-tree/pt-bp.cc src/parse-tree/pt-bp.h src/parse-tree/pt-check.cc src/parse-tree/pt-check.h src/parse-tree/pt-classdef.cc src/parse-tree/pt-classdef.h src/parse-tree/pt-eval.cc src/parse-tree/pt-eval.h src/parse-tree/pt-funcall.cc src/parse-tree/pt-funcall.h src/parse-tree/pt-id.h src/parse-tree/pt-pr-code.cc src/parse-tree/pt-pr-code.h src/parse-tree/pt-walk.h src/pt-all.h src/pt-arg-list.cc src/pt-arg-list.h src/pt-assign.cc src/pt-assign.h src/pt-binop.cc src/pt-binop.h src/pt-bp.cc src/pt-bp.h src/pt-cbinop.cc src/pt-cbinop.h src/pt-cell.cc src/pt-cell.h src/pt-check.cc src/pt-check.h src/pt-classdef.cc src/pt-classdef.h src/pt-cmd.cc src/pt-cmd.h src/pt-colon.cc src/pt-colon.h src/pt-const.cc src/pt-const.h src/pt-decl.cc src/pt-decl.h src/pt-eval.cc src/pt-eval.h src/pt-except.cc src/pt-except.h src/pt-exp.cc src/pt-exp.h src/pt-fcn-handle.cc src/pt-fcn-handle.h src/pt-funcall.cc src/pt-funcall.h src/pt-id.cc src/pt-id.h src/pt-idx.cc src/pt-idx.h src/pt-jump.cc src/pt-jump.h src/pt-loop.cc src/pt-loop.h src/pt-mat.cc src/pt-mat.h src/pt-misc.cc src/pt-misc.h src/pt-pr-code.cc src/pt-pr-code.h src/pt-select.cc src/pt-select.h src/pt-stmt.cc src/pt-stmt.h src/pt-unop.cc src/pt-unop.h src/pt-walk.h src/pt.cc src/pt.h |
diffstat | 323 files changed, 649 insertions(+), 356 deletions(-) [+] |
line wrap: on
line diff
--- a/build-aux/bootstrap.conf +++ b/build-aux/bootstrap.conf @@ -18,6 +18,7 @@ # gnulib modules used by this package. gnulib_modules=" + base64 c-strcase copysign copysignf @@ -60,7 +61,6 @@ signal sigprocmask sleep - sleep stat stdint stdio
--- a/configure.ac +++ b/configure.ac @@ -900,12 +900,17 @@ AC_LANG_PUSH(C++) AC_CHECK_HEADER([Magick++.h], [ AC_MSG_CHECKING([for Magick::ColorRGB in Magick++.h]) - AC_TRY_LINK([#include <Magick++.h>], [Magick::ColorRGB c;], [ - AC_MSG_RESULT(yes) - warn_magick= - ], [ - AC_MSG_RESULT(no) - ]) + AC_PREPROC_IFELSE( + [AC_LANG_SOURCE( + [[#include <Magick++.h>]], + [[Magick::ColorRGB c;]]) + ], [ + AC_MSG_RESULT(yes) + warn_magick= + ], [ + AC_MSG_RESULT(no) + ] + ) ]) AC_LANG_POP(C++) CPPFLAGS="$save_CPPFLAGS"
--- a/doc/interpreter/install.txi +++ b/doc/interpreter/install.txi @@ -250,6 +250,11 @@ (@url{http://www.hdfgroup.org/HDF5}). HDF5 is required for Octave's @code{load} and @code{save} commands to read and write HDF data files. +@item LLVM +Compiler framework, (@url{http://www.llvm.org}). LLVM is required for +Octave's experimental just-in-time (JIT) compilation for speeding up the +interpreter. + @item OpenGL API for portable 2-D and 3-D graphics (@url{http://www.opengl.org}). An OpenGL implementation is required to provide Octave's OpenGL-based
--- a/liboctave/sparse-dmsolve.cc +++ b/liboctave/sparse-dmsolve.cc @@ -33,6 +33,7 @@ #include "MatrixType.h" #include "oct-sort.h" #include "oct-locbuf.h" +#include "oct-inttypes.h" template <class T> static MSparse<T> @@ -42,9 +43,17 @@ octave_idx_type cend, octave_idx_type maxnz = -1, bool lazy = false) { - octave_idx_type nz = (rend - rst) * (cend - cst); + octave_idx_type nr = rend - rst, nc = cend - cst; maxnz = (maxnz < 0 ? A.nnz () : maxnz); - MSparse<T> B (rend - rst, cend - cst, (nz < maxnz ? nz : maxnz)); + octave_idx_type nz; + + // Cast to uint64 to handle overflow in this multiplication + if (octave_uint64 (nr)*octave_uint64 (nc) < octave_uint64 (maxnz)) + nz = nr*nc; + else + nz = maxnz; + + MSparse<T> B (nr, nc, (nz < maxnz ? nz : maxnz)); // Some sparse functions can support lazy indexing (where elements // in the row are in no particular order), even though octave in // general can't. For those functions that can using it is a big
--- a/scripts/help/unimplemented.m +++ b/scripts/help/unimplemented.m @@ -38,7 +38,7 @@ txt = ["quad2d is not implemented. Consider using dblquad."]; case "gsvd" - txt = ["gsvd is not currently part of core Octave. See the ", + txt = ["gsvd is not currently part of core Octave. See the ",... "linear-algebra package at @url{http://octave.sf.net/linear-algebra/}."]; case "linprog"
--- a/src/DLD-FUNCTIONS/module-files +++ b/src/DLD-FUNCTIONS/module-files @@ -1,5 +1,4 @@ # FILE|CPPFLAGS|LDFLAGS|LIBRARIES -chol.cc __delaunayn__.cc|$(QHULL_CPPFLAGS)|$(QHULL_LDFLAGS)|$(QHULL_LIBS) __dsearchn__.cc __fltk_uigetfile__.cc|$(GRAPHICS_CFLAGS) $(FT2_CPPFLAGS)|$(GRAPHICS_LDFLAGS) $(FT2_LDFLAGS)|$(GRAPHICS_LIBS) $(FT2_LIBS) @@ -10,6 +9,7 @@ __voronoi__.cc|$(QHULL_CPPFLAGS)|$(QHULL_LDFLAGS)|$(QHULL_LIBS) amd.cc|$(SPARSE_XCPPFLAGS)|$(SPARSE_XLDFLAGS)|$(SPARSE_XLIBS) ccolamd.cc|$(SPARSE_XCPPFLAGS)|$(SPARSE_XLDFLAGS)|$(SPARSE_XLIBS) +chol.cc colamd.cc|$(SPARSE_XCPPFLAGS)|$(SPARSE_XLDFLAGS)|$(SPARSE_XLIBS) convhulln.cc|$(QHULL_CPPFLAGS)|$(QHULL_LDFLAGS)|$(QHULL_LIBS) dmperm.cc|$(SPARSE_XCPPFLAGS)|$(SPARSE_XLDFLAGS)|$(SPARSE_XLIBS)
--- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,6 +25,8 @@ -I../libgnu -I$(top_srcdir)/libgnu \ -I$(top_srcdir)/libcruft/misc \ -I../liboctave -I$(top_srcdir)/liboctave \ + -Ioctave-value -I$(srcdir)/octave-value \ + -Iparse-tree -I$(srcdir)/parse-tree \ -Icorefcn -I$(srcdir)/corefcn \ -I. -I$(srcdir) \ @CPPFLAGS@ @@ -135,106 +137,6 @@ ../liboctave/LSODE-opts.h \ ../liboctave/Quad-opts.h -OV_INTTYPE_INC = \ - ov-base-int.h \ - ov-base-int.cc \ - ov-int-traits.h \ - ov-int16.h \ - ov-int32.h \ - ov-int64.h \ - ov-int8.h \ - ov-intx.h \ - ov-uint16.h \ - ov-uint32.h \ - ov-uint64.h \ - ov-uint8.h - -OV_INCLUDES = \ - ov-base-diag.h \ - ov-base-diag.cc \ - ov-base-mat.h \ - ov-base-mat.cc \ - ov-base-scalar.h \ - ov-base-scalar.cc \ - ov-base.h \ - ov-bool-mat.h \ - ov-bool-mat.cc \ - ov-bool.h \ - ov-builtin.h \ - ov-cell.h \ - ov-ch-mat.h \ - ov-class.h \ - ov-classdef.h \ - ov-colon.h \ - ov-complex.h \ - ov-cs-list.h \ - ov-cx-diag.h \ - ov-cx-mat.h \ - ov-dld-fcn.h \ - ov-fcn-handle.h \ - ov-fcn-inline.h \ - ov-fcn.h \ - ov-float.h \ - ov-flt-complex.h \ - ov-flt-cx-diag.h \ - ov-flt-cx-mat.h \ - ov-flt-re-diag.h \ - ov-flt-re-mat.h \ - ov-lazy-idx.h \ - ov-mex-fcn.h \ - ov-null-mat.h \ - ov-oncleanup.h \ - ov-perm.h \ - ov-range.h \ - ov-re-diag.h \ - ov-re-mat.h \ - ov-scalar.h \ - ov-str-mat.h \ - ov-struct.h \ - ov-type-conv.h \ - ov-typeinfo.h \ - ov-usr-fcn.h \ - ov.h \ - $(OV_INTTYPE_INC) - -OV_SPARSE_INCLUDES = \ - ov-base-sparse.h \ - ov-bool-sparse.h \ - ov-cx-sparse.h \ - ov-re-sparse.h - -PT_INCLUDES = \ - pt-all.h \ - pt-arg-list.h \ - pt-assign.h \ - pt-binop.h \ - pt-bp.h \ - pt-cbinop.h \ - pt-cell.h \ - pt-check.h \ - pt-classdef.h \ - pt-cmd.h \ - pt-colon.h \ - pt-const.h \ - pt-decl.h \ - pt-eval.h \ - pt-except.h \ - pt-exp.h \ - pt-fcn-handle.h \ - pt-funcall.h \ - pt-id.h \ - pt-idx.h \ - pt-jump.h \ - pt-loop.h \ - pt-mat.h \ - pt-misc.h \ - pt-pr-code.h \ - pt-select.h \ - pt-stmt.h \ - pt-unop.h \ - pt-walk.h \ - pt.h - JIT_INCLUDES = \ jit-util.h \ jit-typeinfo.h \ @@ -329,103 +231,12 @@ mxarray.h \ version.h -OV_INTTYPE_SRC = \ - ov-int16.cc \ - ov-int32.cc \ - ov-int64.cc \ - ov-int8.cc \ - ov-uint16.cc \ - ov-uint32.cc \ - ov-uint64.cc \ - ov-uint8.cc - -OV_SPARSE_SRC = \ - ov-base-sparse.cc \ - ov-bool-sparse.cc \ - ov-cx-sparse.cc \ - ov-re-sparse.cc - -OV_SRC = \ - ov-base.cc \ - ov-bool-mat.cc \ - ov-bool.cc \ - ov-builtin.cc \ - ov-cell.cc \ - ov-ch-mat.cc \ - ov-class.cc \ - ov-classdef.cc \ - ov-colon.cc \ - ov-complex.cc \ - ov-cs-list.cc \ - ov-cx-diag.cc \ - ov-cx-mat.cc \ - ov-dld-fcn.cc \ - ov-fcn-handle.cc \ - ov-fcn-inline.cc \ - ov-fcn.cc \ - ov-float.cc \ - ov-flt-complex.cc \ - ov-flt-cx-diag.cc \ - ov-flt-cx-mat.cc \ - ov-flt-re-diag.cc \ - ov-flt-re-mat.cc \ - ov-lazy-idx.cc \ - ov-mex-fcn.cc \ - ov-null-mat.cc \ - ov-oncleanup.cc \ - ov-perm.cc \ - ov-range.cc \ - ov-re-diag.cc \ - ov-re-mat.cc \ - ov-scalar.cc \ - ov-str-mat.cc \ - ov-struct.cc \ - ov-typeinfo.cc \ - ov-usr-fcn.cc \ - ov.cc \ - $(OV_INTTYPE_SRC) \ - $(OV_SPARSE_SRC) - -PT_SRC = \ - pt-arg-list.cc \ - pt-assign.cc \ - pt-binop.cc \ - pt-bp.cc \ - pt-cbinop.cc \ - pt-cell.cc \ - pt-check.cc \ - pt-cmd.cc \ - pt-classdef.cc \ - pt-colon.cc \ - pt-const.cc \ - pt-decl.cc \ - pt-eval.cc \ - pt-except.cc \ - pt-exp.cc \ - pt-fcn-handle.cc \ - pt-funcall.cc \ - pt-id.cc \ - pt-idx.cc \ - pt-jump.cc \ - pt-loop.cc \ - pt-mat.cc \ - pt-misc.cc \ - pt-pr-code.cc \ - pt-select.cc \ - pt-stmt.cc \ - pt-unop.cc \ - pt.cc - JIT_SRC = \ jit-util.cc \ jit-typeinfo.cc \ jit-ir.cc \ pt-jit.cc -#noinst_LTLIBRARIES = -# -#include corefcn/module.mk -# DIST_SRC = \ Cell.cc \ bitfcns.cc \ @@ -497,22 +308,23 @@ xnorm.cc \ xpow.cc \ zfstream.cc \ - $(corefcn_SRC) \ - $(OV_SRC) \ - $(PT_SRC) \ + $(COREFCN_SRC) \ + $(OCTAVE_VALUE_SRC) \ + $(PARSE_TREE_SRC) \ $(JIT_SRC) noinst_LTLIBRARIES = +include parse-tree/module.mk +include octave-value/module.mk +include operators/module.mk +include template-inst/module.mk include corefcn/module.mk include DLD-FUNCTIONS/module.mk $(srcdir)/DLD-FUNCTIONS/module.mk: $(srcdir)/DLD-FUNCTIONS/config-module.sh $(srcdir)/DLD-FUNCTIONS/config-module.awk $(srcdir)/DLD-FUNCTIONS/module-files $(srcdir)/DLD-FUNCTIONS/config-module.sh $(top_srcdir) -include OPERATORS/module.mk -include TEMPLATE-INST/module.mk - if AMCOND_ENABLE_DYNAMIC_LINKING OCT_FILES = $(DLD_FUNCTIONS_LIBS:.la=.oct) OCT_STAMP_FILES = $(subst DLD-FUNCTIONS/,DLD-FUNCTIONS/$(am__leading_dot),$(DLD_FUNCTIONS_LIBS:.la=.oct-stamp))
--- a/src/corefcn/module.mk +++ b/src/corefcn/module.mk @@ -1,7 +1,7 @@ EXTRA_DIST += \ corefcn/module.mk -corefcn_SRC = \ +COREFCN_SRC = \ corefcn/__contourc__.cc \ corefcn/__dispatch__.cc \ corefcn/__lin_interpn__.cc \ @@ -66,5 +66,5 @@ noinst_LTLIBRARIES += corefcn/libcorefcn.la -corefcn_libcorefcn_la_SOURCES = $(corefcn_SRC) +corefcn_libcorefcn_la_SOURCES = $(COREFCN_SRC)
--- a/src/data.cc +++ b/src/data.cc @@ -3,6 +3,7 @@ Copyright (C) 1994-2012 John W. Eaton Copyright (C) 2009 Jaroslav Hajek Copyright (C) 2009-2010 VZLU Prague +Copyright (C) 2012 Carlo de Falco This file is part of Octave. @@ -37,6 +38,10 @@ #include <ctime> #include <string> +extern "C" +{ +#include <base64.h> +} #include "lo-ieee.h" #include "lo-math.h" @@ -7227,3 +7232,139 @@ return retval; } + +DEFUN (base64_encode, args, , "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {@var{s} =} base64_encode (@var{x})\n\ +Encode a double matrix or array @var{x} into the base64 format string\n\ +@var{s}.\n\ +\n\ +@strong{Warning:} Encoding different numeric types, such as single or\n\ +integer, is not currently supported. Any non-double input will be converted\n\ +to type double before encoding.\n\ +@seealso{base64_decode}\n\ +@end deftypefn") +{ + octave_value_list retval; + + int nargin = args.length (); + + if (nargin != 1) + print_usage (); + else + { + const Array<double> in = args(0).array_value (); + if (! error_state) + { + const char* inc = reinterpret_cast<const char*> (in.data ()); + size_t inlen = in.numel () * sizeof (double) / sizeof (char); + char* out; + size_t outlen = base64_encode_alloc (inc, inlen, &out); + + if (! out && outlen == 0 && inlen != 0) + error ("base64_encode: input array too large"); + else if (! out) + error ("base64_encode: memory allocation error"); + else + retval(0) = octave_value (out); + } + } + + return retval; +} + +/* +%!assert (base64_encode (single (pi)), "AAAAYPshCUA=") +%!assert (base64_encode (uint8 (pi)), base64_encode (double (uint8 (pi)))) + +%!error base64_encode () +%!error base64_encode (1,2) +%!error base64_encode ("A string") +*/ + +DEFUN (base64_decode, args, , "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {@var{x} =} base64_decode (@var{s})\n\ +@deftypefnx {Built-in Function} {@var{x} =} base64_decode (@var{s}, @var{dims})\n\ +Decode the double matrix or array @var{x} from the base64 format string\n\ +@var{s}. The optional input parameter @var{dims} should be a vector\n\ +containing the dimensions of the decoded array.\n\ +@seealso{base64_encode}\n\ +@end deftypefn") +{ + octave_value_list retval; + + int nargin = args.length (); + + if (nargin < 1 || nargin > 2) + print_usage (); + else + { + dim_vector new_dims; + Array<double> res; + + if (nargin > 1) + { + const Array<octave_idx_type> new_size = + args(1).octave_idx_type_vector_value (); + if (! error_state) + { + new_dims = dim_vector::alloc (new_size.length ()); + for (octave_idx_type i = 0; i < new_size.length (); i++) + new_dims(i) = new_size(i); + } + } + + const std::string in = args(0).string_value (); + + if (! error_state) + { + const char *inc = &(in[0]); + char *out; + size_t inlen = in.length (), outlen; + + bool ok = base64_decode_alloc (inc, inlen, &out, &outlen); + + if (! ok) + error ("base64_decode: input was not valid base64"); + else if (! out) + error ("base64_decode: memory allocation error"); + else + { + if ((outlen % (sizeof (double) / sizeof (char))) != 0) + error ("base64_decode: incorrect input size"); + else + { + octave_idx_type l; + l = (outlen * sizeof (char)) / sizeof (double); + res.resize1 (l); + double *dout = reinterpret_cast<double*> (out); + std::copy (dout, dout + l, res.fortran_vec ()); + + if (nargin > 1) + retval(0) = octave_value (res).reshape (new_dims); + else + retval(0) = octave_value (res); + } + } + } + } + + return retval; +} + +/* +%!assert (base64_decode (base64_encode (pi)), pi) +%! +%!test +%! in = randn (10); +%! outv = base64_decode (base64_encode (in)); +%! outm = base64_decode (base64_encode (in), size (in)); +%! assert (outv, in(:).'); +%! assert (outm, in); + +%!error base64_decode () +%!error base64_decode (1,2,3) +%!error base64_decode (1, "this is not a valid set of dimensions") +%!error <input was not valid base64> base64_decode (1) +%!error <input was not valid base64> base64_decode ("AQ=") +%!error <incorrect input size> base64_decode ("AQ==") +*/
--- a/src/jit-ir.cc +++ b/src/jit-ir.cc @@ -598,4 +598,36 @@ return false; } +// -------------------- jit_magic_end -------------------- +const jit_function& +jit_magic_end::overload () const +{ + jit_value *ctx = resolve_context (); + if (ctx) + return jit_typeinfo::end (ctx->type ()); + + static jit_function null_ret; + return null_ret; +} + +jit_value * +jit_magic_end::resolve_context (void) const +{ + // FIXME: We need to have a way of marking functions so we can skip them here + return argument_count () ? argument (0) : 0; +} + +bool +jit_magic_end::infer (void) +{ + jit_type *new_type = overload ().result (); + if (new_type != type ()) + { + stash_type (new_type); + return true; + } + + return false; +} + #endif
--- a/src/jit-ir.h +++ b/src/jit-ir.h @@ -46,7 +46,8 @@ JIT_METH(variable); \ JIT_METH(error_check); \ JIT_METH(assign) \ - JIT_METH(argument) + JIT_METH(argument) \ + JIT_METH(magic_end) #define JIT_VISIT_IR_CONST \ JIT_METH(const_bool); \ @@ -256,6 +257,14 @@ #undef STASH_ARG #undef JIT_INSTRUCTION_CTOR + jit_instruction (const std::vector<jit_value *>& aarguments) + : already_infered (aarguments.size ()), marguments (aarguments.size ()), + mid (next_id ()), mparent (0) + { + for (size_t i = 0; i < aarguments.size (); ++i) + stash_argument (i, aarguments[i]); + } + static void reset_ids (void) { next_id (true); @@ -1137,6 +1146,34 @@ } }; +// for now only handles the 1D case +class +jit_magic_end : public jit_instruction +{ +public: + jit_magic_end (const std::vector<jit_value *>& context) + : jit_instruction (context) + {} + + const jit_function& overload () const; + + jit_value *resolve_context (void) const; + + virtual bool infer (void); + + virtual std::ostream& short_print (std::ostream& os) const + { + return os << "magic_end"; + } + + virtual std::ostream& print (std::ostream& os, size_t indent = 0) const + { + return short_print (print_indent (os, indent)); + } + + JIT_VALUE_ACCEPT; +}; + class jit_extract_argument : public jit_assign_base {
--- a/src/jit-typeinfo.cc +++ b/src/jit-typeinfo.cc @@ -522,8 +522,10 @@ jit_function::call (llvm::IRBuilderD& builder, const std::vector<jit_value *>& in_args) const { + if (! valid ()) + throw jit_fail_exception ("Call not implemented"); + assert (in_args.size () == args.size ()); - std::vector<llvm::Value *> llvm_args (args.size ()); for (size_t i = 0; i < in_args.size (); ++i) llvm_args[i] = in_args[i]->to_llvm (); @@ -535,7 +537,9 @@ jit_function::call (llvm::IRBuilderD& builder, const std::vector<llvm::Value *>& in_args) const { - assert (valid ()); + if (! valid ()) + throw jit_fail_exception ("Call not implemented"); + assert (in_args.size () == args.size ()); llvm::Function *stacksave = llvm::Intrinsic::getDeclaration (module, llvm::Intrinsic::stacksave); @@ -1342,8 +1346,7 @@ builder.CreateBr (done); builder.SetInsertPoint (normal); - llvm::Value *len = builder.CreateExtractValue (mat, - llvm::ArrayRef<unsigned> (2)); + llvm::Value *len = builder.CreateExtractValue (mat, 2); cond0 = builder.CreateICmpSGT (int_idx, len); llvm::Value *rcount = builder.CreateExtractValue (mat, 0); @@ -1386,6 +1389,18 @@ fn.mark_can_error (); paren_subsasgn_fn.add_overload (fn); + end_fn.stash_name ("end"); + fn = create_function (jit_convention::internal, "octave_jit_end_matrix", + scalar, matrix); + body = fn.new_block (); + builder.SetInsertPoint (body); + { + llvm::Value *mat = fn.argument (builder, 0); + llvm::Value *ret = builder.CreateExtractValue (mat, 2); + fn.do_return (builder, builder.CreateSIToFP (ret, scalar_t)); + } + end_fn.add_overload (fn); + casts[any->type_id ()].stash_name ("(any)"); casts[scalar->type_id ()].stash_name ("(scalar)"); casts[complex->type_id ()].stash_name ("(complex)");
--- a/src/jit-typeinfo.h +++ b/src/jit-typeinfo.h @@ -471,6 +471,16 @@ { return instance->do_insert_error_check (bld); } + + static const jit_operation& end (void) + { + return instance->end_fn; + } + + static const jit_function& end (jit_type *ty) + { + return instance->end_fn.overload (ty); + } private: jit_typeinfo (llvm::Module *m, llvm::ExecutionEngine *e); @@ -655,6 +665,7 @@ jit_operation make_range_fn; jit_operation paren_subsref_fn; jit_operation paren_subsasgn_fn; + jit_operation end_fn; // type id -> cast function TO that type std::vector<jit_operation> casts;
--- a/src/link-deps.mk +++ b/src/link-deps.mk @@ -16,7 +16,8 @@ $(OPENGL_LIBS) \ $(X11_LIBS) \ $(CARBON_LIBS) \ - $(LLVM_LIBS) + $(LLVM_LIBS) \ + $(LAPACK_LIBS) LIBOCTINTERP_LINK_OPTS = \ $(GRAPHICS_LDFLAGS) \
--- a/src/mkops +++ b/src/mkops @@ -21,7 +21,7 @@ SED=${SED:-'sed'} cat << \EOF -// DO NOT EDIT! Generated automatically by mkbuiltins. +// DO NOT EDIT! Generated automatically by mkops. #ifdef HAVE_CONFIG_H #include "config.h" @@ -32,7 +32,7 @@ EOF for file in "$@"; do - f=`echo $file | $SED 's,^\./,,; s%^OPERATORS/op-%%; s%\.cc%%; s%-%_%g'` + f=`echo $file | $SED 's,^\./,,; s%^operators/op-%%; s%\.cc%%; s%-%_%g'` echo "extern void install_${f}_ops (void);" done @@ -46,7 +46,7 @@ EOF for file in "$@"; do - f=`echo $file | $SED 's,^\./,,; s%^OPERATORS/op-%%; s%\.cc%%; s%-%_%g'` + f=`echo $file | $SED 's,^\./,,; s%^operators/op-%%; s%\.cc%%; s%-%_%g'` echo " install_${f}_ops ();" done
new file mode 100644 --- /dev/null +++ b/src/octave-value/module.mk @@ -0,0 +1,128 @@ +EXTRA_DIST += \ + octave-value/module.mk + +OV_INTTYPE_INCLUDES = \ + octave-value/ov-base-int.h \ + octave-value/ov-base-int.cc \ + octave-value/ov-int-traits.h \ + octave-value/ov-int16.h \ + octave-value/ov-int32.h \ + octave-value/ov-int64.h \ + octave-value/ov-int8.h \ + octave-value/ov-intx.h \ + octave-value/ov-uint16.h \ + octave-value/ov-uint32.h \ + octave-value/ov-uint64.h \ + octave-value/ov-uint8.h + +OV_SPARSE_INCLUDES = \ + octave-value/ov-base-sparse.h \ + octave-value/ov-bool-sparse.h \ + octave-value/ov-cx-sparse.h \ + octave-value/ov-re-sparse.h + +OV_INCLUDES = \ + octave-value/ov-base-diag.h \ + octave-value/ov-base-diag.cc \ + octave-value/ov-base-mat.h \ + octave-value/ov-base-mat.cc \ + octave-value/ov-base-scalar.h \ + octave-value/ov-base-scalar.cc \ + octave-value/ov-base.h \ + octave-value/ov-bool-mat.h \ + octave-value/ov-bool-mat.cc \ + octave-value/ov-bool.h \ + octave-value/ov-builtin.h \ + octave-value/ov-cell.h \ + octave-value/ov-ch-mat.h \ + octave-value/ov-class.h \ + octave-value/ov-classdef.h \ + octave-value/ov-colon.h \ + octave-value/ov-complex.h \ + octave-value/ov-cs-list.h \ + octave-value/ov-cx-diag.h \ + octave-value/ov-cx-mat.h \ + octave-value/ov-dld-fcn.h \ + octave-value/ov-fcn-handle.h \ + octave-value/ov-fcn-inline.h \ + octave-value/ov-fcn.h \ + octave-value/ov-float.h \ + octave-value/ov-flt-complex.h \ + octave-value/ov-flt-cx-diag.h \ + octave-value/ov-flt-cx-mat.h \ + octave-value/ov-flt-re-diag.h \ + octave-value/ov-flt-re-mat.h \ + octave-value/ov-lazy-idx.h \ + octave-value/ov-mex-fcn.h \ + octave-value/ov-null-mat.h \ + octave-value/ov-oncleanup.h \ + octave-value/ov-perm.h \ + octave-value/ov-range.h \ + octave-value/ov-re-diag.h \ + octave-value/ov-re-mat.h \ + octave-value/ov-scalar.h \ + octave-value/ov-str-mat.h \ + octave-value/ov-struct.h \ + octave-value/ov-type-conv.h \ + octave-value/ov-typeinfo.h \ + octave-value/ov-usr-fcn.h \ + octave-value/ov.h \ + $(OV_INTTYPE_INCLUDES) + +OV_INTTYPE_SRC = \ + octave-value/ov-int16.cc \ + octave-value/ov-int32.cc \ + octave-value/ov-int64.cc \ + octave-value/ov-int8.cc \ + octave-value/ov-uint16.cc \ + octave-value/ov-uint32.cc \ + octave-value/ov-uint64.cc \ + octave-value/ov-uint8.cc + +OV_SPARSE_SRC = \ + octave-value/ov-base-sparse.cc \ + octave-value/ov-bool-sparse.cc \ + octave-value/ov-cx-sparse.cc \ + octave-value/ov-re-sparse.cc + +OCTAVE_VALUE_SRC = \ + octave-value/ov-base.cc \ + octave-value/ov-bool-mat.cc \ + octave-value/ov-bool.cc \ + octave-value/ov-builtin.cc \ + octave-value/ov-cell.cc \ + octave-value/ov-ch-mat.cc \ + octave-value/ov-class.cc \ + octave-value/ov-classdef.cc \ + octave-value/ov-colon.cc \ + octave-value/ov-complex.cc \ + octave-value/ov-cs-list.cc \ + octave-value/ov-cx-diag.cc \ + octave-value/ov-cx-mat.cc \ + octave-value/ov-dld-fcn.cc \ + octave-value/ov-fcn-handle.cc \ + octave-value/ov-fcn-inline.cc \ + octave-value/ov-fcn.cc \ + octave-value/ov-float.cc \ + octave-value/ov-flt-complex.cc \ + octave-value/ov-flt-cx-diag.cc \ + octave-value/ov-flt-cx-mat.cc \ + octave-value/ov-flt-re-diag.cc \ + octave-value/ov-flt-re-mat.cc \ + octave-value/ov-lazy-idx.cc \ + octave-value/ov-mex-fcn.cc \ + octave-value/ov-null-mat.cc \ + octave-value/ov-oncleanup.cc \ + octave-value/ov-perm.cc \ + octave-value/ov-range.cc \ + octave-value/ov-re-diag.cc \ + octave-value/ov-re-mat.cc \ + octave-value/ov-scalar.cc \ + octave-value/ov-str-mat.cc \ + octave-value/ov-struct.cc \ + octave-value/ov-typeinfo.cc \ + octave-value/ov-usr-fcn.cc \ + octave-value/ov.cc \ + $(OV_INTTYPE_SRC) \ + $(OV_SPARSE_SRC) +
rename from src/OPERATORS/module.mk rename to src/operators/module.mk --- a/src/OPERATORS/module.mk +++ b/src/operators/module.mk @@ -1,136 +1,136 @@ -EXTRA_DIST += OPERATORS/module.mk +EXTRA_DIST += operators/module.mk OPERATORS_SRC = \ - OPERATORS/op-b-b.cc \ - OPERATORS/op-b-bm.cc \ - OPERATORS/op-b-sbm.cc \ - OPERATORS/op-bm-b.cc \ - OPERATORS/op-bm-bm.cc \ - OPERATORS/op-bm-sbm.cc \ - OPERATORS/op-cdm-cdm.cc \ - OPERATORS/op-cdm-cm.cc \ - OPERATORS/op-cdm-cs.cc \ - OPERATORS/op-cdm-dm.cc \ - OPERATORS/op-cdm-m.cc \ - OPERATORS/op-cdm-s.cc \ - OPERATORS/op-cell.cc \ - OPERATORS/op-chm.cc \ - OPERATORS/op-class.cc \ - OPERATORS/op-cm-cdm.cc \ - OPERATORS/op-cm-cm.cc \ - OPERATORS/op-cm-cs.cc \ - OPERATORS/op-cm-dm.cc \ - OPERATORS/op-cm-m.cc \ - OPERATORS/op-cm-pm.cc \ - OPERATORS/op-cm-s.cc \ - OPERATORS/op-cm-scm.cc \ - OPERATORS/op-cm-sm.cc \ - OPERATORS/op-cs-cm.cc \ - OPERATORS/op-cs-cs.cc \ - OPERATORS/op-cs-m.cc \ - OPERATORS/op-cs-s.cc \ - OPERATORS/op-cs-scm.cc \ - OPERATORS/op-cs-sm.cc \ - OPERATORS/op-dm-cdm.cc \ - OPERATORS/op-dm-cm.cc \ - OPERATORS/op-dm-cs.cc \ - OPERATORS/op-dm-dm.cc \ - OPERATORS/op-dm-m.cc \ - OPERATORS/op-dm-s.cc \ - OPERATORS/op-dm-scm.cc \ - OPERATORS/op-dm-sm.cc \ - OPERATORS/op-double-conv.cc \ - OPERATORS/op-fcdm-fcdm.cc \ - OPERATORS/op-fcdm-fcm.cc \ - OPERATORS/op-fcdm-fcs.cc \ - OPERATORS/op-fcdm-fdm.cc \ - OPERATORS/op-fcdm-fm.cc \ - OPERATORS/op-fcdm-fs.cc \ - OPERATORS/op-fcm-fcdm.cc \ - OPERATORS/op-fcm-fcm.cc \ - OPERATORS/op-fcm-fcs.cc \ - OPERATORS/op-fcm-fdm.cc \ - OPERATORS/op-fcm-fm.cc \ - OPERATORS/op-fcm-fs.cc \ - OPERATORS/op-fcm-pm.cc \ - OPERATORS/op-fcn.cc \ - OPERATORS/op-fcs-fcm.cc \ - OPERATORS/op-fcs-fcs.cc \ - OPERATORS/op-fcs-fm.cc \ - OPERATORS/op-fcs-fs.cc \ - OPERATORS/op-fdm-fcdm.cc \ - OPERATORS/op-fdm-fcm.cc \ - OPERATORS/op-fdm-fcs.cc \ - OPERATORS/op-fdm-fdm.cc \ - OPERATORS/op-fdm-fm.cc \ - OPERATORS/op-fdm-fs.cc \ - OPERATORS/op-float-conv.cc \ - OPERATORS/op-fm-fcdm.cc \ - OPERATORS/op-fm-fcm.cc \ - OPERATORS/op-fm-fcs.cc \ - OPERATORS/op-fm-fdm.cc \ - OPERATORS/op-fm-fm.cc \ - OPERATORS/op-fm-fs.cc \ - OPERATORS/op-fm-pm.cc \ - OPERATORS/op-fs-fcm.cc \ - OPERATORS/op-fs-fcs.cc \ - OPERATORS/op-fs-fm.cc \ - OPERATORS/op-fs-fs.cc \ - OPERATORS/op-i16-i16.cc \ - OPERATORS/op-i32-i32.cc \ - OPERATORS/op-i64-i64.cc \ - OPERATORS/op-i8-i8.cc \ - OPERATORS/op-int-concat.cc \ - OPERATORS/op-int-conv.cc \ - OPERATORS/op-m-cdm.cc \ - OPERATORS/op-m-cm.cc \ - OPERATORS/op-m-cs.cc \ - OPERATORS/op-m-dm.cc \ - OPERATORS/op-m-m.cc \ - OPERATORS/op-m-pm.cc \ - OPERATORS/op-m-s.cc \ - OPERATORS/op-m-scm.cc \ - OPERATORS/op-m-sm.cc \ - OPERATORS/op-pm-cm.cc \ - OPERATORS/op-pm-fcm.cc \ - OPERATORS/op-pm-fm.cc \ - OPERATORS/op-pm-m.cc \ - OPERATORS/op-pm-pm.cc \ - OPERATORS/op-pm-scm.cc \ - OPERATORS/op-pm-sm.cc \ - OPERATORS/op-range.cc \ - OPERATORS/op-s-cm.cc \ - OPERATORS/op-s-cs.cc \ - OPERATORS/op-s-m.cc \ - OPERATORS/op-s-s.cc \ - OPERATORS/op-s-scm.cc \ - OPERATORS/op-s-sm.cc \ - OPERATORS/op-sbm-b.cc \ - OPERATORS/op-sbm-bm.cc \ - OPERATORS/op-sbm-sbm.cc \ - OPERATORS/op-scm-cm.cc \ - OPERATORS/op-scm-cs.cc \ - OPERATORS/op-scm-m.cc \ - OPERATORS/op-scm-s.cc \ - OPERATORS/op-scm-scm.cc \ - OPERATORS/op-scm-sm.cc \ - OPERATORS/op-sm-cm.cc \ - OPERATORS/op-sm-cs.cc \ - OPERATORS/op-sm-m.cc \ - OPERATORS/op-sm-s.cc \ - OPERATORS/op-sm-scm.cc \ - OPERATORS/op-sm-sm.cc \ - OPERATORS/op-str-m.cc \ - OPERATORS/op-str-s.cc \ - OPERATORS/op-str-str.cc \ - OPERATORS/op-struct.cc \ - OPERATORS/op-ui16-ui16.cc \ - OPERATORS/op-ui32-ui32.cc \ - OPERATORS/op-ui64-ui64.cc \ - OPERATORS/op-ui8-ui8.cc + operators/op-b-b.cc \ + operators/op-b-bm.cc \ + operators/op-b-sbm.cc \ + operators/op-bm-b.cc \ + operators/op-bm-bm.cc \ + operators/op-bm-sbm.cc \ + operators/op-cdm-cdm.cc \ + operators/op-cdm-cm.cc \ + operators/op-cdm-cs.cc \ + operators/op-cdm-dm.cc \ + operators/op-cdm-m.cc \ + operators/op-cdm-s.cc \ + operators/op-cell.cc \ + operators/op-chm.cc \ + operators/op-class.cc \ + operators/op-cm-cdm.cc \ + operators/op-cm-cm.cc \ + operators/op-cm-cs.cc \ + operators/op-cm-dm.cc \ + operators/op-cm-m.cc \ + operators/op-cm-pm.cc \ + operators/op-cm-s.cc \ + operators/op-cm-scm.cc \ + operators/op-cm-sm.cc \ + operators/op-cs-cm.cc \ + operators/op-cs-cs.cc \ + operators/op-cs-m.cc \ + operators/op-cs-s.cc \ + operators/op-cs-scm.cc \ + operators/op-cs-sm.cc \ + operators/op-dm-cdm.cc \ + operators/op-dm-cm.cc \ + operators/op-dm-cs.cc \ + operators/op-dm-dm.cc \ + operators/op-dm-m.cc \ + operators/op-dm-s.cc \ + operators/op-dm-scm.cc \ + operators/op-dm-sm.cc \ + operators/op-double-conv.cc \ + operators/op-fcdm-fcdm.cc \ + operators/op-fcdm-fcm.cc \ + operators/op-fcdm-fcs.cc \ + operators/op-fcdm-fdm.cc \ + operators/op-fcdm-fm.cc \ + operators/op-fcdm-fs.cc \ + operators/op-fcm-fcdm.cc \ + operators/op-fcm-fcm.cc \ + operators/op-fcm-fcs.cc \ + operators/op-fcm-fdm.cc \ + operators/op-fcm-fm.cc \ + operators/op-fcm-fs.cc \ + operators/op-fcm-pm.cc \ + operators/op-fcn.cc \ + operators/op-fcs-fcm.cc \ + operators/op-fcs-fcs.cc \ + operators/op-fcs-fm.cc \ + operators/op-fcs-fs.cc \ + operators/op-fdm-fcdm.cc \ + operators/op-fdm-fcm.cc \ + operators/op-fdm-fcs.cc \ + operators/op-fdm-fdm.cc \ + operators/op-fdm-fm.cc \ + operators/op-fdm-fs.cc \ + operators/op-float-conv.cc \ + operators/op-fm-fcdm.cc \ + operators/op-fm-fcm.cc \ + operators/op-fm-fcs.cc \ + operators/op-fm-fdm.cc \ + operators/op-fm-fm.cc \ + operators/op-fm-fs.cc \ + operators/op-fm-pm.cc \ + operators/op-fs-fcm.cc \ + operators/op-fs-fcs.cc \ + operators/op-fs-fm.cc \ + operators/op-fs-fs.cc \ + operators/op-i16-i16.cc \ + operators/op-i32-i32.cc \ + operators/op-i64-i64.cc \ + operators/op-i8-i8.cc \ + operators/op-int-concat.cc \ + operators/op-int-conv.cc \ + operators/op-m-cdm.cc \ + operators/op-m-cm.cc \ + operators/op-m-cs.cc \ + operators/op-m-dm.cc \ + operators/op-m-m.cc \ + operators/op-m-pm.cc \ + operators/op-m-s.cc \ + operators/op-m-scm.cc \ + operators/op-m-sm.cc \ + operators/op-pm-cm.cc \ + operators/op-pm-fcm.cc \ + operators/op-pm-fm.cc \ + operators/op-pm-m.cc \ + operators/op-pm-pm.cc \ + operators/op-pm-scm.cc \ + operators/op-pm-sm.cc \ + operators/op-range.cc \ + operators/op-s-cm.cc \ + operators/op-s-cs.cc \ + operators/op-s-m.cc \ + operators/op-s-s.cc \ + operators/op-s-scm.cc \ + operators/op-s-sm.cc \ + operators/op-sbm-b.cc \ + operators/op-sbm-bm.cc \ + operators/op-sbm-sbm.cc \ + operators/op-scm-cm.cc \ + operators/op-scm-cs.cc \ + operators/op-scm-m.cc \ + operators/op-scm-s.cc \ + operators/op-scm-scm.cc \ + operators/op-scm-sm.cc \ + operators/op-sm-cm.cc \ + operators/op-sm-cs.cc \ + operators/op-sm-m.cc \ + operators/op-sm-s.cc \ + operators/op-sm-scm.cc \ + operators/op-sm-sm.cc \ + operators/op-str-m.cc \ + operators/op-str-s.cc \ + operators/op-str-str.cc \ + operators/op-struct.cc \ + operators/op-ui16-ui16.cc \ + operators/op-ui32-ui32.cc \ + operators/op-ui64-ui64.cc \ + operators/op-ui8-ui8.cc octinclude_HEADERS += \ - OPERATORS/op-dm-template.cc \ - OPERATORS/op-dms-template.cc \ - OPERATORS/op-int.h \ - OPERATORS/op-pm-template.cc + operators/op-dm-template.cc \ + operators/op-dms-template.cc \ + operators/op-int.h \ + operators/op-pm-template.cc
new file mode 100644 --- /dev/null +++ b/src/parse-tree/module.mk @@ -0,0 +1,65 @@ +EXTRA_DIST += \ + parse-tree/module.mk + +PT_INCLUDES = \ + parse-tree/pt-all.h \ + parse-tree/pt-arg-list.h \ + parse-tree/pt-assign.h \ + parse-tree/pt-binop.h \ + parse-tree/pt-bp.h \ + parse-tree/pt-cbinop.h \ + parse-tree/pt-cell.h \ + parse-tree/pt-check.h \ + parse-tree/pt-classdef.h \ + parse-tree/pt-cmd.h \ + parse-tree/pt-colon.h \ + parse-tree/pt-const.h \ + parse-tree/pt-decl.h \ + parse-tree/pt-eval.h \ + parse-tree/pt-except.h \ + parse-tree/pt-exp.h \ + parse-tree/pt-fcn-handle.h \ + parse-tree/pt-funcall.h \ + parse-tree/pt-id.h \ + parse-tree/pt-idx.h \ + parse-tree/pt-jump.h \ + parse-tree/pt-loop.h \ + parse-tree/pt-mat.h \ + parse-tree/pt-misc.h \ + parse-tree/pt-pr-code.h \ + parse-tree/pt-select.h \ + parse-tree/pt-stmt.h \ + parse-tree/pt-unop.h \ + parse-tree/pt-walk.h \ + parse-tree/pt.h + +PARSE_TREE_SRC = \ + parse-tree/pt-arg-list.cc \ + parse-tree/pt-assign.cc \ + parse-tree/pt-binop.cc \ + parse-tree/pt-bp.cc \ + parse-tree/pt-cbinop.cc \ + parse-tree/pt-cell.cc \ + parse-tree/pt-check.cc \ + parse-tree/pt-classdef.cc \ + parse-tree/pt-cmd.cc \ + parse-tree/pt-colon.cc \ + parse-tree/pt-const.cc \ + parse-tree/pt-decl.cc \ + parse-tree/pt-eval.cc \ + parse-tree/pt-except.cc \ + parse-tree/pt-exp.cc \ + parse-tree/pt-fcn-handle.cc \ + parse-tree/pt-funcall.cc \ + parse-tree/pt-id.cc \ + parse-tree/pt-idx.cc \ + parse-tree/pt-jump.cc \ + parse-tree/pt-loop.cc \ + parse-tree/pt-mat.cc \ + parse-tree/pt-misc.cc \ + parse-tree/pt-pr-code.cc \ + parse-tree/pt-select.cc \ + parse-tree/pt-stmt.cc \ + parse-tree/pt-unop.cc \ + parse-tree/pt.cc +
--- a/src/pt-jit.cc +++ b/src/pt-jit.cc @@ -412,7 +412,14 @@ void jit_convert::visit_identifier (tree_identifier& ti) { - result = get_variable (ti.name ()); + if (ti.has_magic_end ()) + { + if (!end_context.size ()) + throw jit_fail_exception ("Illegal end"); + result = block->append (create<jit_magic_end> (end_context)); + } + else + result = get_variable (ti.name ()); } void @@ -826,6 +833,12 @@ tree_expression *tree_object = exp.expression (); jit_value *object = visit (tree_object); + + end_context.push_back (object); + + unwind_protect prot; + prot.add_method (&end_context, &std::vector<jit_value *>::pop_back); + tree_expression *arg0 = arg_list->front (); jit_value *index = visit (arg0); @@ -1479,6 +1492,14 @@ jit_convert::convert_llvm::visit (jit_argument&) {} +void +jit_convert::convert_llvm::visit (jit_magic_end& me) +{ + const jit_function& ol = me.overload (); + llvm::Value *ret = ol.call (builder, me.resolve_context ()); + me.stash_llvm (ret); +} + // -------------------- tree_jit -------------------- tree_jit::tree_jit (void) : module (0), engine (0) @@ -1823,4 +1844,13 @@ %! endwhile %! assert (i == niter); +%!test +%! niter = 1001; +%! result = 0; +%! m = [5 10]; +%! for i=1:niter +%! result = result + m(end); +%! endfor +%! assert (result == m(end) * niter); + */
--- a/src/pt-jit.h +++ b/src/pt-jit.h @@ -244,6 +244,8 @@ std::list<jit_value *> all_values; + std::vector<jit_value *> end_context; + size_t iterator_count; size_t for_bounds_count; size_t short_count;
rename from src/TEMPLATE-INST/module.mk rename to src/template-inst/module.mk --- a/src/TEMPLATE-INST/module.mk +++ b/src/template-inst/module.mk @@ -1,6 +1,6 @@ -EXTRA_DIST += TEMPLATE-INST/module.mk +EXTRA_DIST += template-inst/module.mk TEMPLATE_INST_SRC = \ - TEMPLATE-INST/Array-os.cc \ - TEMPLATE-INST/Array-tc.cc \ - TEMPLATE-INST/Array-jit.cc + template-inst/Array-os.cc \ + template-inst/Array-tc.cc \ + template-inst/Array-jit.cc