jdeans289 / icg2

Interface Code Generator 2: Electric Boogaloo
Other
0 stars 2 forks source link

Variable is Undeclared in Checkpoint File #43

Closed Mrockwell2 closed 10 months ago

Mrockwell2 commented 10 months ago

I'm not sure if this is how it's supposed to act, but supplying an allocation when declaring a variable with the MemoryManager leads to it not being declared in the checkpoint file. The following code:

double *dub_p, **dub_p_p;
dub_p = (double *) memoryManager.declare_var("double d");
dub_p_p = (double **) memoryManager.declare_var("double * d_ptr", &dub_p);
*dub_p = 5.5;

memoryManager.write_checkpoint("checkpoint.txt");

results in a checkpoint file that declares d and assigns the values of both d and d_ptr. Notably, d_ptr is not declared within the file.

Mrockwell2 commented 10 months ago

Also if I assign the value after the MemoryManager declares the variable, it is declared correctly in the checkpoint file.

jdeans289 commented 10 months ago

This is expected. Allocations that are "local" declared, meaning that the memory manager allocates them, appear as declarations in the checkpoint files. Allocations that are "extern" declared, meaning that they allocated outside the memory manager and then registered with a supplied allocation, are not declared in the checkpoint file.

Perhaps I should write some clarifying docs explaining local vs extern allocs? This is the same way that the current Trick memory manager works, but the only difference is supplying the allocation instead of explicitly calling different functions.

https://nasa.github.io/trick/documentation/simulation_capabilities/memory_manager/MemoryManager#registering-an-object

Mrockwell2 commented 10 months ago

Looks like intended behavior