Changeset 1ebc1a62 in mainline for uspace/app/sbi/src/builtin.c


Ignore:
Timestamp:
2010-03-29T20:30:29Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a95310e
Parents:
5da468e
Message:

Update SBI to rev. 157.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sbi/src/builtin.c

    r5da468e r1ebc1a62  
    2727 */
    2828
    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 */
    3038
    3139#include <stdio.h>
     
    5462 *
    5563 * Declares symbols that will be hooked to builtin interpreter procedures.
     64 *
     65 * @param program       Program in which to declare builtin symbols.
    5666 */
    5767void builtin_declare(stree_program_t *program)
     
    8696}
    8797
    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 */
    89106stree_csi_t *builtin_get_gf_class(builtin_t *builtin)
    90107{
     
    95112}
    96113
     114/** Allocate new builtin context object.
     115 *
     116 * @return      Builtin context object.
     117 */
    97118static builtin_t *builtin_new(void)
    98119{
     
    126147}
    127148
    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 */
    129157stree_symbol_t *builtin_find_lvl0(builtin_t *bi, const char *sym_name)
    130158{
     
    136164        ident->sid = strtab_get_sid(sym_name);
    137165        sym = symbol_lookup_in_csi(bi->program, NULL, ident);
     166        assert(sym != NULL);
    138167
    139168        return sym;
    140169}
    141170
    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 */
    143180stree_symbol_t *builtin_find_lvl1(builtin_t *bi, const char *csi_name,
    144181    const char *sym_name)
     
    154191        ident->sid = strtab_get_sid(csi_name);
    155192        csi_sym = symbol_lookup_in_csi(bi->program, NULL, ident);
     193        assert(csi_sym != NULL);
    156194        csi = symbol_to_csi(csi_sym);
    157195        assert(csi != NULL);
     
    159197        ident->sid = strtab_get_sid(sym_name);
    160198        mbr_sym = symbol_lookup_in_csi(bi->program, csi, ident);
     199        assert(mbr_sym != NULL);
    161200
    162201        return mbr_sym;
    163202}
    164203
     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 */
    165214void builtin_fun_bind(builtin_t *bi, const char *csi_name,
    166215    const char *sym_name, builtin_proc_t bproc)
     
    177226}
    178227
     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 */
    179235void builtin_run_proc(run_t *run, stree_proc_t *proc)
    180236{
     
    201257}
    202258
    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 */
    204268rdata_var_t *builtin_get_self_mbr_var(run_t *run, const char *mbr_name)
    205269{
     
    220284}
    221285
    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 */
    223295stree_symbol_t *builtin_declare_fun(stree_csi_t *csi, const char *name)
    224296{
     
    251323}
    252324
    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 */
    254334void builtin_fun_add_arg(stree_symbol_t *fun_sym, const char *name)
    255335{
Note: See TracChangeset for help on using the changeset viewer.