source: mainline/uspace/app/sbi/src/run_t.h

Last change on this file was 09ab0a9a, checked in by Jiri Svoboda <jiri@…>, 7 years ago

Fix vertical spacing with new Ccheck revision.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2010 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef RUN_T_H_
30#define RUN_T_H_
31
32#include "intmap_t.h"
33#include "list_t.h"
34
35/** Block activation record
36 *
37 * One block AR is created for each block that we enter. A variable declaration
38 * statement inserts the variable here. Upon exiting the block we pop from the
39 * stack, thus all the variables declared in that block are forgotten.
40 */
41typedef struct run_block_ar {
42 /** Variables in this block */
43 intmap_t vars; /* of rdata_var_t */
44} run_block_ar_t;
45
46/** Procedure activation record
47 *
48 * A procedure can be a member function, a named property or an indexed
49 * property. A procedure activation record is created whenever a procedure
50 * is invoked.
51 */
52typedef struct run_proc_ar {
53 /** Object on which the procedure is being invoked or @c NULL. */
54 struct rdata_var *obj;
55
56 /** Procedure being invoked */
57 struct stree_proc *proc;
58
59 /** Block activation records */
60 list_t block_ar; /* of run_block_ar_t */
61
62 /** Procedure return value or @c NULL if not set. */
63 struct rdata_item *retval;
64} run_proc_ar_t;
65
66/** Bailout mode
67 *
68 * Determines whether control is bailing out of a statement, function, etc.
69 */
70typedef enum {
71 /** Normal execution */
72 bm_none,
73
74 /** Break from statement */
75 bm_stat,
76
77 /** Return from procedure */
78 bm_proc,
79
80 /** Exception */
81 bm_exc,
82
83 /** Unrecoverable runtime error */
84 bm_error
85} run_bailout_mode_t;
86
87/** Thread activation record
88 *
89 * We can walk the list of function ARs to get a function call backtrace.
90 */
91typedef struct run_thread_ar {
92 /** Function activation records */
93 list_t proc_ar; /* of run_proc_ar_t */
94
95 /** Bailout mode */
96 run_bailout_mode_t bo_mode;
97
98 /** Exception cspan */
99 struct cspan *exc_cspan;
100
101 /** Exception payload */
102 struct rdata_value *exc_payload;
103
104 /** @c b_true if a run-time error occured. */
105 bool_t error;
106} run_thread_ar_t;
107
108/** Runner state object */
109typedef struct run {
110 /** Code of the program being executed */
111 struct stree_program *program;
112
113 /** Thread-private state */
114 run_thread_ar_t *thread_ar;
115
116 /** Global state */
117 struct rdata_var *gdata;
118} run_t;
119
120#endif
Note: See TracBrowser for help on using the repository browser.