From: Dmitry Selyutin Date: Mon, 27 Sep 2021 19:30:24 +0000 (+0000) Subject: decoder/parser: generate methods, not functions X-Git-Tag: sv_maxu_works-initial~820 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0086d54e1968d04c1c5cc5468f4360bac7bc3105;p=openpower-isa.git decoder/parser: generate methods, not functions --- diff --git a/src/openpower/decoder/pseudo/parser.py b/src/openpower/decoder/pseudo/parser.py index cb22c6a9..cc7f1292 100644 --- a/src/openpower/decoder/pseudo/parser.py +++ b/src/openpower/decoder/pseudo/parser.py @@ -378,10 +378,11 @@ class PowerParser: def p_parameters(self, p): """parameters : LPAR RPAR | LPAR varargslist RPAR""" - if len(p) == 3: - args = [] - else: - args = p[2] + args = [] + if self.helper: + args.append("self") + if len(p) != 3: + args += p[2] p[0] = ast.arguments(args=args, vararg=None, kwarg=None, defaults=[]) # during the time between parameters identified and suite is not # there is a window of opportunity to declare the function parameters @@ -951,6 +952,8 @@ class GardenSnakeParser(PowerParser): def parse(self, code): # self.lexer.input(code) result = self.parser.parse(code, lexer=self.lexer, debug=self.debug) + if self.helper: + result = [ast.ClassDef("ISACallerFnHelper", [], [], result, decorator_list=[])] return ast.Module(result)