1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 00:20:08 +00:00

bitbake: Add codeparser for parsing shell and python functions

This commit is derived from Chris Larson's checksum work, turned into a
standalone piece of code for parsing python and shell functions.

The deindent code has been replaced with code to work around indentation
for speed. The original NodeVisitor in the ast was replaced with a faster
class walk call.

Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
Richard Purdie
2010-08-02 10:20:20 +01:00
parent 13fdd4ae5d
commit 3492bff64a
2 changed files with 276 additions and 3 deletions
+3 -3
View File
@@ -46,7 +46,7 @@ class VariableParse:
self.value = val
self.references = set()
self.funcrefs = set()
self.execs = set()
def var_sub(self, match):
key = match.group()[2:-1]
@@ -64,10 +64,10 @@ class VariableParse:
code = match.group()[3:-1]
codeobj = compile(code.strip(), self.varname or "<expansion>", "eval")
parser = bb.rptest.PythonParser()
parser = bb.codeparser.PythonParser()
parser.parse_python(code)
self.references |= parser.references
self.funcrefs |= parser.execs
self.execs |= parser.execs
value = utils.better_eval(codeobj, {"d": self.d})
return str(value)