Reputation: 1485
I define a variable my_reg_file
in function post_access()
(this function is a vr_ad
hook for implementing side effects):
//file1.e
extend TIMER_LOAD_0 vr_ad_reg {
post_access(direction : vr_ad_rw_t) is first {
var my_reg_file : TIMER vr_ad_reg_file =
get_parents()[0].as_a(TIMER vr_ad_reg_file);
....
};
};
Then I extend this function in another e file:
//file2.e
extend TIMER_LOAD_0 vr_ad_reg {
post_access(direction : vr_ad_rw_t) is also {
start my_reg_file.some_tcm();
};
};
I get a compilation error:
*** Error: No such variable 'my_reg_file'
Why post_access()
does not recognizes the variable my_reg_file
? Thank you for your help.
Note: file1.e is imported before file2.e
Upvotes: 1
Views: 328
Reputation: 963
Another solution, which seems even better, is to add a separate method to this subtype, e.g. get_my_reg_file()
, which will return the desired value, and then call this method where this value is needed, instead of using the local variable.
Upvotes: 3
Reputation: 165
my_reg_file is a local variable, of that specific method layer, and is not shared with other method layers. I think the only way to communicate between method layers are: a. using the result saved variable which can be accessed from any method layer. b. using a struct member.
Upvotes: 3