From 0086d54e1968d04c1c5cc5468f4360bac7bc3105 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Mon, 27 Sep 2021 19:30:24 +0000 Subject: [PATCH] decoder/parser: generate methods, not functions --- src/openpower/decoder/pseudo/parser.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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) -- 2.30.2