Changeset c7d35a585321cd3187bd956d71ba5cca13788500

Show
Ignore:
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:
5 modified

Legend:

Unmodified
Added
Removed
  • include/crules/opcodes.h

    r97bcdcf rc7d35a5  
    5151#define TYPE_BOOLEAN           0xF028 
    5252#define TYPE_OBJECT            0xF029 
    53 #define TYPE_BUILTIN           0xF02A 
     53#define TYPE_BUILTIN_CALLBACK  0xF02A 
    5454 
    5555#define SYMBOL_REFERENCE       0xF02B 
  • include/crules/symbols.h

    r6e32d3f rc7d35a5  
    3636    unsigned char character; 
    3737    char * string; 
     38    struct crl_builtin_function_def_t * callback; 
    3839    struct crl_symbol_table_t * symbol_table; 
    3940    struct crl_obj_state_t * object_state; 
     
    4647    bool boolean; 
    4748    unsigned char character; 
    48     char *string; 
     49    char * string; 
     50    struct crl_builtin_function_def_t * callback; 
    4951    struct crl_symbol_table_t * symbol_table; 
    5052    struct crl_obj_state_t * object_state; 
  • src/gg_garbage.c

    r11b18d6 rc7d35a5  
    263263    } 
    264264  else 
    265     crl_error("freeing null hash table!\n"); 
     265    { 
     266      crl_error("freeing null hash table!\n"); 
     267    } 
    266268} 
    267269 
     
    303305    } 
    304306 
    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} 
  • src/rr_context.c

    r6e32d3f rc7d35a5  
    211211    { 
    212212      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", 
    214214                 identifier, h ); 
    215215 
     
    287287crl_rr_context_clone_n_prot( struct crl_number_prot_t * prot ) 
    288288{ 
    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 
     311bool crl_rr_context_init_member_functions( crl_branch_context * context , 
    293312                                           struct crl_builtin_function_def_t * functions ) 
    294313{ 
    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; 
    296351} 
    297352 
  • src/rr_runtime.c

    r6e32d3f rc7d35a5  
    534534          break; 
    535535 
    536         case TYPE_BUILTIN: 
    537           crl_fatal("not implemented yet!\n"); 
    538           break; 
    539  
    540536        case TYPE_SYMBOL_NIL: 
    541537          retval->op_a.symbol_table= NULL; 
     
    608604        case TYPE_OBJECT: 
    609605          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"); 
    614606          break; 
    615607