Method: RCSimCinterface.rcsim_add_hcase_whens
- Defined in:
- ext/hruby_sim/hruby_rcsim_build.c
.rcsim_add_hcase_whens(hcaseV, matchVs, stmntVs) ⇒ Object
Adds whens to a C hardware case.
1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1367 VALUE rcsim_add_hcase_whens(VALUE mod, VALUE hcaseV, VALUE matchVs, VALUE stmntVs) { /* Get the C hardware case from the Ruby value. */ HCase hcase; value_to_rcsim(HCaseS,hcaseV,hcase); // printf("rcsim_add_hcase_whens with hcase=%p\n",hcase); /* Prepare the size for the noifs. */ long num = RARRAY_LEN(matchVs); long old_num = hcase->num_whens; hcase->num_whens += num; // printf("first hcase->matches=%p\n",hcase->matches); fflush(stdout); // printf("first hcase->stmnts=%p\n",hcase->stmnts); fflush(stdout); hcase->matches = realloc(hcase->matches, sizeof(Expression[hcase->num_whens])); // hcase->matches = (Expression*)my_realloc(hcase->matches, // sizeof(Expression[old_num]), sizeof(Expression[hcase->num_whens])); // printf("now hcase->matches=%p\n",hcase->matches); fflush(stdout); // printf("access test: %p\n",hcase->matches[0]); fflush(stdout); hcase->stmnts = realloc(hcase->stmnts, sizeof(Statement[hcase->num_whens])); // hcase->stmnts = (Statement*)my_realloc(hcase->stmnts, // sizeof(Statement[old_num]), sizeof(Statement[hcase->num_whens])); // printf("now hcase->stmnts=%p\n",hcase->stmnts); fflush(stdout); // printf("access test: %p\n",hcase->stmnts[0]); fflush(stdout); /* Get and add the whens from the Ruby value. */ for(long i=0; i< num; ++i) { Expression match; Statement stmnt; // show_access(hcase->matches,old_num+i); // show_access(hcase->stmnts,old_num+i); value_to_rcsim(ExpressionS,rb_ary_entry(matchVs,i),match); hcase->matches[old_num + i] = match; value_to_rcsim(StatementS,rb_ary_entry(stmntVs,i),stmnt); hcase->stmnts[old_num + i] = stmnt; } return hcaseV; } |