示例#1
0
 def chk_sequential(self, head, level):
     nlevel = level + self._l
     for n in thinutils.chain_iter(head):
         k = iirs.Get_Kind(n)
         self.chk_level(n, iirs.Get_Location(n), level)
         if k == iirs.Iir_Kind.If_Statement:
             self.chk_if_stmt(n, level)
         elif (k == iirs.Iir_Kind.For_Loop_Statement
               or k == iirs.Iir_Kind.While_Loop_Statement):
             self.chk_sequential(iirs.Get_Sequential_Statement_Chain(n),
                                 nlevel)
             self.chk_level(n, elocs.Get_End_Location(n), level)
         elif k == iirs.Iir_Kind.Case_Statement:
             alts = iirs.Get_Case_Statement_Alternative_Chain(n)
             self.chk_case_alternatives(alts, nlevel)
             self.chk_level(n, elocs.Get_End_Location(n), level)
         elif (k == iirs.Iir_Kind.Wait_Statement
               or k == iirs.Iir_Kind.Return_Statement
               or k == iirs.Iir_Kind.Assertion_Statement
               or k == iirs.Iir_Kind.Report_Statement
               or k == iirs.Iir_Kind.Procedure_Call_Statement
               or k == iirs.Iir_Kind.Null_Statement
               or k == iirs.Iir_Kind.Exit_Statement
               or k == iirs.Iir_Kind.Next_Statement):
             pass
         elif (k == iirs.Iir_Kind.Simple_Signal_Assignment_Statement
               or k == iirs.Iir_Kind.Variable_Assignment_Statement):
             pass
         else:
             assert False, "Indent: unhandled node {}".format(
                 thinutils.kind_image(k))
 def check(self, input, ast):
     for node in thinutils.constructs_iter(ast):
         k = iirs.Get_Kind(node)
         if k not in [
                 iirs.Iir_Kind.Architecture_Body,
                 iirs.Iir_Kind.Block_Statement,
                 iirs.Iir_Kind.Entity_Declaration,
                 iirs.Iir_Kind.Generate_Statement_Body,
                 iirs.Iir_Kind.Process_Statement,
                 iirs.Iir_Kind.Sensitized_Process_Statement,
                 iirs.Iir_Kind.Procedure_Body, iirs.Iir_Kind.Function_Body
         ]:
             continue
         beg_loc = elocations.Get_Begin_Location(node)
         end_loc = elocations.Get_End_Location(node)
         if beg_loc == thin.No_Location or end_loc == thin.No_Location:
             continue
         beg_file, beg_line, beg_col = Location_To_File_Line_Col(beg_loc)
         end_file, end_line, end_col = Location_To_File_Line_Col(end_loc)
         if end_col != beg_col:
             self.error(
                 Location.from_location(end_loc),
                 "'begin' and 'end' must be aligned on the same column")
         if k in iirs.Iir_Kinds.Subprogram_Body:
             if iirs.Get_Declaration_Chain(node) != thin.Null_Iir:
                 is_loc = elocations.Get_Is_Location(node)
                 is_file, is_ln, is_col = Location_To_File_Line_Col(is_loc)
                 if is_col != beg_col:
                     self.error(
                         Location.from_location(is_loc),
                         "'is' and 'begin' must be on the same column")
示例#3
0
 def chk_if_stmt(self, n, level):
     nlevel = level + self._l
     while n != thin.Null_Iir:
         # if/else/elsif
         loc = iirs.Get_Location(n)
         self.chk_level(n, loc, level)
         self.chk_sequential(iirs.Get_Sequential_Statement_Chain(n), nlevel)
         self.chk_level(n, elocs.Get_End_Location(n), level)
         n = iirs.Get_Else_Clause(n)
示例#4
0
 def chk_concurrent(self, head, level):
     nlevel = level + self._l
     for n in thinutils.chain_iter(head):
         self.chk_level(n, iirs.Get_Location(n), level)
         k = iirs.Get_Kind(n)
         if k == iirs.Iir_Kind.Component_Instantiation_Statement:
             # TODO
             pass
         elif (k == iirs.Iir_Kind.Concurrent_Assertion_Statement
               or k == iirs.Iir_Kind.Concurrent_Simple_Signal_Assignment
               or k ==
                 iirs.Iir_Kind.Concurrent_Conditional_Signal_Assignment
               or k == iirs.Iir_Kind.Concurrent_Selected_Signal_Assignment):
             pass
         elif k == iirs.Iir_Kind.Concurrent_Procedure_Call_Statement:
             pass
         elif k == iirs.Iir_Kind.Block_Statement:
             self.chk_declarations(iirs.Get_Declaration_Chain(n), nlevel)
             self.chk_level(n, elocs.Get_Begin_Location(n), level)
             self.chk_concurrent(
                 iirs.Get_Concurrent_Statement_Chain(n), nlevel)
             self.chk_level(n, elocs.Get_End_Location(n), level)
         elif k == iirs.Iir_Kind.For_Generate_Statement:
             self.chk_line_or_col(
                 n, iirs.Get_Location(n), elocs.Get_Generate_Location(n))
             self.chk_generate_body(
                 iirs.Get_Generate_Statement_Body(n), level)
             self.chk_level(n, elocs.Get_End_Location(n), level)
         elif k == iirs.Iir_Kind.If_Generate_Statement:
             self.chk_line_or_col(
                 n, iirs.Get_Location(n), elocs.Get_Generate_Location(n))
             self.chk_generate_body(
                 iirs.Get_Generate_Statement_Body(n), level)
             self.chk_level(n, elocs.Get_End_Location(n), level)
         elif (k == iirs.Iir_Kind.Sensitized_Process_Statement
               or k == iirs.Iir_Kind.Process_Statement):
             self.chk_declarations(iirs.Get_Declaration_Chain(n), nlevel)
             self.chk_level(n, elocs.Get_Begin_Location(n), level)
             self.chk_sequential(
                 iirs.Get_Sequential_Statement_Chain(n), nlevel)
             self.chk_level(n, elocs.Get_End_Location(n), level)
示例#5
0
 def chk_declarations(self, head, level):
     nlevel = level + self._l
     for n in thinutils.chain_iter(head):
         k = iirs.Get_Kind(n)
         if k == iirs.Iir_Kind.Constant_Declaration \
            or k == iirs.Iir_Kind.Signal_Declaration \
            or k == iirs.Iir_Kind.Variable_Declaration \
            or k == iirs.Iir_Kind.File_Declaration \
            or k == iirs.Iir_Kind.Object_Alias_Declaration \
            or k == iirs.Iir_Kind.Attribute_Declaration \
            or k == iirs.Iir_Kind.Attribute_Specification:
             self.chk_level(n, elocs.Get_Start_Location(n), level)
         elif (k == iirs.Iir_Kind.Configuration_Specification
               or k == iirs.Iir_Kind.Disconnection_Specification):
             self.chk_level(n, iirs.Get_Location(n), level)
         elif (k == iirs.Iir_Kind.Subtype_Declaration
               or k == iirs.Iir_Kind.Type_Declaration
               or k == iirs.Iir_Kind.Anonymous_Type_Declaration):
             self.chk_level(n, elocs.Get_Start_Location(n), level)
         elif k == iirs.Iir_Kind.Component_Declaration:
             self.chk_level(n, elocs.Get_Start_Location(n), level)
             self.chk_level(n, elocs.Get_Generic_Location(n), nlevel)
             self.chk_level(n, elocs.Get_Port_Location(n), nlevel)
             self.chk_level(n, elocs.Get_End_Location(n), level)
         elif (k == iirs.Iir_Kind.Function_Declaration
               or k == iirs.Iir_Kind.Procedure_Declaration):
             self.chk_level(n, elocs.Get_Start_Location(n), level)
         elif (k == iirs.Iir_Kind.Function_Body
               or k == iirs.Iir_Kind.Procedure_Body):
             self.chk_declarations(iirs.Get_Declaration_Chain(n), nlevel)
             self.chk_level(n, elocs.Get_Begin_Location(n), level)
             self.chk_sequential(
                 iirs.Get_Sequential_Statement_Chain(n), nlevel)
             self.chk_level(n, elocs.Get_End_Location(n), level)
             # check start
         elif k == iirs.Iir_Kind.Use_Clause:
             self.chk_level(n, iirs.Get_Location(n), level)
         else:
             assert False, "unhandled declaration {}".format(
                 thinutils.kind_image(k))
示例#6
0
 def chk_library_unit(self, n, level):
     k = iirs.Get_Kind(n)
     nlevel = level + self._l
     self.chk_level(n, elocs.Get_Start_Location(n), level)
     if k == iirs.Iir_Kind.Package_Declaration \
        or k == iirs.Iir_Kind.Package_Body:
         self.chk_declarations(iirs.Get_Declaration_Chain(n), nlevel)
     elif k == iirs.Iir_Kind.Entity_Declaration:
         self.chk_level(n, elocs.Get_Generic_Location(n), nlevel)
         self.chk_level(n, elocs.Get_Port_Location(n), nlevel)
         self.chk_declarations(iirs.Get_Declaration_Chain(n), nlevel)
         self.chk_level(n, elocs.Get_Begin_Location(n), level)
         self.chk_concurrent(iirs.Get_Concurrent_Statement_Chain(n), nlevel)
     elif k == iirs.Iir_Kind.Architecture_Body:
         self.chk_declarations(iirs.Get_Declaration_Chain(n), nlevel)
         self.chk_level(n, elocs.Get_Begin_Location(n), level)
         self.chk_concurrent(iirs.Get_Concurrent_Statement_Chain(n), nlevel)
     elif k == iirs.Iir_Kind.Configuration_Declaration:
         self.chk_declarations(iirs.Get_Declaration_Chain(n), nlevel)
         # TODO: block configuration
     else:
         assert False, "unhandled unit {}".format(thinutils.kind_image(k))
     self.chk_level(n, elocs.Get_End_Location(n), level)