En Specman, pourquoi est mon label macro pour le corps de code poubelle retour?

StackOverflow https://stackoverflow.com/questions/3774300

  •  04-10-2019
  •  | 
  •  

Question

Dans le même à ce poste http://feedproxy.google.com/~r/cadence/community/blogs/fv/~3/IvdCIla8_Es/extending-multiple-when-subtypes-simultaneously.aspx

Je veux faire une macro qui fait la boucle pour se déplacer dérouler quelques-unes des quand-sous-typage et les questions d'héritage Specman a.

J'ai commencé avec:

-- macros.e
<'
define <FOREACH_UNROLL'action> "FOREACH_UNROLL (<UNROLLEES>\[<unrollee'name>,...\]) (<STATEMENTS>{<statement>;...})" as computed {
   print <UNROLLEES>;
   print str_split(<UNROLLEES>,"/ *, */");
   for each in str_split(<UNROLLEES>,"/ *, */") {
      out(it.as_a(string));
      var statements := str_replace( <STATEMENTS>,"\"REPLACE_ME\"",it);
      result =appendf("%s %s;",result,statements);
   };
};
'>


-- main.e
<'
import macros.e
extend sys {
   run() is also {
      FOREACH_UNROLL [baz,foo,bar] {
         out("REPLACE_ME");
         out("part2","REPLACE_ME");
      };
   };
};
'>

Quand je cours, je reçois:

specman -c 'load $HOME/main; test'
Welcome to Specman Elite(64) (08.20.007-s)  -  Linked on Tue Dec 15 17:07:26
2009

Protected by U.S. Patents 6,141,630 ;6,182,258; 6,219,809; 6,347,388;
6,487,704; 6,499,132; 6,502,232; 6,519,727; 6,530,054; 6,675,138; 6,684,359;
6,687,662; 6,907,599; 6,918,076; 6,920,583; Other Patents Pending.

0 notifications were modified by command 'set notify -severity=WARNING
DEPR_START_TCM_ARG_BY_REF'
Checking license ... OK
Loading macros.e   (imported by main.e) ...
read...parse...update...patch...h code...code...clean...
Loading /nfs/pdx/home/rbroger1/main.e ...
read...parse...  <UNROLLEES> = "[35]"
  str_split(<UNROLLEES>,"/ *, */") =
0.      "[35]"
[35]
update...patch...h code...code...clean...
Doing setup ...
Generating the test using seed 1...

Starting the test ...
Running the test ...
REPLACE_ME
part2REPLACE_ME
No actual running requested.
Checking the test ...
Checking is complete - 0 DUT errors, 0 DUT warnings.

Si vous regardez l'impression de <UNROLLEES>:

<UNROLLEES> = "[35]"

Pourquoi est-ce <UNROLLEES> me donner [35] au lieu du corps à l'intérieur des accolades? 35 est la valeur ascii pour #, donc je suis à une perte pour laquelle je recevrais un 35 ...

P.S. Je me rends compte des macros sont du diable, mais je pense que la copie de code est pire. Je dois le faire parce que Specman est pas vraiment polymorphes.

Était-ce utile?

La solution

Il se trouve que je devais utiliser la fonction str_expand_dots dans ma version de Specman (8.2).

Voici le macros.e modifié:

define <FOREACH_UNROLL'action> "FOREACH_UNROLL (<UNROLLEES>\[<unrollee'name>,...\]) (<STATEMENTS>{<statement>;...})" as computed {
   -- print str_expand_dots(<UNROLLEES>);
   --print str_expand_dots(<STATEMENTS>);
   -- print str_split(str_expand_dots(<UNROLLEES>),"/ *, */");
   for each  in str_split(str_expand_dots(<UNROLLEES>),"/ *, */") {
      var unrollee := str_replace(it, "[","");
      unrollee = str_replace(unrollee, "]","");
      --out(unrollee);
      var statements := str_replace( str_expand_dots(<STATEMENTS>),"\"REPLACE_ME\"",unrollee);
      result =appendf("%s %s;",result,statements);
   };
};

modifié main.e:

import macros;
extend sys {
   run() is also {
      FOREACH_UNROLL ["baz","foo","bar"] {
         out("REPLACE_ME");
         out("part2","REPLACE_ME");
         if "REPLACE_ME" == "baz" {
            out("found baz");
         };
      };
   };
};

Et la sortie:

Welcome to Specman Elite(64) (08.20.007-s)  -  Linked on Tue Dec 15 17:07:26
2009

Protected by U.S. Patents 6,141,630 ;6,182,258; 6,219,809; 6,347,388;
6,487,704; 6,499,132; 6,502,232; 6,519,727; 6,530,054; 6,675,138; 6,684,359;
6,687,662; 6,907,599; 6,918,076; 6,920,583; Other Patents Pending.

0 notifications were modified by command 'set notify -severity=WARNING
DEPR_START_TCM_ARG_BY_REF'
Checking license ... OK
Loading /nfs/pdx/home/rbroger1/macros.e   (imported by main.e) ...
read...parse...update...patch...h code...code...clean...
Loading /nfs/pdx/home/rbroger1/main.e ...
read...parse...update...patch...h code...code...clean...
Doing setup ...
Generating the test using seed 1...

Starting the test ...
Running the test ...
baz
part2baz
found baz
foo
part2foo
bar
part2bar
No actual running requested.
Checking the test ...
Checking is complete - 0 DUT errors, 0 DUT warnings.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top