Changeset c7d35a585321cd3187bd956d71ba5cca13788500
- Timestamp:
- 04/20/10 20:13:47 (2 years ago)
- Author:
- Philip Herron <redbrain@…>
- Parents:
- 6e32d3f0de9260d4456ba0359ed144ba6d525952
- Children:
- c508c581f70744f8cf9cd86f23b478e88f6a7aa2
- git-committer:
- Philip Herron <redbrain@omicron.(none)> / 2010-04-20T20:13:47Z+0100
- Message:
-
intilized integer module
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r97bcdcf
|
rc7d35a5
|
|
| 51 | 51 | #define TYPE_BOOLEAN 0xF028 |
| 52 | 52 | #define TYPE_OBJECT 0xF029 |
| 53 | | #define TYPE_BUILTIN 0xF02A |
| | 53 | #define TYPE_BUILTIN_CALLBACK 0xF02A |
| 54 | 54 | |
| 55 | 55 | #define SYMBOL_REFERENCE 0xF02B |
-
|
r6e32d3f
|
rc7d35a5
|
|
| 36 | 36 | unsigned char character; |
| 37 | 37 | char * string; |
| | 38 | struct crl_builtin_function_def_t * callback; |
| 38 | 39 | struct crl_symbol_table_t * symbol_table; |
| 39 | 40 | struct crl_obj_state_t * object_state; |
| … |
… |
|
| 46 | 47 | bool boolean; |
| 47 | 48 | unsigned char character; |
| 48 | | char *string; |
| | 49 | char * string; |
| | 50 | struct crl_builtin_function_def_t * callback; |
| 49 | 51 | struct crl_symbol_table_t * symbol_table; |
| 50 | 52 | struct crl_obj_state_t * object_state; |
-
|
r11b18d6
|
rc7d35a5
|
|
| 263 | 263 | } |
| 264 | 264 | else |
| 265 | | crl_error("freeing null hash table!\n"); |
| | 265 | { |
| | 266 | crl_error("freeing null hash table!\n"); |
| | 267 | } |
| 266 | 268 | } |
| 267 | 269 | |
| … |
… |
|
| 303 | 305 | } |
| 304 | 306 | |
| 305 | | if( (*stack)->array ) |
| 306 | | crl_free( (*stack)->array ); |
| 307 | | crl_free( *stack ); |
| 308 | | } |
| | 307 | if( ((*stack)->array) ) { |
| | 308 | crl_free( ((*stack)->array) ); |
| | 309 | } |
| | 310 | crl_free( (*stack) ); |
| | 311 | } |
-
|
r6e32d3f
|
rc7d35a5
|
|
| 211 | 211 | { |
| 212 | 212 | crl_hash_t h= crl_dd_hash_hash( identifier ); |
| 213 | | crl_debug( "looking up function '%s' - hash 0x%X\n", |
| | 213 | crl_debug( "looking up defintion '%s' - hash 0x%X\n", |
| 214 | 214 | identifier, h ); |
| 215 | 215 | |
| … |
… |
|
| 287 | 287 | crl_rr_context_clone_n_prot( struct crl_number_prot_t * prot ) |
| 288 | 288 | { |
| 289 | | return NULL; |
| 290 | | } |
| 291 | | |
| 292 | | void crl_rr_context_init_member_functions( crl_branch_context * context , |
| | 289 | struct crl_number_prot_t * retval = NULL; |
| | 290 | if( prot ) |
| | 291 | { |
| | 292 | retval = crl_malloc( sizeof(struct crl_number_prot_t) ); |
| | 293 | retval->init = prot->init; |
| | 294 | retval->n_add = prot->n_add; |
| | 295 | retval->n_sub = prot->n_sub; |
| | 296 | retval->n_div = prot->n_div; |
| | 297 | retval->n_mul = prot->n_mul; |
| | 298 | retval->n_pow = prot->n_pow; |
| | 299 | retval->n_let = prot->n_let; |
| | 300 | retval->n_lee = prot->n_lee; |
| | 301 | retval->n_get = prot->n_get; |
| | 302 | retval->n_gee = prot->n_gee; |
| | 303 | retval->n_eee = prot->n_eee; |
| | 304 | retval->n_nee = prot->n_nee; |
| | 305 | retval->n_orr = prot->n_orr; |
| | 306 | retval->n_and = prot->n_and; |
| | 307 | } |
| | 308 | return retval; |
| | 309 | } |
| | 310 | |
| | 311 | bool crl_rr_context_init_member_functions( crl_branch_context * context , |
| 293 | 312 | struct crl_builtin_function_def_t * functions ) |
| 294 | 313 | { |
| 295 | | return; |
| | 314 | bool retval = true; |
| | 315 | crl_context_table * ctx = (crl_context_table *) |
| | 316 | crl_malloc( sizeof(crl_context_table) ); |
| | 317 | crl_rr_context_init_table( &ctx ); |
| | 318 | crl_rr_context_push( context, ctx ); |
| | 319 | |
| | 320 | unsigned int idx = 0; |
| | 321 | while( functions[idx].identifier != NULL ) |
| | 322 | { |
| | 323 | crl_debug("initilizing member <%s>!\n", functions[idx].identifier ); |
| | 324 | crl_symbol_obj *o; |
| | 325 | crl_symbol_init( o ); |
| | 326 | |
| | 327 | struct crl_builtin_function_def_t * call = |
| | 328 | crl_malloc( sizeof(struct crl_builtin_function_def_t) ); |
| | 329 | call->identifier = crl_strdup( functions[idx].identifier ); |
| | 330 | memcpy( &(call->n_parameters), &(functions[idx].n_parameters), |
| | 331 | sizeof(int) ); |
| | 332 | call->callback = functions[idx].callback; |
| | 333 | |
| | 334 | o->identifier = crl_strdup( functions[idx].identifier ); |
| | 335 | o->type = TYPE_BUILTIN_CALLBACK; |
| | 336 | o->op_a.callback = call; |
| | 337 | |
| | 338 | if( !(crl_rr_context_push_function_def( o, &ctx )) ) |
| | 339 | { |
| | 340 | crl_error("error inserting table defined function <%s> idx <%i>!\n", |
| | 341 | functions[idx].identifier, idx ); |
| | 342 | retval = false; |
| | 343 | return retval; |
| | 344 | } |
| | 345 | idx++; |
| | 346 | } |
| | 347 | crl_rr_context_pop( ctx ); |
| | 348 | crl_garbage_free_context_table( &ctx ); |
| | 349 | |
| | 350 | return retval; |
| 296 | 351 | } |
| 297 | 352 | |
-
|
r6e32d3f
|
rc7d35a5
|
|
| 534 | 534 | break; |
| 535 | 535 | |
| 536 | | case TYPE_BUILTIN: |
| 537 | | crl_fatal("not implemented yet!\n"); |
| 538 | | break; |
| 539 | | |
| 540 | 536 | case TYPE_SYMBOL_NIL: |
| 541 | 537 | retval->op_a.symbol_table= NULL; |
| … |
… |
|
| 608 | 604 | case TYPE_OBJECT: |
| 609 | 605 | retval->op_b.object_state = crl_rr_context_clone_obj_state( &((*sym)->op_b.object_state) ); |
| 610 | | break; |
| 611 | | |
| 612 | | case TYPE_BUILTIN: |
| 613 | | crl_fatal("not imeplemented yet!\n"); |
| 614 | 606 | break; |
| 615 | 607 | |