Permalink
Please sign in to comment.
Browse files
Move OPy shell functions out of run.sh.
- Line counts are now in count.sh, and enhanced. - compare-opcodes updated and moved to new metrics.sh script> - Remove a function now in fix.sh.
- Loading branch information...
Showing
with
88 additions
and 46 deletions.
- +3 −2 build/metrics.sh
- +47 −0 opy/count.sh
- +38 −0 opy/metrics.sh
- +0 −44 opy/run.sh
| @@ -0,0 +1,47 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Usage: | ||
| # ./count.sh <function name> | ||
| set -o nounset | ||
| set -o pipefail | ||
| set -o errexit | ||
| _count() { | ||
| xargs wc -l | sort -n | ||
| } | ||
| # 8700 lines for tokenizer -> tokens -> parser -> homogeneous nodes -> | ||
| # transformer -> ast -> compiler -> byte code | ||
| all() { | ||
| echo COMMON | ||
| echo opy_main.py util_opy.py | _count | ||
| echo | ||
| echo PARSER GENERATOR | ||
| echo pytree.py pgen2/*.py | _count | ||
| echo | ||
| # ast is generated | ||
| echo COMPILER2 | ||
| ls compiler2/*.py | grep -v ast.py | xargs wc -l | sort -n | ||
| echo | ||
| echo GENERATED CODE | ||
| wc -l compiler2/ast.py | ||
| echo | ||
| echo BYTERUN | ||
| ls byterun/*.py | grep -v 'test' | xargs wc -l | sort -n | ||
| echo | ||
| echo MISC | ||
| echo {misc,tools}/*.py | _count | ||
| echo | ||
| echo SCRIPTS | ||
| echo *.sh */*.sh | _count | ||
| echo | ||
| } | ||
| "$@" |
| @@ -0,0 +1,38 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Somewhat like build/metrics.sh for OPy. | ||
| # | ||
| # Usage: | ||
| # ./metrics.sh <function name> | ||
| set -o nounset | ||
| set -o pipefail | ||
| set -o errexit | ||
| # Compare opcodes emitted by compiler2 vs. ones defined. | ||
| compare-opcodes() { | ||
| # 67 opcodes emitted | ||
| local pat='self.emit|self.unaryOp|self.binaryOp|self._nameOp|self._implicitNameOp|INPLACE|CALL_FUNCTION' | ||
| egrep "$pat" compiler2/pycodegen.py | egrep -o '[A-Z][A-Z_]+' | | ||
| sort | uniq > _tmp/opcodes-emitted.txt | ||
| # 119 ops? | ||
| PYTHONPATH=. python2 > _tmp/opcodes-defined.txt -c ' | ||
| from compiler2 import opcode | ||
| names = sorted(opcode.opmap) | ||
| for n in names: | ||
| print(n) | ||
| ' | ||
| diff -u _tmp/opcodes-{defined,emitted}.txt | tee _tmp/opcode-diff.txt || true | ||
| # Opcodes emitted but not defined? This is approximate because some opcodes | ||
| # are dynamically defined, like SLICE+0 vs SLICE. | ||
| grep '^+' _tmp/opcode-diff.txt | grep -v SLICE | ||
| # Found issue: VERSION=1 is still there, and UNPACK_TUPLE isn't used! | ||
| wc -l _tmp/opcodes-{defined,emitted}.txt # 119 defined | ||
| } | ||
| "$@" |
0 comments on commit
1eaa262