开发者

specman e macros loop

i am trying to write a macro (not computed) that define instances with a loop , for example if it was a computed macro it would have been :

define <def_struct'statement> "def_struct <str_name'name> <number'num> to <other'name>" as computed {

         result.add(appendf("extend %s { ", <other'n开发者_开发技巧ame> ) );
                 for i from 0 to <number'num> do {
                    result.add(appendf("%s_%d : %s;", <str_name'name> ,i,<str_name'name> ));
                 };
          result.add("};"); }

is it possible to do the same with a macro that is not a computed macro ??

i probably have something wrong with the syntax , but look at the idea..


In your computed as example, you're creating a bunch of instances of the same class. Why not instantiate a list of structs?

myStructs : list of MyStruct_s;

If you need to, you can constraint each item in the list based on index like:

keep for each (s) using index (i) in myStructs {
    i==0 => s.fooBar == BAZ;
    s.name == appendf("this is struct %d",i);
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜