Changeset 883fedc in mainline for uspace/app/sbi/src/builtin/bi_fun.c


Ignore:
Timestamp:
2010-04-23T23:09:56Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
37c9fc8
Parents:
80badbe (diff), 6c39a907 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jsvoboda/helenos/sysel. New: generic classes, autoboxing, delegates.

File:
1 edited

Legend:

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

    r80badbe r883fedc  
    4444#include "bi_fun.h"
    4545
     46static void bi_fun_builtin_write(run_t *run);
    4647static void bi_fun_builtin_writeline(run_t *run);
    4748static void bi_fun_task_exec(run_t *run);
    4849
    49 /** Declare builtin functions. */
     50/** Declare builtin functions.
     51 *
     52 * @param bi    Builtin object
     53 */
    5054void bi_fun_declare(builtin_t *bi)
    5155{
     
    6367        csi = stree_csi_new(csi_class);
    6468        csi->name = ident;
     69        list_init(&csi->targ);
    6570        list_init(&csi->members);
    6671
     
    7580        list_append(&bi->program->module->members, modm);
    7681
     82        /* Declare Builtin.Write(). */
     83
     84        fun_sym = builtin_declare_fun(csi, "Write");
     85        builtin_fun_add_arg(fun_sym, "arg");
     86
    7787        /* Declare Builtin.WriteLine(). */
    7888
     
    8898}
    8999
    90 /** Bind builtin functions. */
     100/** Bind builtin functions.
     101 *
     102 * @param bi    Builtin object
     103 */
    91104void bi_fun_bind(builtin_t *bi)
    92105{
     106        builtin_fun_bind(bi, "Builtin", "Write", bi_fun_builtin_write);
    93107        builtin_fun_bind(bi, "Builtin", "WriteLine", bi_fun_builtin_writeline);
    94108        builtin_fun_bind(bi, "Task", "Exec", bi_fun_task_exec);
    95109}
    96110
    97 /** Write a line of output. */
    98 static void bi_fun_builtin_writeline(run_t *run)
     111/** Write to the console.
     112 *
     113 * @param run   Runner object
     114 */
     115static void bi_fun_builtin_write(run_t *run)
    99116{
    100117        rdata_var_t *var;
     
    103120
    104121#ifdef DEBUG_RUN_TRACE
    105         printf("Called Builtin.WriteLine()\n");
     122        printf("Called Builtin.Write()\n");
    106123#endif
    107124        var = run_local_vars_lookup(run, strtab_get_sid("arg"));
     
    109126
    110127        switch (var->vc) {
     128        case vc_bool:
     129                printf("%s", var->u.bool_v->value ? "true" : "false");
     130                break;
    111131        case vc_char:
    112132                rc = bigint_get_value_int(&var->u.char_v->value, &char_val);
    113133                if (rc == EOK)
    114                         printf("%lc\n", char_val);
     134                        printf("%lc", char_val);
    115135                else
    116                         printf("???\n");
     136                        printf("???");
    117137                break;
    118138        case vc_int:
    119139                bigint_print(&var->u.int_v->value);
    120                 putchar('\n');
    121140                break;
    122141        case vc_string:
    123                 printf("%s\n", var->u.string_v->value);
     142                printf("%s", var->u.string_v->value);
    124143                break;
    125144        default:
    126                 printf("Unimplemented: writeLine() with unsupported type.\n");
    127                 exit(1);
    128         }
    129 }
    130 
    131 /** Start an executable and wait for it to finish. */
     145                printf("Unimplemented: Write() with unsupported type.\n");
     146                exit(1);
     147        }
     148}
     149
     150/** Write a line of output.
     151 *
     152 * @param run   Runner object
     153 */
     154static void bi_fun_builtin_writeline(run_t *run)
     155{
     156#ifdef DEBUG_RUN_TRACE
     157        printf("Called Builtin.WriteLine()\n");
     158#endif
     159        bi_fun_builtin_write(run);
     160        putchar('\n');
     161}
     162
     163/** Start an executable and wait for it to finish.
     164 *
     165 * @param run   Runner object
     166 */
    132167static void bi_fun_task_exec(run_t *run)
    133168{
     
    137172        rdata_var_t *arg;
    138173        int idx, dim;
    139         char **cmd;
     174        const char **cmd;
    140175
    141176#ifdef DEBUG_RUN_TRACE
     
    178213        cmd[dim] = '\0';
    179214
    180         if (os_exec(cmd) != EOK) {
     215        if (os_exec((char * const *)cmd) != EOK) {
    181216                printf("Error: Exec failed.\n");
    182217                exit(1);
Note: See TracChangeset for help on using the changeset viewer.