]>
Commit | Line | Data |
---|---|---|
99dee823 | 1 | .. Copyright (C) 2014-2021 Free Software Foundation, Inc. |
29df5715 DM |
2 | Originally contributed by David Malcolm <dmalcolm@redhat.com> |
3 | ||
4 | This is free software: you can redistribute it and/or modify it | |
5 | under the terms of the GNU General Public License as published by | |
6 | the Free Software Foundation, either version 3 of the License, or | |
7 | (at your option) any later version. | |
8 | ||
9 | This program is distributed in the hope that it will be useful, but | |
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU General Public License | |
15 | along with this program. If not, see | |
16 | <http://www.gnu.org/licenses/>. | |
17 | ||
18 | .. default-domain:: cpp | |
19 | ||
20 | Objects | |
21 | ======= | |
22 | ||
23 | .. class:: gccjit::object | |
24 | ||
25 | Almost every entity in the API (with the exception of | |
26 | :class:`gccjit::context` and :c:type:`gcc_jit_result *`) is a | |
27 | "contextual" object, a :class:`gccjit::object`. | |
28 | ||
29 | A JIT object: | |
30 | ||
31 | * is associated with a :class:`gccjit::context`. | |
32 | ||
33 | * is automatically cleaned up for you when its context is released so | |
34 | you don't need to manually track and cleanup all objects, just the | |
35 | contexts. | |
36 | ||
37 | The C++ class hierarchy within the ``gccjit`` namespace looks like this:: | |
38 | ||
39 | +- object | |
40 | +- location | |
41 | +- type | |
42 | +- struct | |
43 | +- field | |
44 | +- function | |
45 | +- block | |
46 | +- rvalue | |
47 | +- lvalue | |
48 | +- param | |
ec5d0088 | 49 | +- case_ |
29df5715 DM |
50 | |
51 | The :class:`gccjit::object` base class has the following operations: | |
52 | ||
53 | .. function:: gccjit::context gccjit::object::get_context () const | |
54 | ||
55 | Which context is the obj within? | |
56 | ||
57 | .. function:: std::string gccjit::object::get_debug_string () const | |
58 | ||
59 | Generate a human-readable description for the given object. | |
60 | ||
61 | For example, | |
62 | ||
63 | .. code-block:: c++ | |
64 | ||
65 | printf ("obj: %s\n", obj.get_debug_string ().c_str ()); | |
66 | ||
67 | might give this text on stdout: | |
68 | ||
69 | .. code-block:: bash | |
70 | ||
71 | obj: 4.0 * (float)i |