Method: RCSimCinterface.rcsim_add_concat_expressions

Defined in:
ext/hruby_sim/hruby_rcsim_build.c

.rcsim_add_concat_expressions(concatV, exprVs) ⇒ Object

Adds expressions to a C concat.



1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1486

VALUE rcsim_add_concat_expressions(VALUE mod, VALUE concatV, VALUE exprVs) {
    /* Get the C concat from the Ruby value. */
    Concat concat;
    value_to_rcsim(ConcatS,concatV,concat);
    // printf("rcsim_add_concat_expressions with concat=%p\n",concat);
    /* Prepare the size for the expressions. */
    long num = RARRAY_LEN(exprVs);
    long old_num = concat->num_exprs;
    // printf("add_concat_expressions with num=%li old_num=%li\n",num,old_num);
    concat->num_exprs += num;
    // printf("first concat->exprs=%p\n",concat->exprs); fflush(stdout);
    concat->exprs = realloc(concat->exprs,
            sizeof(Expression[concat->num_exprs]));
    // concat->exprs = (Expression*)my_realloc(concat->exprs,
    //         sizeof(Expression[old_num]), sizeof(Expression[concat->num_exprs]));
    // printf("now concat->exprs=%p\n",concat->exprs); fflush(stdout);
    // printf("access test: %p\n",concat->exprs[0]); fflush(stdout);
    /* Get and add the expressions from the Ruby value. */
    for(long i=0; i< num; ++i) {
        Expression expr;
        // show_access(concat->exprs,old_num+i);
        value_to_rcsim(ExpressionS,rb_ary_entry(exprVs,i),expr);
        concat->exprs[old_num + i] = expr;
    }
    return concatV;
}