WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.2% of users enabled 2FA.

instructionstocases.py 824 Bytes
Newer Older
Kunshan Wang's avatar
Kunshan Wang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
"""
Generate match cases to match against instructions.
"""

from refimpl2injectablefiles import _refimpl2_root
import injecttools

import os.path, sys
import re

case_class_r = re.compile(r'case class (\w+)\(([^)]*)\)', re.MULTILINE)

param_r = re.compile(r'va[lr]\s+(\w+)\s*:\s*([a-zA-Z0-9\[\]_]+)', re.MULTILINE)

ssavariables_path = os.path.join(_refimpl2_root, "src/main/scala/uvm/ssavariables/ssavariables.scala")

def main():
    with open(ssavariables_path) as f:
        txt = f.read()

    txt = injecttools.extract_lines(txt, "EXTRACT:BEGIN:INSTS", "EXTRACT:END:INSTS")

    for name, params in case_class_r.findall(txt):
        pns = []
        for pn, pt in param_r.findall(params):
            pns.append(pn)

        print("case {}({}) => ".format(name, ", ".join(pns)))

if __name__=="__main__":
    main()