jit: add switch statements
[official-gcc.git] / gcc / jit / docs / cp / topics / objects.rst
blob8d99bd40df8228ddbd4cb011d62ff571540fdfb7
1 .. Copyright (C) 2014-2015 Free Software Foundation, Inc.
2    Originally contributed by David Malcolm <dmalcolm@redhat.com>
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.
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.
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/>.
18 .. default-domain:: cpp
20 Objects
21 =======
23 .. class:: gccjit::object
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`.
29 A JIT object:
31   * is associated with a :class:`gccjit::context`.
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.
37 The C++ class hierarchy within the ``gccjit`` namespace looks like this::
39   +- object
40       +- location
41       +- type
42          +- struct
43       +- field
44       +- function
45       +- block
46       +- rvalue
47           +- lvalue
48              +- param
49       +- case_
51 The :class:`gccjit::object` base class has the following operations:
53 .. function:: gccjit::context gccjit::object::get_context () const
55   Which context is the obj within?
57 .. function:: std::string gccjit::object::get_debug_string () const
59   Generate a human-readable description for the given object.
61   For example,
63   .. code-block:: c++
65      printf ("obj: %s\n", obj.get_debug_string ().c_str ());
67   might give this text on stdout:
69   .. code-block:: bash
71      obj: 4.0 * (float)i