Changeset 1ebc1a62 in mainline for uspace/app/sbi/src/builtin.c
- Timestamp:
- 2010-03-29T20:30:29Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a95310e
- Parents:
- 5da468e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/builtin.c
r5da468e r1ebc1a62 27 27 */ 28 28 29 /** @file Builtin symbol binding. */ 29 /** @file Builtin symbol binding. 30 * 31 * 'Builtin' symbols are implemented outside of the language itself. 32 * Here we refer to entities residing within the interpreted universe 33 * as 'internal', while anything implemented outside this universe 34 * as 'external'. This module facilitates declaration of builtin 35 * symbols and the binding of these symbols to their external 36 * implementation. 37 */ 30 38 31 39 #include <stdio.h> … … 54 62 * 55 63 * Declares symbols that will be hooked to builtin interpreter procedures. 64 * 65 * @param program Program in which to declare builtin symbols. 56 66 */ 57 67 void builtin_declare(stree_program_t *program) … … 86 96 } 87 97 88 /** Get grandfather class. */ 98 /** Get grandfather class. 99 * 100 * Grandfather class is the class from which all other classes are 101 * (directly or indirectly) derived. 102 * 103 * @param builtin Builtin context (corresponsds to program). 104 * @return Grandfather class (CSI). 105 */ 89 106 stree_csi_t *builtin_get_gf_class(builtin_t *builtin) 90 107 { … … 95 112 } 96 113 114 /** Allocate new builtin context object. 115 * 116 * @return Builtin context object. 117 */ 97 118 static builtin_t *builtin_new(void) 98 119 { … … 126 147 } 127 148 128 /** Simplifed search for a global symbol. */ 149 /** Simplifed search for a global symbol. 150 * 151 * The specified symbol must exist. 152 * 153 * @param bi Builtin context object. 154 * @param sym_name Name of symbol to find. 155 * @return Symbol. 156 */ 129 157 stree_symbol_t *builtin_find_lvl0(builtin_t *bi, const char *sym_name) 130 158 { … … 136 164 ident->sid = strtab_get_sid(sym_name); 137 165 sym = symbol_lookup_in_csi(bi->program, NULL, ident); 166 assert(sym != NULL); 138 167 139 168 return sym; 140 169 } 141 170 142 /** Simplifed search for a level 1 symbol. */ 171 /** Simplifed search for a level 1 symbol. 172 * 173 * The specified symbol must exist. 174 * 175 * @param bi Builtin context object. 176 * @param csi_name CSI in which to look for symbol. 177 * @param sym_name Name of symbol to find. 178 * @return Symbol. 179 */ 143 180 stree_symbol_t *builtin_find_lvl1(builtin_t *bi, const char *csi_name, 144 181 const char *sym_name) … … 154 191 ident->sid = strtab_get_sid(csi_name); 155 192 csi_sym = symbol_lookup_in_csi(bi->program, NULL, ident); 193 assert(csi_sym != NULL); 156 194 csi = symbol_to_csi(csi_sym); 157 195 assert(csi != NULL); … … 159 197 ident->sid = strtab_get_sid(sym_name); 160 198 mbr_sym = symbol_lookup_in_csi(bi->program, csi, ident); 199 assert(mbr_sym != NULL); 161 200 162 201 return mbr_sym; 163 202 } 164 203 204 /** Bind level 1 member function to external implementation. 205 * 206 * Binds a member function (of a global class) to external implementation. 207 * The specified CSI and member function must exist. 208 * 209 * @param bi Builtin context object. 210 * @param csi_name CSI which contains the function. 211 * @param sym_name Function name. 212 * @param bproc Pointer to C function implementation. 213 */ 165 214 void builtin_fun_bind(builtin_t *bi, const char *csi_name, 166 215 const char *sym_name, builtin_proc_t bproc) … … 177 226 } 178 227 228 /** Execute a builtin procedure. 229 * 230 * Executes a procedure that has an external implementation. 231 * 232 * @param run Runner object. 233 * @param proc Procedure that has an external implementation. 234 */ 179 235 void builtin_run_proc(run_t *run, stree_proc_t *proc) 180 236 { … … 201 257 } 202 258 203 /** Get pointer to member var of current object. */ 259 /** Get pointer to member var of current object. 260 * 261 * Returns the var node that corresponds to a member of the currently 262 * active object with the given name. This member must exist. 263 * 264 * @param run Runner object. 265 * @param mbr_name Name of member to find. 266 * @return Var node of the member. 267 */ 204 268 rdata_var_t *builtin_get_self_mbr_var(run_t *run, const char *mbr_name) 205 269 { … … 220 284 } 221 285 222 /** Declare a builtin function in @a csi. */ 286 /** Declare a builtin function in @a csi. 287 * 288 * Declare a builtin function member of CSI @a csi. Deprecated in favor 289 * of builtin_code_snippet(). 290 * 291 * @param csi CSI in which to declare function. 292 * @param name Name of member function to declare. 293 * @return Symbol of newly declared function. 294 */ 223 295 stree_symbol_t *builtin_declare_fun(stree_csi_t *csi, const char *name) 224 296 { … … 251 323 } 252 324 253 /** Add one formal parameter to function. */ 325 /** Add one formal parameter to function. 326 * 327 * Used to incrementally construct formal parameter list of a builtin 328 * function. Deprecated in favor of builtin_code_snippet(). Does not 329 * support type checking. 330 * 331 * @param fun_sym Symbol of function to add parameters to. 332 * @param name Name of parameter to add. 333 */ 254 334 void builtin_fun_add_arg(stree_symbol_t *fun_sym, const char *name) 255 335 {
Note:
See TracChangeset
for help on using the changeset viewer.