Changeset 39e8406 in mainline for uspace/app/sbi/src/builtin.c
- Timestamp:
- 2010-03-20T21:57:13Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b535aeb
- Parents:
- 6ba20a6b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/builtin.c
r6ba20a6b r39e8406 44 44 static stree_symbol_t *builtin_declare_fun(stree_csi_t *csi, const char *name); 45 45 static void builtin_fun_add_arg(stree_symbol_t *fun_sym, const char *name); 46 static void builtin_fun_add_vararg(stree_symbol_t *fun_sym, const char *name); 46 static void builtin_fun_add_vararg(stree_symbol_t *fun_sym, const char *name, 47 stree_texpr_t *type); 48 49 static stree_texpr_t *builtin_mktype_string_array(void); 47 50 48 51 static void builtin_write_line(run_t *run); … … 86 89 87 90 bi_exec = builtin_declare_fun(csi, "Exec"); 88 builtin_fun_add_vararg(bi_exec, "args"); 89 } 90 91 void builtin_run_proc(run_t *run, stree_symbol_t *proc_sym) 92 { 91 builtin_fun_add_vararg(bi_exec, "args", 92 builtin_mktype_string_array()); 93 } 94 95 void builtin_run_proc(run_t *run, stree_proc_t *proc) 96 { 97 stree_symbol_t *fun_sym; 98 93 99 #ifdef DEBUG_RUN_TRACE 94 100 printf("Run builtin procedure.\n"); 95 101 #endif 96 if (proc_sym == bi_write_line) { 102 fun_sym = proc->outer_symbol; 103 104 if (fun_sym == bi_write_line) { 97 105 builtin_write_line(run); 98 } else if ( proc_sym == bi_exec) {106 } else if (fun_sym == bi_exec) { 99 107 builtin_exec(run); 100 108 } else { … … 109 117 stree_fun_t *fun; 110 118 stree_csimbr_t *csimbr; 111 stree_symbol_t * symbol;119 stree_symbol_t *fun_sym; 112 120 113 121 ident = stree_ident_new(); … … 116 124 fun = stree_fun_new(); 117 125 fun->name = ident; 118 fun->body = NULL; 126 fun->proc = stree_proc_new(); 127 fun->proc->body = NULL; 119 128 list_init(&fun->args); 120 129 … … 122 131 csimbr->u.fun = fun; 123 132 124 symbol = stree_symbol_new(sc_fun); 125 symbol->u.fun = fun; 126 symbol->outer_csi = csi; 127 fun->symbol = symbol; 133 fun_sym = stree_symbol_new(sc_fun); 134 fun_sym->u.fun = fun; 135 fun_sym->outer_csi = csi; 136 fun->symbol = fun_sym; 137 fun->proc->outer_symbol = fun_sym; 128 138 129 139 list_append(&csi->members, csimbr); 130 140 131 return symbol;141 return fun_sym; 132 142 } 133 143 … … 150 160 151 161 /** Add variadic formal parameter to function. */ 152 static void builtin_fun_add_vararg(stree_symbol_t *fun_sym, const char *name) 162 static void builtin_fun_add_vararg(stree_symbol_t *fun_sym, const char *name, 163 stree_texpr_t *type) 153 164 { 154 165 stree_proc_arg_t *proc_arg; … … 161 172 proc_arg->name = stree_ident_new(); 162 173 proc_arg->name->sid = strtab_get_sid(name); 163 proc_arg->type = NULL; /* XXX */174 proc_arg->type = type; 164 175 165 176 fun->varg = proc_arg; 177 } 178 179 /** Construct a @c string[] type expression. */ 180 static stree_texpr_t *builtin_mktype_string_array(void) 181 { 182 stree_texpr_t *tstring; 183 stree_texpr_t *tsarray; 184 stree_tliteral_t *tliteral; 185 stree_tindex_t *tindex; 186 187 /* Construct @c string */ 188 tstring = stree_texpr_new(tc_tliteral); 189 tliteral = stree_tliteral_new(tlc_string); 190 tstring->u.tliteral = tliteral; 191 192 /* Construct the indexing node */ 193 tsarray = stree_texpr_new(tc_tindex); 194 tindex = stree_tindex_new(); 195 tsarray->u.tindex = tindex; 196 197 tindex->base_type = tstring; 198 tindex->n_args = 1; 199 list_init(&tindex->args); 200 201 return tsarray; 166 202 } 167 203
Note:
See TracChangeset
for help on using the changeset viewer.