[英]Specman reflection: How to use get_method()?
Hi I would like to write a general method check_range()
that gets as parameter raw_type
( vin
or vout
or il
etc.) and according to the raw_type
calls relevant method calc_vin()
or calc_vout()
etc. I try to use reflection get_method()
for it: 您好我想编写一个通用方法
check_range()
是获取作为参数raw_type
( vin
或vout
或il
等),并根据raw_type
调用相关的方法calc_vin()
或calc_vout()
等,我尝试使用反射get_method()
:
type raw_t : [vin, vout, il, iin];
...
extend my_unit {
check_range(raw_type : raw_t) : uint {
var meth_name : string = appendf("calc_%s", raw_type);
var meth : rf_method = me.get_method(meth_name); //This line causes an error
// ....
};
calc_vout() is {
// Calculates Vout
};
};
When I invoke the check_range()
method I get the error : 当我调用
check_range()
方法时, 出现错误 :
Error: 'me' (of type my_unit_u) does not have 'get_method()' method.
How can I approach the calc_vout()
method using reflection get_method()
? 我怎样才能接近
calc_vout()
使用方法反射get_method()
Really appreciate your help 非常感谢您的帮助
In order to work with the reflection facility, you need to use the "rf_struct" of my_unit_u. 为了使用反射工具,您需要使用my_unit_u的“ rf_struct”。
Specifically, try the following: 具体来说,请尝试以下操作:
type raw_t : [vin, vout, il, iin];
...
extend my_unit {
check_range(raw_type : raw_t) : uint {
var meth_name : string = appendf("calc_%s", raw_type);
var my_unit_rf := rf_manager.get_struct_of_instance(me);
var meth : rf_method = my_unit_rf.get_method(meth_name);
// ....
};
calc_vout() is {
// Calculates Vout
};
}; };
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.