source: mainline/uspace/app/sbi/src/run_t.h@ 36f0738

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 36f0738 was c5cb943d, checked in by Jiri Svoboda <jiri@…>, 15 years ago

Update SBI to rev. 291.

  • 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
47/** Procedure activation record
48 *
49 * A procedure can be a member function, a named property or an indexed
50 * property. A procedure activation record is created whenever a procedure
51 * is invoked.
52 */
53typedef struct run_proc_ar {
54 /** Object on which the procedure is being invoked or @c NULL. */
55 struct rdata_var *obj;
56
57 /** Procedure being invoked */
58 struct stree_proc *proc;
59
60 /** Block activation records */
61 list_t block_ar; /* of run_block_ar_t */
62
63 /** Procedure return value or @c NULL if not set. */
64 struct rdata_item *retval;
65} run_proc_ar_t;
66
67/** Bailout mode
68 *
69 * Determines whether control is bailing out of a statement, function, etc.
70 */
71typedef enum {
72 /** Normal execution */
73 bm_none,
74
75 /** Break from statement */
76 bm_stat,
77
78 /** Return from procedure */
79 bm_proc,
80
81 /** Exception */
82 bm_exc,
83
84 /** Unrecoverable runtime error */
85 bm_error
86} run_bailout_mode_t;
87
88/** Thread activation record
89 *
90 * We can walk the list of function ARs to get a function call backtrace.
91 */
92typedef struct run_thread_ar {
93 /** Function activation records */
94 list_t proc_ar; /* of run_proc_ar_t */
95
96 /** Bailout mode */
97 run_bailout_mode_t bo_mode;
98
99 /** Exception cspan */
100 struct cspan *exc_cspan;
101
102 /** Exception payload */
103 struct rdata_value *exc_payload;
104
105 /** @c b_true if a run-time error occured. */
106 bool_t error;
107} run_thread_ar_t;
108
109/** Runner state object */
110typedef struct run {
111 /** Code of the program being executed */
112 struct stree_program *program;
113
114 /** Thread-private state */
115 run_thread_ar_t *thread_ar;
116
117 /** Global state */
118 struct rdata_var *gdata;
119} run_t;
120
121#endif
Note: See TracBrowser for help on using the repository browser.