Mercurial > octave
comparison libinterp/parse-tree/pt-vm-eval.cc @ 31167:92d897a2c1c3
New runtime function __enable_vm_eval__() to control use of VM evaluator.
* libinterp/parse-tree/pt-vm-eval.cc (F__enable_vm_eval__): New file. New
DEFUN for __enable_vm_eval__ protected by #ifdef on configuration variable
OCTAVE_ENABLE_VM_EVALUATOR.
* libinterp/parse-tree/module.mk: Add pt-vm-eval.cc to build system.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 29 Jul 2022 10:41:22 -0700 |
parents | |
children | e88a07dec498 |
comparison
equal
deleted
inserted
replaced
31166:0758c713c6e6 | 31167:92d897a2c1c3 |
---|---|
1 //////////////////////////////////////////////////////////////////////// | |
2 // | |
3 // Copyright (C) 2022 The Octave Project Developers | |
4 // | |
5 // See the file COPYRIGHT.md in the top-level directory of this | |
6 // distribution or <https://octave.org/copyright/>. | |
7 // | |
8 // This file is part of Octave. | |
9 // | |
10 // Octave is free software: you can redistribute it and/or modify it | |
11 // under the terms of the GNU General Public License as published by | |
12 // the Free Software Foundation, either version 3 of the License, or | |
13 // (at your option) any later version. | |
14 // | |
15 // Octave is distributed in the hope that it will be useful, but | |
16 // WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 // GNU General Public License for more details. | |
19 // | |
20 // You should have received a copy of the GNU General Public License | |
21 // along with Octave; see the file COPYING. If not, see | |
22 // <https://www.gnu.org/licenses/>. | |
23 // | |
24 //////////////////////////////////////////////////////////////////////// | |
25 | |
26 #if defined (HAVE_CONFIG_H) | |
27 # include "config.h" | |
28 #endif | |
29 | |
30 #include "defun.h" | |
31 #include "variables.h" | |
32 | |
33 OCTAVE_NAMESPACE_BEGIN | |
34 | |
35 // If TRUE, use VM evaluator rather than tree walker. | |
36 | |
37 static bool V__enable_vm_eval__ = false; | |
38 | |
39 DEFUN (__enable_vm_eval__, args, nargout, | |
40 doc: /* -*- texinfo -*- | |
41 @deftypefn {} {@var{val} =} __enable_vm_eval__ () | |
42 @deftypefnx {} {@var{old_val} =} __enable_vm_eval__ (@var{new_val}) | |
43 @deftypefnx {} {@var{old_val} =} __enable_vm_eval__ (@var{new_val}, "local") | |
44 Query or set whether Octave uses a virtual machine (VM) for evaluation of | |
45 parsed statements. | |
46 | |
47 The default value is false. When false, Octave uses a traditional tree walker | |
48 to evaluate statements parsed from m-code. When true, Octave translates parsed | |
49 statements to an intermediate representation that is then evaluated by a | |
50 virtual machine. | |
51 | |
52 When called from inside a function with the @qcode{"local"} option, the setting | |
53 is changed locally for the function and any subroutines it calls. The original | |
54 setting is restored when exiting the function. | |
55 @end deftypefn */) | |
56 { | |
57 #if defined (OCTAVE_ENABLE_VM_EVALUATOR) | |
58 | |
59 return set_internal_variable (V__enable_vm_eval__, args, nargout, | |
60 "__enable_vm_eval__"); | |
61 | |
62 #else | |
63 | |
64 octave_unused_parameter (args); | |
65 | |
66 err_disabled_feature ("vm-evaluator", | |
67 "using a Virtual Machine for statement evaluation"); | |
68 | |
69 #endif | |
70 } | |
71 | |
72 OCTAVE_NAMESPACE_END |