1

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

Halona
  • 1,475
  • 1
  • 15
  • 26

2 Answers2

3

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.

Raz
  • 175
  • 5
3

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.

Yuri Tsoglin
  • 963
  • 4
  • 7