GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-vm-eval.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2022-2023 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 
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 
OCTAVE_END_NAMESPACE(octave)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition: defun.h:56
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
Definition: errwarn.cc:53
static bool V__enable_vm_eval__
Definition: pt-vm-eval.cc:37
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
Definition: variables.cc:584