Mercurial > hg > octave-nkf
annotate liboctave/oct-md5.cc @ 15078:fe4752f772e2
Generate ND indexing functions on demand in JIT.
* src/jit-typeinfo.cc (jit_operation::~jit_operation,
jit_operation::do_generate, jit_operation::generate,
jit_operation::signature_cmp::operator()): New function.
(jit_operation::overload): Call do_generate when lookup fails.
(jit_index_operation, jit_paren_subsref, jit_paren_subsasgn): New class.
(jit_typeinfo::jit_typeinfo): Update to use jit_paren_subsref and
jit_paren_subsasgn.
(jit_typeinfo::gen_subsref, jit_typeinfo::gen_subsasgn): Removed functions.
* src/jit-typeinfo.h (jit_operation::~jit_operation, jit_operation::generate,
jit_operation::do_generate): New declaration.
(jit_operation::add_overload, jit_operation::overload, jit_operation::result,
jit_operation::to_idx): Use signature_vec typedef.
(jit_operation::singature_cmp): New class.
(jit_index_operation, jit_paren_subsref, jit_paren_subsasgn): New class.
(jit_typeinfo::get_scalar_ptr): Nwe function.
(jit_typeinfo::gen_subsref, jit_typeinfo::gen_subsasgn): Removed declaration.
* src/pt-jit.cc: New test.
author | Max Brister <max@2bass.com> |
---|---|
date | Wed, 01 Aug 2012 17:00:12 -0500 |
parents | 3d8ace26c5b4 |
children | 307912900544 |
rev | line source |
---|---|
6375 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3 Copyright (C) 2007-2012 David Bateman |
6375 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
6375 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
6375 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include "config.h" | |
25 #endif | |
26 | |
8521 | 27 #include <cstdio> |
28 | |
29 #include <string> | |
30 #include <vector> | |
31 | |
6383 | 32 #include "lo-error.h" |
6375 | 33 #include "oct-md5.h" |
34 #include "md5.h" | |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
35 |
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
36 static std::string |
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
37 oct_md5_result_to_str (const unsigned char *buf) |
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
38 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
39 char tmp[33]; |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
40 |
11293
202bd0f1863d
oct_md5_result_to_str: avoid buffer overrun; replace loop with single call to sprintf
John W. Eaton <jwe@octave.org>
parents:
11292
diff
changeset
|
41 sprintf (tmp, |
202bd0f1863d
oct_md5_result_to_str: avoid buffer overrun; replace loop with single call to sprintf
John W. Eaton <jwe@octave.org>
parents:
11292
diff
changeset
|
42 "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", |
202bd0f1863d
oct_md5_result_to_str: avoid buffer overrun; replace loop with single call to sprintf
John W. Eaton <jwe@octave.org>
parents:
11292
diff
changeset
|
43 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], |
202bd0f1863d
oct_md5_result_to_str: avoid buffer overrun; replace loop with single call to sprintf
John W. Eaton <jwe@octave.org>
parents:
11292
diff
changeset
|
44 buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], |
202bd0f1863d
oct_md5_result_to_str: avoid buffer overrun; replace loop with single call to sprintf
John W. Eaton <jwe@octave.org>
parents:
11292
diff
changeset
|
45 buf[15]); |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
46 |
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
47 return std::string (tmp, 32); |
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
48 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
49 |
6375 | 50 std::string |
51 oct_md5 (const std::string str) | |
52 { | |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
53 unsigned char buf[16]; |
6375 | 54 |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
55 md5_buffer (str.data (), str.length (), buf); |
6375 | 56 |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
57 return oct_md5_result_to_str (buf); |
6375 | 58 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
59 |
6383 | 60 std::string |
61 oct_md5_file (const std::string file) | |
62 { | |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
63 std::string retval; |
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
64 |
14153 | 65 FILE *ifile = gnulib::fopen (file.c_str (), "rb"); |
6383 | 66 |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
67 if (ifile) |
6383 | 68 { |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
69 unsigned char buf[16]; |
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
70 |
11292
231e6d1b57d6
oct_md5_file: close file after reading
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
71 int errflag = md5_stream (ifile, buf); |
231e6d1b57d6
oct_md5_file: close file after reading
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
72 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11293
diff
changeset
|
73 gnulib::fclose (ifile); |
11292
231e6d1b57d6
oct_md5_file: close file after reading
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
74 |
231e6d1b57d6
oct_md5_file: close file after reading
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
75 if (! errflag) |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
76 retval = oct_md5_result_to_str (buf); |
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
77 else |
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
78 (*current_liboctave_error_handler) ("internal error in md5_stream"); |
6383 | 79 } |
80 else | |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
81 (*current_liboctave_error_handler) ("unable to open file `%s' for reading", |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14153
diff
changeset
|
82 file.c_str ()); |
6383 | 83 |
10025
acd5e9df38f8
use gnuplib crypto/md5 module
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
84 return retval; |
6383 | 85 } |