Exemplo n.º 1
0
 def generate_testdata(self):
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             if type(assign) != TypeAssignment:
                 # ValueAssignment: generate_values()
                 continue
             self.process_TypeAssignment(assign)
Exemplo n.º 2
0
def parse(pickle_file):
    files = [asn1_file]
    incdirs = []
    logger.info("parsing ASN1")
    defmods, refmods = realise(incdirs, files)

    returns = []
    calls = []
    others = []

    for mod_name, module in defmods.items():

        for sorted_ass in dependency_sort(module.assignments):
            for ass in sorted_ass:
                if ass.type_name.endswith("-Return"):
                    returns.append(ass)
                elif ass.type_name.endswith("-Call"):
                    calls.append(ass)
                else:
                    others.append(ass)

    data = {'returns': returns, 'calls': calls, 'others': others}

    with open(pickle_file, 'wb') as f:
        pickle.dump(data, f)
    return data
Exemplo n.º 3
0
 def generate_testdata(self):
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             if type(assign) != TypeAssignment:
                 # ValueAssignment: generate_values()
                 continue
             self.process_TypeAssignment(assign)
Exemplo n.º 4
0
 def generate_overlay(self):
     self.writeln()
     self.writeln()
     self.writeln('/* Overlay structures with ASN.1 derived nesting and labelling */')
     self.writeln()
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             self.generate_overlay_node(assign, None, None)
Exemplo n.º 5
0
 def generate_overlay(self):
     self.writeln()
     self.writeln()
     self.writeln('/* Overlay structures with ASN.1 derived nesting and labelling */')
     self.writeln()
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             self.generate_overlay_node(assign, None, None)
Exemplo n.º 6
0
 def generate_classes(self):
     self.writeln('#')
     self.writeln('# Classes for ASN.1 type assignments')
     self.writeln('#')
     self.writeln()
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             if type(assign) != TypeAssignment:
                 # ValueAssignment: generate_values()
                 continue
             self.pygenTypeAssignment(assign)
Exemplo n.º 7
0
 def generate_classes(self):
     self.writeln('#')
     self.writeln('# Classes for ASN.1 type assignments')
     self.writeln('#')
     self.writeln()
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             if type(assign) != TypeAssignment:
                 # ValueAssignment: generate_values()
                 continue
             self.pygenTypeAssignment(assign)
Exemplo n.º 8
0
 def generate_values(self):
     self.writeln('#')
     self.writeln('# Variables with ASN.1 value assignments')
     self.writeln('#')
     self.writeln()
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             if type(assign) != ValueAssignment:
                 # TypeAssignemnts: generate_classes()
                 continue
                 # TODO# Need generic mapping to DER values
             self.pygenValueAssignment(assign)
Exemplo n.º 9
0
 def generate_values(self):
     self.writeln('#')
     self.writeln('# Variables with ASN.1 value assignments')
     self.writeln('#')
     self.writeln()
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             if type(assign) != ValueAssignment:
                 # TypeAssignemnts: generate_classes()
                 continue
                 # TODO# Need generic mapping to DER values
             self.pygenValueAssignment(assign)
Exemplo n.º 10
0
 def generate_pack(self):
     self.writeln()
     self.writeln()
     self.writeln('/* Parser definitions in terms of ASN.1 derived bytecode instructions */')
     self.writeln()
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             tnm = type(assign)
             if tnm in self.pack_funmap:
                 self.pack_funmap[tnm](assign)
             else:
                 raise Exception('No pack generator for ' + str(tnm))
Exemplo n.º 11
0
 def generate_pack(self):
     self.writeln()
     self.writeln()
     self.writeln('/* Parser definitions in terms of ASN.1 derived bytecode instructions */')
     self.writeln()
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             tnm = type(assign)
             if tnm in self.pack_funmap:
                 self.pack_funmap[tnm](assign)
             else:
                 raise Exception('No pack generator for ' + str(tnm))
Exemplo n.º 12
0
 def generate_psub(self):
     self.writeln()
     self.writeln()
     self.writeln('/* Recursive parser-sub definitions in support of SEQUENCE OF and SET OF */')
     self.writeln()
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             tnm = type(assign)
             if tnm in self.psub_funmap:
                 dprint('Recursive call for', tnm)
                 self.psub_funmap[tnm](assign, None, None, True)
                 dprint('Recursion done for', tnm)
             else:
                 raise Exception('No psub generator for ' + str(tnm))
Exemplo n.º 13
0
 def generate_psub(self):
     self.writeln()
     self.writeln()
     self.writeln('/* Recursive parser-sub definitions in support of SEQUENCE OF and SET OF */')
     self.writeln()
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             tnm = type(assign)
             if tnm in self.psub_funmap:
                 dprint('Recursive call for', tnm)
                 self.psub_funmap[tnm](assign, None, None, True)
                 dprint('Recursion done for', tnm)
             else:
                 raise Exception('No psub generator for ' + str(tnm))
Exemplo n.º 14
0
 def generate_pack(self):
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             self.generate_pack_node(assign, None, None)
Exemplo n.º 15
0
 def generate_pack(self):
     for assigncompos in dependency_sort(self.semamod.assignments):
         for assign in assigncompos:
             self.generate_pack_node(assign, None, None)
Exemplo n.º 16
0
 def walk (self):
     assignment_components = dependency_sort (self.sema_module.assignments)
     for component in assignment_components:
         for assignment in component:
             self.gen_dispatch (assignment)