pytunia 0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pytunia-0.1/LICENSE.txt +45 -0
- pytunia-0.1/MANIFEST.in +3 -0
- pytunia-0.1/PKG-INFO +276 -0
- pytunia-0.1/README.md +245 -0
- pytunia-0.1/pyproject.toml +45 -0
- pytunia-0.1/pytunia/__init__.py +34 -0
- pytunia-0.1/pytunia/__main__.py +7 -0
- pytunia-0.1/pytunia/api.py +106 -0
- pytunia-0.1/pytunia/classfile.py +911 -0
- pytunia-0.1/pytunia/diagnostics.py +61 -0
- pytunia-0.1/pytunia/insninfo.py +266 -0
- pytunia-0.1/pytunia/jas/__init__.py +79 -0
- pytunia-0.1/pytunia/jas/annotation.py +325 -0
- pytunia-0.1/pytunia/jas/attributes.py +225 -0
- pytunia-0.1/pytunia/jas/classenv.py +334 -0
- pytunia-0.1/pytunia/jas/code.py +281 -0
- pytunia-0.1/pytunia/jas/constants.py +328 -0
- pytunia-0.1/pytunia/jas/cp.py +208 -0
- pytunia-0.1/pytunia/jas/errors.py +26 -0
- pytunia-0.1/pytunia/jas/insn.py +520 -0
- pytunia-0.1/pytunia/jas/stackmap.py +293 -0
- pytunia-0.1/pytunia/javacompat.py +830 -0
- pytunia-0.1/pytunia/main.py +273 -0
- pytunia-0.1/pytunia/parser.py +612 -0
- pytunia-0.1/pytunia/parser_tables.py +2321 -0
- pytunia-0.1/pytunia/scanner.py +513 -0
- pytunia-0.1/pytunia/sym.py +153 -0
- pytunia-0.1/pytunia.egg-info/PKG-INFO +276 -0
- pytunia-0.1/pytunia.egg-info/SOURCES.txt +415 -0
- pytunia-0.1/pytunia.egg-info/dependency_links.txt +1 -0
- pytunia-0.1/pytunia.egg-info/top_level.txt +1 -0
- pytunia-0.1/setup.cfg +4 -0
- pytunia-0.1/tests/cases/Annotations.j +93 -0
- pytunia-0.1/tests/cases/AutoLines.j +25 -0
- pytunia-0.1/tests/cases/Constants.j +48 -0
- pytunia-0.1/tests/cases/Crlf.j +10 -0
- pytunia-0.1/tests/cases/Debug.j +35 -0
- pytunia-0.1/tests/cases/DebugG.j +35 -0
- pytunia-0.1/tests/cases/Enclosing.j +4 -0
- pytunia-0.1/tests/cases/ErrAnnFloatNeg.j +5 -0
- pytunia-0.1/tests/cases/ErrAnnNotClosed.j +6 -0
- pytunia-0.1/tests/cases/ErrAnnParam.j +6 -0
- pytunia-0.1/tests/cases/ErrAnnRange.j +5 -0
- pytunia-0.1/tests/cases/ErrAnnSig.j +5 -0
- pytunia-0.1/tests/cases/ErrAnnTooMany.j +5 -0
- pytunia-0.1/tests/cases/ErrAnnValue.j +5 -0
- pytunia-0.1/tests/cases/ErrArrayType.j +8 -0
- pytunia-0.1/tests/cases/ErrAttrFile.j +3 -0
- pytunia-0.1/tests/cases/ErrBadArgs.j +8 -0
- pytunia-0.1/tests/cases/ErrBadArgs2.j +8 -0
- pytunia-0.1/tests/cases/ErrBadArgs3.j +8 -0
- pytunia-0.1/tests/cases/ErrBadArgs4.j +8 -0
- pytunia-0.1/tests/cases/ErrBadEscape.j +8 -0
- pytunia-0.1/tests/cases/ErrBadNumber.j +8 -0
- pytunia-0.1/tests/cases/ErrBadNumber2.j +8 -0
- pytunia-0.1/tests/cases/ErrBadNumber3.j +8 -0
- pytunia-0.1/tests/cases/ErrBadNumber4.j +8 -0
- pytunia-0.1/tests/cases/ErrBadUEscape.j +8 -0
- pytunia-0.1/tests/cases/ErrBipush.j +8 -0
- pytunia-0.1/tests/cases/ErrBytecodeDouble.j +3 -0
- pytunia-0.1/tests/cases/ErrBytecodeExp.j +3 -0
- pytunia-0.1/tests/cases/ErrBytecodeInt.j +3 -0
- pytunia-0.1/tests/cases/ErrBytecodeLong.j +3 -0
- pytunia-0.1/tests/cases/ErrCatchMixed.j +8 -0
- pytunia-0.1/tests/cases/ErrDirectiveNumber.j +3 -0
- pytunia-0.1/tests/cases/ErrDollar.j +8 -0
- pytunia-0.1/tests/cases/ErrDollarBad.j +8 -0
- pytunia-0.1/tests/cases/ErrDoubleClass.j +4 -0
- pytunia-0.1/tests/cases/ErrDupLabelOk.j +11 -0
- pytunia-0.1/tests/cases/ErrEmpty.j +0 -0
- pytunia-0.1/tests/cases/ErrEmptyName.j +8 -0
- pytunia-0.1/tests/cases/ErrEndField.j +3 -0
- pytunia-0.1/tests/cases/ErrFarJump.j +33009 -0
- pytunia-0.1/tests/cases/ErrFieldNoClass.j +8 -0
- pytunia-0.1/tests/cases/ErrFieldValue.j +3 -0
- pytunia-0.1/tests/cases/ErrGloups.j +8 -0
- pytunia-0.1/tests/cases/ErrInterfaceNargs.j +8 -0
- pytunia-0.1/tests/cases/ErrLabelSyntax.j +9 -0
- pytunia-0.1/tests/cases/ErrLimit.j +6 -0
- pytunia-0.1/tests/cases/ErrLimitWord.j +6 -0
- pytunia-0.1/tests/cases/ErrMalformedSig.j +8 -0
- pytunia-0.1/tests/cases/ErrManyErrors.j +10 -0
- pytunia-0.1/tests/cases/ErrMetho.j +3 -0
- pytunia-0.1/tests/cases/ErrMissingArgs.j +8 -0
- pytunia-0.1/tests/cases/ErrNameEscape.j +8 -0
- pytunia-0.1/tests/cases/ErrNameNoSep.j +8 -0
- pytunia-0.1/tests/cases/ErrNewarrayInt.j +8 -0
- pytunia-0.1/tests/cases/ErrNoEndMethod.j +4 -0
- pytunia-0.1/tests/cases/ErrNoNewlineAtEnd.j +4 -0
- pytunia-0.1/tests/cases/ErrNoSuper.j +4 -0
- pytunia-0.1/tests/cases/ErrOnlyComments.j +3 -0
- pytunia-0.1/tests/cases/ErrRecovery.j +13 -0
- pytunia-0.1/tests/cases/ErrSet.j +10 -0
- pytunia-0.1/tests/cases/ErrSignatureOutside.j +4 -0
- pytunia-0.1/tests/cases/ErrSipush.j +8 -0
- pytunia-0.1/tests/cases/ErrStackOffset2.j +9 -0
- pytunia-0.1/tests/cases/ErrStackType.j +10 -0
- pytunia-0.1/tests/cases/ErrStackUse.j +7 -0
- pytunia-0.1/tests/cases/ErrStackUse0.j +7 -0
- pytunia-0.1/tests/cases/ErrTableHigh.j +12 -0
- pytunia-0.1/tests/cases/ErrTabs.j +5 -0
- pytunia-0.1/tests/cases/ErrUndefinedLabel.j +8 -0
- pytunia-0.1/tests/cases/ErrUnknownDirective.j +3 -0
- pytunia-0.1/tests/cases/ErrUntermName.j +8 -0
- pytunia-0.1/tests/cases/ErrUntermString.j +9 -0
- pytunia-0.1/tests/cases/ErrUntermStringEOF.j +4 -0
- pytunia-0.1/tests/cases/ErrVar.j +8 -0
- pytunia-0.1/tests/cases/FarJumpW.j +33009 -0
- pytunia-0.1/tests/cases/Fields.j +50 -0
- pytunia-0.1/tests/cases/Header.j +34 -0
- pytunia-0.1/tests/cases/Iface.j +15 -0
- pytunia-0.1/tests/cases/Instructions.j +253 -0
- pytunia-0.1/tests/cases/Latin1.j +4 -0
- pytunia-0.1/tests/cases/ManyConstants.j +2070 -0
- pytunia-0.1/tests/cases/Names.j +19 -0
- pytunia-0.1/tests/cases/NumLabels.j +29 -0
- pytunia-0.1/tests/cases/NumLabelsG.j +29 -0
- pytunia-0.1/tests/cases/StackMapOld.j +17 -0
- pytunia-0.1/tests/cases/StackMapTable.j +137 -0
- pytunia-0.1/tests/cases/Switches.j +94 -0
- pytunia-0.1/tests/cases/Unicode.j +11 -0
- pytunia-0.1/tests/cases/attr.bin +0 -0
- pytunia-0.1/tests/cases/empty.bin +0 -0
- pytunia-0.1/tests/expected/Annotations/classes/Annotations.class +0 -0
- pytunia-0.1/tests/expected/Annotations/status.txt +1 -0
- pytunia-0.1/tests/expected/Annotations/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Annotations/stdout.txt +1 -0
- pytunia-0.1/tests/expected/AutoLines/classes/AutoLines.class +0 -0
- pytunia-0.1/tests/expected/AutoLines/status.txt +1 -0
- pytunia-0.1/tests/expected/AutoLines/stderr.txt +0 -0
- pytunia-0.1/tests/expected/AutoLines/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Constants/classes/Constants.class +0 -0
- pytunia-0.1/tests/expected/Constants/status.txt +1 -0
- pytunia-0.1/tests/expected/Constants/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Constants/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Crlf/classes/Crlf.class +0 -0
- pytunia-0.1/tests/expected/Crlf/status.txt +1 -0
- pytunia-0.1/tests/expected/Crlf/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Crlf/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Debug/classes/Debug.class +0 -0
- pytunia-0.1/tests/expected/Debug/status.txt +1 -0
- pytunia-0.1/tests/expected/Debug/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Debug/stdout.txt +1 -0
- pytunia-0.1/tests/expected/DebugG/classes/DebugG.class +0 -0
- pytunia-0.1/tests/expected/DebugG/status.txt +1 -0
- pytunia-0.1/tests/expected/DebugG/stderr.txt +0 -0
- pytunia-0.1/tests/expected/DebugG/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Enclosing/classes/Enclosing$1.class +0 -0
- pytunia-0.1/tests/expected/Enclosing/status.txt +1 -0
- pytunia-0.1/tests/expected/Enclosing/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Enclosing/stdout.txt +1 -0
- pytunia-0.1/tests/expected/ErrAnnFloatNeg/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrAnnFloatNeg/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrAnnFloatNeg/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrAnnNotClosed/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrAnnNotClosed/stderr.txt +7 -0
- pytunia-0.1/tests/expected/ErrAnnNotClosed/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrAnnParam/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrAnnParam/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrAnnParam/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrAnnRange/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrAnnRange/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrAnnRange/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrAnnSig/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrAnnSig/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrAnnSig/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrAnnTooMany/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrAnnTooMany/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrAnnTooMany/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrAnnValue/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrAnnValue/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrAnnValue/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrArrayType/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrArrayType/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrArrayType/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrAttrFile/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrAttrFile/stderr.txt +2 -0
- pytunia-0.1/tests/expected/ErrAttrFile/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBadArgs/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBadArgs/stderr.txt +5 -0
- pytunia-0.1/tests/expected/ErrBadArgs/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBadArgs2/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBadArgs2/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBadArgs2/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBadArgs3/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBadArgs3/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBadArgs3/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBadArgs4/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBadArgs4/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBadArgs4/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBadEscape/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBadEscape/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBadEscape/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBadNumber/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBadNumber/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBadNumber/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBadNumber2/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBadNumber2/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBadNumber2/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBadNumber3/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBadNumber3/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBadNumber3/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBadNumber4/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBadNumber4/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBadNumber4/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBadUEscape/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBadUEscape/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBadUEscape/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBipush/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBipush/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBipush/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBytecodeDouble/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBytecodeDouble/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBytecodeDouble/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBytecodeExp/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBytecodeExp/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrBytecodeExp/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBytecodeInt/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBytecodeInt/stderr.txt +7 -0
- pytunia-0.1/tests/expected/ErrBytecodeInt/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrBytecodeLong/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrBytecodeLong/stderr.txt +7 -0
- pytunia-0.1/tests/expected/ErrBytecodeLong/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrCatchMixed/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrCatchMixed/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrCatchMixed/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrDirectiveNumber/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrDirectiveNumber/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrDirectiveNumber/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrDollar/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrDollar/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrDollar/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrDollarBad/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrDollarBad/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrDollarBad/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrDoubleClass/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrDoubleClass/stderr.txt +7 -0
- pytunia-0.1/tests/expected/ErrDoubleClass/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrDupLabelOk/classes/DupLabel.class +0 -0
- pytunia-0.1/tests/expected/ErrDupLabelOk/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrDupLabelOk/stderr.txt +0 -0
- pytunia-0.1/tests/expected/ErrDupLabelOk/stdout.txt +1 -0
- pytunia-0.1/tests/expected/ErrEmpty/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrEmpty/stderr.txt +2 -0
- pytunia-0.1/tests/expected/ErrEmpty/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrEmptyName/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrEmptyName/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrEmptyName/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrEndField/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrEndField/stderr.txt +7 -0
- pytunia-0.1/tests/expected/ErrEndField/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrFarJump/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrFarJump/stderr.txt +2 -0
- pytunia-0.1/tests/expected/ErrFarJump/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrFieldNoClass/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrFieldNoClass/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrFieldNoClass/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrFieldValue/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrFieldValue/stderr.txt +7 -0
- pytunia-0.1/tests/expected/ErrFieldValue/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrGloups/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrGloups/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrGloups/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrInterfaceNargs/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrInterfaceNargs/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrInterfaceNargs/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrLabelSyntax/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrLabelSyntax/stderr.txt +5 -0
- pytunia-0.1/tests/expected/ErrLabelSyntax/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrLimit/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrLimit/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrLimit/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrLimitWord/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrLimitWord/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrLimitWord/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrMalformedSig/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrMalformedSig/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrMalformedSig/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrManyErrors/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrManyErrors/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrManyErrors/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrMetho/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrMetho/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrMetho/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrMissingArgs/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrMissingArgs/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrMissingArgs/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrNameEscape/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrNameEscape/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrNameEscape/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrNameNoSep/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrNameNoSep/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrNameNoSep/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrNewarrayInt/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrNewarrayInt/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrNewarrayInt/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrNoEndMethod/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrNoEndMethod/stderr.txt +3 -0
- pytunia-0.1/tests/expected/ErrNoEndMethod/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrNoNewlineAtEnd/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrNoNewlineAtEnd/stderr.txt +2 -0
- pytunia-0.1/tests/expected/ErrNoNewlineAtEnd/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrNoSuper/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrNoSuper/stderr.txt +7 -0
- pytunia-0.1/tests/expected/ErrNoSuper/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrOnlyComments/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrOnlyComments/stderr.txt +2 -0
- pytunia-0.1/tests/expected/ErrOnlyComments/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrRecovery/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrRecovery/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrRecovery/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrSet/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrSet/stderr.txt +7 -0
- pytunia-0.1/tests/expected/ErrSet/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrSignatureOutside/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrSignatureOutside/stderr.txt +3 -0
- pytunia-0.1/tests/expected/ErrSignatureOutside/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrSipush/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrSipush/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrSipush/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrStackOffset2/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrStackOffset2/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrStackOffset2/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrStackType/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrStackType/stderr.txt +10 -0
- pytunia-0.1/tests/expected/ErrStackType/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrStackUse/classes/X.class +0 -0
- pytunia-0.1/tests/expected/ErrStackUse/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrStackUse/stderr.txt +0 -0
- pytunia-0.1/tests/expected/ErrStackUse/stdout.txt +1 -0
- pytunia-0.1/tests/expected/ErrStackUse0/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrStackUse0/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrStackUse0/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrTableHigh/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrTableHigh/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrTableHigh/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrTabs/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrTabs/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrTabs/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrUndefinedLabel/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrUndefinedLabel/stderr.txt +2 -0
- pytunia-0.1/tests/expected/ErrUndefinedLabel/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrUnknownDirective/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrUnknownDirective/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrUnknownDirective/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrUntermName/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrUntermName/stderr.txt +4 -0
- pytunia-0.1/tests/expected/ErrUntermName/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrUntermString/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrUntermString/stderr.txt +2 -0
- pytunia-0.1/tests/expected/ErrUntermString/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrUntermStringEOF/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrUntermStringEOF/stderr.txt +2 -0
- pytunia-0.1/tests/expected/ErrUntermStringEOF/stdout.txt +0 -0
- pytunia-0.1/tests/expected/ErrVar/status.txt +1 -0
- pytunia-0.1/tests/expected/ErrVar/stderr.txt +8 -0
- pytunia-0.1/tests/expected/ErrVar/stdout.txt +0 -0
- pytunia-0.1/tests/expected/FarJumpW/classes/FarJumpW.class +0 -0
- pytunia-0.1/tests/expected/FarJumpW/status.txt +1 -0
- pytunia-0.1/tests/expected/FarJumpW/stderr.txt +0 -0
- pytunia-0.1/tests/expected/FarJumpW/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Fields/classes/Fields.class +0 -0
- pytunia-0.1/tests/expected/Fields/status.txt +1 -0
- pytunia-0.1/tests/expected/Fields/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Fields/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Header/classes/Outer$Inner.class +0 -0
- pytunia-0.1/tests/expected/Header/status.txt +1 -0
- pytunia-0.1/tests/expected/Header/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Header/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Iface/classes/pkg/sub/Iface.class +0 -0
- pytunia-0.1/tests/expected/Iface/status.txt +1 -0
- pytunia-0.1/tests/expected/Iface/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Iface/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Instructions/classes/Instructions.class +0 -0
- pytunia-0.1/tests/expected/Instructions/status.txt +1 -0
- pytunia-0.1/tests/expected/Instructions/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Instructions/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Latin1/classes/Latin1.class +0 -0
- pytunia-0.1/tests/expected/Latin1/status.txt +1 -0
- pytunia-0.1/tests/expected/Latin1/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Latin1/stdout.txt +1 -0
- pytunia-0.1/tests/expected/ManyConstants/classes/ManyConstants.class +0 -0
- pytunia-0.1/tests/expected/ManyConstants/status.txt +1 -0
- pytunia-0.1/tests/expected/ManyConstants/stderr.txt +0 -0
- pytunia-0.1/tests/expected/ManyConstants/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Names/classes/class.class +0 -0
- pytunia-0.1/tests/expected/Names/status.txt +1 -0
- pytunia-0.1/tests/expected/Names/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Names/stdout.txt +1 -0
- pytunia-0.1/tests/expected/NumLabels/classes/NumLabels.class +0 -0
- pytunia-0.1/tests/expected/NumLabels/status.txt +1 -0
- pytunia-0.1/tests/expected/NumLabels/stderr.txt +0 -0
- pytunia-0.1/tests/expected/NumLabels/stdout.txt +1 -0
- pytunia-0.1/tests/expected/NumLabelsG/classes/NumLabelsG.class +0 -0
- pytunia-0.1/tests/expected/NumLabelsG/status.txt +1 -0
- pytunia-0.1/tests/expected/NumLabelsG/stderr.txt +0 -0
- pytunia-0.1/tests/expected/NumLabelsG/stdout.txt +1 -0
- pytunia-0.1/tests/expected/StackMapOld/classes/StackMapOld.class +0 -0
- pytunia-0.1/tests/expected/StackMapOld/status.txt +1 -0
- pytunia-0.1/tests/expected/StackMapOld/stderr.txt +0 -0
- pytunia-0.1/tests/expected/StackMapOld/stdout.txt +1 -0
- pytunia-0.1/tests/expected/StackMapTable/classes/StackMapTable.class +0 -0
- pytunia-0.1/tests/expected/StackMapTable/status.txt +1 -0
- pytunia-0.1/tests/expected/StackMapTable/stderr.txt +0 -0
- pytunia-0.1/tests/expected/StackMapTable/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Switches/classes/Switches.class +0 -0
- pytunia-0.1/tests/expected/Switches/status.txt +1 -0
- pytunia-0.1/tests/expected/Switches/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Switches/stdout.txt +1 -0
- pytunia-0.1/tests/expected/Unicode/classes/Unicode.class +0 -0
- pytunia-0.1/tests/expected/Unicode/status.txt +1 -0
- pytunia-0.1/tests/expected/Unicode/stderr.txt +0 -0
- pytunia-0.1/tests/expected/Unicode/stdout.txt +1 -0
- pytunia-0.1/tests/expected/numbers.txt +10067 -0
- pytunia-0.1/tests/make_expected.py +205 -0
- pytunia-0.1/tests/test_api.py +225 -0
- pytunia-0.1/tests/test_cli.py +158 -0
pytunia-0.1/LICENSE.txt
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
pytunia is a Python port of Jasmin 2.4 and of the JAS library it uses.
|
|
2
|
+
It is distributed under the same terms as the original Jasmin:
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 1996-2004, Jon Meyer
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
|
9
|
+
* that the following conditions are met:
|
|
10
|
+
*
|
|
11
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
|
12
|
+
* and the following disclaimer.
|
|
13
|
+
*
|
|
14
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
|
15
|
+
* and the following disclaimer in the documentation and/or other materials provided with the
|
|
16
|
+
* distribution.
|
|
17
|
+
*
|
|
18
|
+
* Neither the name of the Jon Meyer nor the names of its contributors may be used to
|
|
19
|
+
* endorse or promote products derived from this software without specific prior written permission.
|
|
20
|
+
*
|
|
21
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
22
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
23
|
+
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
24
|
+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
26
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
27
|
+
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
28
|
+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
*
|
|
30
|
+
* Jasmin was written by Jon Meyer, www.cybergrain.com
|
|
31
|
+
* The Jasmin website is jasmin.sourceforge.net.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
Credits
|
|
35
|
+
-------
|
|
36
|
+
|
|
37
|
+
* Jasmin: Jonathan Meyer; extensions for Jasmin 2.x by Daniel Reynaud and
|
|
38
|
+
Iouri Kharon.
|
|
39
|
+
* JAS (the class file library, package pytunia.jas): K. B. Sriram. Its
|
|
40
|
+
README asks that users of derived code add the author to the list of
|
|
41
|
+
credits.
|
|
42
|
+
* The parse tables in pytunia/parser_tables.py were generated by
|
|
43
|
+
Java CUP 0.9 (Scott E. Hudson) from Jasmin's grammar, and the LR parser
|
|
44
|
+
driver in pytunia/parser.py is a port of the CUP runtime. Java CUP is
|
|
45
|
+
distributed under its own permissive license.
|
pytunia-0.1/MANIFEST.in
ADDED
pytunia-0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pytunia
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: Jasmin, the assembler for the Java Virtual Machine, in Python
|
|
5
|
+
Author-email: Karl Stroetmann <karl.stroetmann@dhbw-mannheim.de>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/karlstroetmann/pytunia
|
|
8
|
+
Project-URL: Source, https://github.com/karlstroetmann/pytunia
|
|
9
|
+
Project-URL: Issues, https://github.com/karlstroetmann/pytunia/issues
|
|
10
|
+
Project-URL: Original Jasmin, https://jasmin.sourceforge.net/
|
|
11
|
+
Keywords: jasmin,assembler,jvm,java,bytecode,class file
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Education
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Java
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
25
|
+
Classifier: Topic :: Software Development :: Assemblers
|
|
26
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE.txt
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# pytunia
|
|
33
|
+
|
|
34
|
+
**Jasmin, the assembler for the Java Virtual Machine, in Python.**
|
|
35
|
+
|
|
36
|
+
pytunia is a Python port of [Jasmin 2.4](https://jasmin.sourceforge.net/).
|
|
37
|
+
It translates assembly code for the Java Virtual Machine (`.j` files) into
|
|
38
|
+
Java class files, and it produces **byte-for-byte the same class files** as
|
|
39
|
+
the original `jasmin.jar`. Its error messages are identical, too.
|
|
40
|
+
|
|
41
|
+
pytunia is a library written in pure Python, with no dependencies. It needs
|
|
42
|
+
Python 3.9 or newer.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
pip install pytunia
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The latest development version can be installed from GitHub:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pip install git+https://github.com/karlstroetmann/pytunia
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Example
|
|
57
|
+
|
|
58
|
+
`HelloWorld.j`:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
.class public HelloWorld
|
|
62
|
+
.super java/lang/Object
|
|
63
|
+
|
|
64
|
+
.method public static main([Ljava/lang/String;)V
|
|
65
|
+
.limit stack 2
|
|
66
|
+
getstatic java/lang/System/out Ljava/io/PrintStream;
|
|
67
|
+
ldc "Hello, World!"
|
|
68
|
+
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
|
|
69
|
+
return
|
|
70
|
+
.end method
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import pytunia
|
|
75
|
+
|
|
76
|
+
pytunia.assemble("HelloWorld.j") # writes HelloWorld.class
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
$ java HelloWorld
|
|
81
|
+
Hello, World!
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
import pytunia
|
|
88
|
+
|
|
89
|
+
# assemble a file and write the class file; returns its path
|
|
90
|
+
path = pytunia.assemble("Count.j") # examples/Count.class
|
|
91
|
+
path = pytunia.assemble("Count.j", output_dir="build") # build/examples/Count.class
|
|
92
|
+
|
|
93
|
+
# assemble source text in memory; nothing is written to disk
|
|
94
|
+
class_name, data = pytunia.assemble_string(source) # ("examples/Count", b"\xca\xfe...")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
(Here `Count.j` defines the class `examples.Count`.)
|
|
98
|
+
|
|
99
|
+
`assemble(source_file, output_dir=None, *, line_numbers=False, encoding="utf-8")`
|
|
100
|
+
|
|
101
|
+
* Places the class file below `output_dir` (default: the current directory)
|
|
102
|
+
in subdirectories for its package, as Jasmin does. `output_dir` can
|
|
103
|
+
therefore be used directly as a class path:
|
|
104
|
+
`java -cp build examples.Count`. Missing directories are created.
|
|
105
|
+
* `line_numbers=True` generates a line number table that refers to the lines
|
|
106
|
+
of the assembly source (option `-g` of Jasmin), so that Java stack traces
|
|
107
|
+
show the line numbers of the `.j` file.
|
|
108
|
+
* Returns the path of the class file as a `pathlib.Path`.
|
|
109
|
+
|
|
110
|
+
`assemble_string(source, name=None, *, line_numbers=False)`
|
|
111
|
+
|
|
112
|
+
* Returns the class name (in the internal form of the JVM, e.g.
|
|
113
|
+
`"examples/Count"`) and the class file as `bytes`.
|
|
114
|
+
* `name` is the file name used in error messages and for the class file's
|
|
115
|
+
`SourceFile` attribute. Without it, error messages show `<string>` and
|
|
116
|
+
the attribute is `<class name>.j`.
|
|
117
|
+
|
|
118
|
+
### Errors
|
|
119
|
+
|
|
120
|
+
If the source contains errors, both functions raise `pytunia.AssemblyError`.
|
|
121
|
+
Its attribute `errors` is a list of `pytunia.Diagnostic` objects, each with
|
|
122
|
+
`filename`, `line`, `message`, `source_line` and `column`. `str(error)` is
|
|
123
|
+
exactly the error output of `jasmin.jar`:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
try:
|
|
127
|
+
pytunia.assemble("Bad.j")
|
|
128
|
+
except pytunia.AssemblyError as e:
|
|
129
|
+
print(e)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
Bad.j:4: JAS Error: bipush value exceed size of byte.
|
|
134
|
+
bipush 300
|
|
135
|
+
^
|
|
136
|
+
Bad.j: Found 1 errors
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
A file that cannot be read or written raises the usual `OSError`, for
|
|
140
|
+
example `FileNotFoundError`. The functions print nothing, and they can be
|
|
141
|
+
called from several threads at once.
|
|
142
|
+
|
|
143
|
+
### Command line
|
|
144
|
+
|
|
145
|
+
For debugging, the command line of the Java version is available. It is not
|
|
146
|
+
installed as a command:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
python3 -m pytunia [-d <outpath>] [-g] [-e <encoding>] <file> [<file> ...]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Low-level interface
|
|
153
|
+
|
|
154
|
+
`pytunia.ClassFile` has the methods of the Java class `jasmin.ClassFile`
|
|
155
|
+
(`read_jasmin`, `error_count`, `get_class_name`, `write`). Errors are
|
|
156
|
+
collected in its list `diagnostics`.
|
|
157
|
+
|
|
158
|
+
## Compatibility with Jasmin
|
|
159
|
+
|
|
160
|
+
### Why the output is identical
|
|
161
|
+
|
|
162
|
+
These details of the Java version had to be reproduced exactly:
|
|
163
|
+
|
|
164
|
+
* **Parsing.** Jasmin's parser is an LALR(1) parser generated by Java CUP.
|
|
165
|
+
pytunia uses the very same parse tables, extracted from the generated
|
|
166
|
+
`parser.java`, and a port of the CUP runtime, including its error
|
|
167
|
+
recovery. It therefore accepts the same language and reports syntax errors
|
|
168
|
+
at the same places.
|
|
169
|
+
* **Constant pool order.** Jasmin stores constant pool entries in a
|
|
170
|
+
`java.util.Hashtable` keyed by strings and writes them in the table's
|
|
171
|
+
enumeration order. pytunia reproduces this order (`String.hashCode`, bucket
|
|
172
|
+
layout, rehashing).
|
|
173
|
+
* **Number formatting.** Some of these keys contain numbers formatted with
|
|
174
|
+
`Float.toString` and `Double.toString`. These are not always the shortest
|
|
175
|
+
representation, so the JDK 8 algorithm (`sun.misc.FloatingDecimal`) is
|
|
176
|
+
ported as well.
|
|
177
|
+
* **Java strings and number types.** Strings are handled as UTF-16 code
|
|
178
|
+
units, and constants are written in modified UTF-8. Numbers keep their
|
|
179
|
+
Java type (Integer, Long, Float, Double), since Jasmin's behaviour depends
|
|
180
|
+
on it. Number parsing follows Java's rules.
|
|
181
|
+
|
|
182
|
+
Quirks of Jasmin 2.4 are kept on purpose, because changing them would
|
|
183
|
+
change the output. For example:
|
|
184
|
+
|
|
185
|
+
* `iinc` gets a `wide` prefix unless the increment is exactly 127 (a typo in
|
|
186
|
+
Jasmin's `jas.IincOperand`).
|
|
187
|
+
* Variable substitution with `.set name value` / `$name` does not work: the
|
|
188
|
+
substituted token is taken as `.method`.
|
|
189
|
+
* `ldc2_w 0.1` stores the *float* value 0.1f as a double. Write `0.1d` to
|
|
190
|
+
get the exact double.
|
|
191
|
+
* After a syntax error, the error recovery drops one token.
|
|
192
|
+
|
|
193
|
+
### Known differences
|
|
194
|
+
|
|
195
|
+
* When `.stack` frames share an offset, Java prints a stack trace
|
|
196
|
+
(`UNEXPECTED JAS ERROR` …) before reporting the error. pytunia prints only
|
|
197
|
+
the first two lines of it. The result (error, no class file) is the same.
|
|
198
|
+
* The default source encoding is always UTF-8. Java up to version 17 uses
|
|
199
|
+
the platform encoding instead.
|
|
200
|
+
* Java keeps some state of the assembler in static fields. pytunia keeps it
|
|
201
|
+
in the objects of a single assembly instead, so assemblies can run in
|
|
202
|
+
parallel.
|
|
203
|
+
|
|
204
|
+
## Development
|
|
205
|
+
|
|
206
|
+
### How the code is organized
|
|
207
|
+
|
|
208
|
+
The structure follows the Java sources of Jasmin. Class names are kept, and
|
|
209
|
+
method names are converted to snake_case.
|
|
210
|
+
|
|
211
|
+
| Python module | Java original |
|
|
212
|
+
|---|---|
|
|
213
|
+
| `pytunia/api.py`, `pytunia/diagnostics.py` | the library interface (`assemble`, `assemble_string`, `AssemblyError`); new in pytunia |
|
|
214
|
+
| `pytunia/main.py` | `jasmin.Main`: command line handling |
|
|
215
|
+
| `pytunia/classfile.py` | `jasmin.ClassFile`: called by the parser to build the class |
|
|
216
|
+
| `pytunia/scanner.py` | `jasmin.Scanner`, `ScannerUtils`, `ReservedWords` |
|
|
217
|
+
| `pytunia/parser.py` | `jasmin.parser` (the CUP-generated parser) and the CUP runtime `java_cup.runtime.lr_parser` |
|
|
218
|
+
| `pytunia/parser_tables.py`, `pytunia/sym.py` | parse tables and symbol numbers (generated, see below) |
|
|
219
|
+
| `pytunia/insninfo.py` | `jasmin.InsnInfo`: instruction table |
|
|
220
|
+
| `pytunia/jas/` | the `jas` package that writes class files (constant pool, instructions, Code attribute, annotations, StackMap frames, ...) |
|
|
221
|
+
| `pytunia/javacompat.py` | emulation of the Java library behaviour that the output depends on |
|
|
222
|
+
|
|
223
|
+
### Tests
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
python3 -m unittest discover -s tests
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
`tests/cases/` contains about 90 Jasmin files. They cover every instruction
|
|
230
|
+
form, all directives (fields with constant values, annotations, stack maps,
|
|
231
|
+
inner classes, debug information, ...), character encodings, and many kinds
|
|
232
|
+
of errors. `tests/expected/` holds the results of `jasmin.jar` for each case:
|
|
233
|
+
class files, standard output, standard error and exit status.
|
|
234
|
+
|
|
235
|
+
* `tests/test_api.py` assembles every case with `assemble()` and
|
|
236
|
+
`assemble_string()`. The class files must be identical to those of the
|
|
237
|
+
Java version, and for sources with errors `str(AssemblyError)` must be
|
|
238
|
+
identical to its error output.
|
|
239
|
+
* `tests/test_cli.py` runs the command line (`python3 -m pytunia`) on every
|
|
240
|
+
case and compares the class files, standard output, standard error and
|
|
241
|
+
exit status. It also checks the number formatting against Java for about
|
|
242
|
+
10,000 values.
|
|
243
|
+
|
|
244
|
+
Running the tests needs neither Java nor Jasmin.
|
|
245
|
+
|
|
246
|
+
### Comparing with the Java version
|
|
247
|
+
|
|
248
|
+
The following tools need the original Jasmin 2.4 (`jasmin-2.4.zip` from the
|
|
249
|
+
[Jasmin project on SourceForge](https://sourceforge.net/projects/jasmin/)).
|
|
250
|
+
By default they look for it in a directory `jasmin-2.4` next to the
|
|
251
|
+
repository.
|
|
252
|
+
|
|
253
|
+
To regenerate the expected test results (needs `java` and `javac`):
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
python3 tests/make_expected.py ../jasmin-2.4/jasmin.jar
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
`tools/fuzz_compare.py` runs randomly mutated Jasmin files through both
|
|
260
|
+
versions and reports any file where they differ:
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
python3 tools/fuzz_compare.py --jar ../jasmin-2.4/jasmin.jar -n 20 tests/cases/*.j
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
If Jasmin's grammar changes, rebuild its parser with CUP first and then
|
|
267
|
+
regenerate the parse tables from the generated Java sources:
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
python3 tools/extract_tables.py ../jasmin-2.4/src/jasmin
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## License
|
|
274
|
+
|
|
275
|
+
Jasmin is distributed under a BSD-style license, and pytunia keeps it; see
|
|
276
|
+
[LICENSE.txt](https://github.com/karlstroetmann/pytunia/blob/main/LICENSE.txt), which also lists the credits.
|
pytunia-0.1/README.md
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# pytunia
|
|
2
|
+
|
|
3
|
+
**Jasmin, the assembler for the Java Virtual Machine, in Python.**
|
|
4
|
+
|
|
5
|
+
pytunia is a Python port of [Jasmin 2.4](https://jasmin.sourceforge.net/).
|
|
6
|
+
It translates assembly code for the Java Virtual Machine (`.j` files) into
|
|
7
|
+
Java class files, and it produces **byte-for-byte the same class files** as
|
|
8
|
+
the original `jasmin.jar`. Its error messages are identical, too.
|
|
9
|
+
|
|
10
|
+
pytunia is a library written in pure Python, with no dependencies. It needs
|
|
11
|
+
Python 3.9 or newer.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
pip install pytunia
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The latest development version can be installed from GitHub:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
pip install git+https://github.com/karlstroetmann/pytunia
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Example
|
|
26
|
+
|
|
27
|
+
`HelloWorld.j`:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
.class public HelloWorld
|
|
31
|
+
.super java/lang/Object
|
|
32
|
+
|
|
33
|
+
.method public static main([Ljava/lang/String;)V
|
|
34
|
+
.limit stack 2
|
|
35
|
+
getstatic java/lang/System/out Ljava/io/PrintStream;
|
|
36
|
+
ldc "Hello, World!"
|
|
37
|
+
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
|
|
38
|
+
return
|
|
39
|
+
.end method
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import pytunia
|
|
44
|
+
|
|
45
|
+
pytunia.assemble("HelloWorld.j") # writes HelloWorld.class
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
$ java HelloWorld
|
|
50
|
+
Hello, World!
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
import pytunia
|
|
57
|
+
|
|
58
|
+
# assemble a file and write the class file; returns its path
|
|
59
|
+
path = pytunia.assemble("Count.j") # examples/Count.class
|
|
60
|
+
path = pytunia.assemble("Count.j", output_dir="build") # build/examples/Count.class
|
|
61
|
+
|
|
62
|
+
# assemble source text in memory; nothing is written to disk
|
|
63
|
+
class_name, data = pytunia.assemble_string(source) # ("examples/Count", b"\xca\xfe...")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
(Here `Count.j` defines the class `examples.Count`.)
|
|
67
|
+
|
|
68
|
+
`assemble(source_file, output_dir=None, *, line_numbers=False, encoding="utf-8")`
|
|
69
|
+
|
|
70
|
+
* Places the class file below `output_dir` (default: the current directory)
|
|
71
|
+
in subdirectories for its package, as Jasmin does. `output_dir` can
|
|
72
|
+
therefore be used directly as a class path:
|
|
73
|
+
`java -cp build examples.Count`. Missing directories are created.
|
|
74
|
+
* `line_numbers=True` generates a line number table that refers to the lines
|
|
75
|
+
of the assembly source (option `-g` of Jasmin), so that Java stack traces
|
|
76
|
+
show the line numbers of the `.j` file.
|
|
77
|
+
* Returns the path of the class file as a `pathlib.Path`.
|
|
78
|
+
|
|
79
|
+
`assemble_string(source, name=None, *, line_numbers=False)`
|
|
80
|
+
|
|
81
|
+
* Returns the class name (in the internal form of the JVM, e.g.
|
|
82
|
+
`"examples/Count"`) and the class file as `bytes`.
|
|
83
|
+
* `name` is the file name used in error messages and for the class file's
|
|
84
|
+
`SourceFile` attribute. Without it, error messages show `<string>` and
|
|
85
|
+
the attribute is `<class name>.j`.
|
|
86
|
+
|
|
87
|
+
### Errors
|
|
88
|
+
|
|
89
|
+
If the source contains errors, both functions raise `pytunia.AssemblyError`.
|
|
90
|
+
Its attribute `errors` is a list of `pytunia.Diagnostic` objects, each with
|
|
91
|
+
`filename`, `line`, `message`, `source_line` and `column`. `str(error)` is
|
|
92
|
+
exactly the error output of `jasmin.jar`:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
try:
|
|
96
|
+
pytunia.assemble("Bad.j")
|
|
97
|
+
except pytunia.AssemblyError as e:
|
|
98
|
+
print(e)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
Bad.j:4: JAS Error: bipush value exceed size of byte.
|
|
103
|
+
bipush 300
|
|
104
|
+
^
|
|
105
|
+
Bad.j: Found 1 errors
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
A file that cannot be read or written raises the usual `OSError`, for
|
|
109
|
+
example `FileNotFoundError`. The functions print nothing, and they can be
|
|
110
|
+
called from several threads at once.
|
|
111
|
+
|
|
112
|
+
### Command line
|
|
113
|
+
|
|
114
|
+
For debugging, the command line of the Java version is available. It is not
|
|
115
|
+
installed as a command:
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
python3 -m pytunia [-d <outpath>] [-g] [-e <encoding>] <file> [<file> ...]
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Low-level interface
|
|
122
|
+
|
|
123
|
+
`pytunia.ClassFile` has the methods of the Java class `jasmin.ClassFile`
|
|
124
|
+
(`read_jasmin`, `error_count`, `get_class_name`, `write`). Errors are
|
|
125
|
+
collected in its list `diagnostics`.
|
|
126
|
+
|
|
127
|
+
## Compatibility with Jasmin
|
|
128
|
+
|
|
129
|
+
### Why the output is identical
|
|
130
|
+
|
|
131
|
+
These details of the Java version had to be reproduced exactly:
|
|
132
|
+
|
|
133
|
+
* **Parsing.** Jasmin's parser is an LALR(1) parser generated by Java CUP.
|
|
134
|
+
pytunia uses the very same parse tables, extracted from the generated
|
|
135
|
+
`parser.java`, and a port of the CUP runtime, including its error
|
|
136
|
+
recovery. It therefore accepts the same language and reports syntax errors
|
|
137
|
+
at the same places.
|
|
138
|
+
* **Constant pool order.** Jasmin stores constant pool entries in a
|
|
139
|
+
`java.util.Hashtable` keyed by strings and writes them in the table's
|
|
140
|
+
enumeration order. pytunia reproduces this order (`String.hashCode`, bucket
|
|
141
|
+
layout, rehashing).
|
|
142
|
+
* **Number formatting.** Some of these keys contain numbers formatted with
|
|
143
|
+
`Float.toString` and `Double.toString`. These are not always the shortest
|
|
144
|
+
representation, so the JDK 8 algorithm (`sun.misc.FloatingDecimal`) is
|
|
145
|
+
ported as well.
|
|
146
|
+
* **Java strings and number types.** Strings are handled as UTF-16 code
|
|
147
|
+
units, and constants are written in modified UTF-8. Numbers keep their
|
|
148
|
+
Java type (Integer, Long, Float, Double), since Jasmin's behaviour depends
|
|
149
|
+
on it. Number parsing follows Java's rules.
|
|
150
|
+
|
|
151
|
+
Quirks of Jasmin 2.4 are kept on purpose, because changing them would
|
|
152
|
+
change the output. For example:
|
|
153
|
+
|
|
154
|
+
* `iinc` gets a `wide` prefix unless the increment is exactly 127 (a typo in
|
|
155
|
+
Jasmin's `jas.IincOperand`).
|
|
156
|
+
* Variable substitution with `.set name value` / `$name` does not work: the
|
|
157
|
+
substituted token is taken as `.method`.
|
|
158
|
+
* `ldc2_w 0.1` stores the *float* value 0.1f as a double. Write `0.1d` to
|
|
159
|
+
get the exact double.
|
|
160
|
+
* After a syntax error, the error recovery drops one token.
|
|
161
|
+
|
|
162
|
+
### Known differences
|
|
163
|
+
|
|
164
|
+
* When `.stack` frames share an offset, Java prints a stack trace
|
|
165
|
+
(`UNEXPECTED JAS ERROR` …) before reporting the error. pytunia prints only
|
|
166
|
+
the first two lines of it. The result (error, no class file) is the same.
|
|
167
|
+
* The default source encoding is always UTF-8. Java up to version 17 uses
|
|
168
|
+
the platform encoding instead.
|
|
169
|
+
* Java keeps some state of the assembler in static fields. pytunia keeps it
|
|
170
|
+
in the objects of a single assembly instead, so assemblies can run in
|
|
171
|
+
parallel.
|
|
172
|
+
|
|
173
|
+
## Development
|
|
174
|
+
|
|
175
|
+
### How the code is organized
|
|
176
|
+
|
|
177
|
+
The structure follows the Java sources of Jasmin. Class names are kept, and
|
|
178
|
+
method names are converted to snake_case.
|
|
179
|
+
|
|
180
|
+
| Python module | Java original |
|
|
181
|
+
|---|---|
|
|
182
|
+
| `pytunia/api.py`, `pytunia/diagnostics.py` | the library interface (`assemble`, `assemble_string`, `AssemblyError`); new in pytunia |
|
|
183
|
+
| `pytunia/main.py` | `jasmin.Main`: command line handling |
|
|
184
|
+
| `pytunia/classfile.py` | `jasmin.ClassFile`: called by the parser to build the class |
|
|
185
|
+
| `pytunia/scanner.py` | `jasmin.Scanner`, `ScannerUtils`, `ReservedWords` |
|
|
186
|
+
| `pytunia/parser.py` | `jasmin.parser` (the CUP-generated parser) and the CUP runtime `java_cup.runtime.lr_parser` |
|
|
187
|
+
| `pytunia/parser_tables.py`, `pytunia/sym.py` | parse tables and symbol numbers (generated, see below) |
|
|
188
|
+
| `pytunia/insninfo.py` | `jasmin.InsnInfo`: instruction table |
|
|
189
|
+
| `pytunia/jas/` | the `jas` package that writes class files (constant pool, instructions, Code attribute, annotations, StackMap frames, ...) |
|
|
190
|
+
| `pytunia/javacompat.py` | emulation of the Java library behaviour that the output depends on |
|
|
191
|
+
|
|
192
|
+
### Tests
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
python3 -m unittest discover -s tests
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
`tests/cases/` contains about 90 Jasmin files. They cover every instruction
|
|
199
|
+
form, all directives (fields with constant values, annotations, stack maps,
|
|
200
|
+
inner classes, debug information, ...), character encodings, and many kinds
|
|
201
|
+
of errors. `tests/expected/` holds the results of `jasmin.jar` for each case:
|
|
202
|
+
class files, standard output, standard error and exit status.
|
|
203
|
+
|
|
204
|
+
* `tests/test_api.py` assembles every case with `assemble()` and
|
|
205
|
+
`assemble_string()`. The class files must be identical to those of the
|
|
206
|
+
Java version, and for sources with errors `str(AssemblyError)` must be
|
|
207
|
+
identical to its error output.
|
|
208
|
+
* `tests/test_cli.py` runs the command line (`python3 -m pytunia`) on every
|
|
209
|
+
case and compares the class files, standard output, standard error and
|
|
210
|
+
exit status. It also checks the number formatting against Java for about
|
|
211
|
+
10,000 values.
|
|
212
|
+
|
|
213
|
+
Running the tests needs neither Java nor Jasmin.
|
|
214
|
+
|
|
215
|
+
### Comparing with the Java version
|
|
216
|
+
|
|
217
|
+
The following tools need the original Jasmin 2.4 (`jasmin-2.4.zip` from the
|
|
218
|
+
[Jasmin project on SourceForge](https://sourceforge.net/projects/jasmin/)).
|
|
219
|
+
By default they look for it in a directory `jasmin-2.4` next to the
|
|
220
|
+
repository.
|
|
221
|
+
|
|
222
|
+
To regenerate the expected test results (needs `java` and `javac`):
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
python3 tests/make_expected.py ../jasmin-2.4/jasmin.jar
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
`tools/fuzz_compare.py` runs randomly mutated Jasmin files through both
|
|
229
|
+
versions and reports any file where they differ:
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
python3 tools/fuzz_compare.py --jar ../jasmin-2.4/jasmin.jar -n 20 tests/cases/*.j
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
If Jasmin's grammar changes, rebuild its parser with CUP first and then
|
|
236
|
+
regenerate the parse tables from the generated Java sources:
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
python3 tools/extract_tables.py ../jasmin-2.4/src/jasmin
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## License
|
|
243
|
+
|
|
244
|
+
Jasmin is distributed under a BSD-style license, and pytunia keeps it; see
|
|
245
|
+
[LICENSE.txt](https://github.com/karlstroetmann/pytunia/blob/main/LICENSE.txt), which also lists the credits.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pytunia"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Jasmin, the assembler for the Java Virtual Machine, in Python"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "BSD-3-Clause"
|
|
12
|
+
license-files = ["LICENSE.txt"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Karl Stroetmann", email = "karl.stroetmann@dhbw-mannheim.de"},
|
|
15
|
+
]
|
|
16
|
+
keywords = ["jasmin", "assembler", "jvm", "java", "bytecode", "class file"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 4 - Beta",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Intended Audience :: Education",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Java",
|
|
23
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
24
|
+
"Programming Language :: Python :: 3.9",
|
|
25
|
+
"Programming Language :: Python :: 3.10",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Programming Language :: Python :: 3.14",
|
|
30
|
+
"Programming Language :: Python :: 3.15",
|
|
31
|
+
"Topic :: Software Development :: Assemblers",
|
|
32
|
+
"Topic :: Software Development :: Compilers",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/karlstroetmann/pytunia"
|
|
37
|
+
Source = "https://github.com/karlstroetmann/pytunia"
|
|
38
|
+
Issues = "https://github.com/karlstroetmann/pytunia/issues"
|
|
39
|
+
"Original Jasmin" = "https://jasmin.sourceforge.net/"
|
|
40
|
+
|
|
41
|
+
[tool.setuptools]
|
|
42
|
+
packages = ["pytunia", "pytunia.jas"]
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.dynamic]
|
|
45
|
+
version = {attr = "pytunia.__version__"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pytunia - Jasmin, the assembler for the Java Virtual Machine, in Python.
|
|
3
|
+
|
|
4
|
+
This package is a port of Jasmin 2.4 (Jonathan Meyer, Daniel Reynaud,
|
|
5
|
+
Iouri Kharon) from Java to Python. It reads Jasmin assembly code and
|
|
6
|
+
produces Java class files that are byte-for-byte identical to those
|
|
7
|
+
produced by the Java version.
|
|
8
|
+
|
|
9
|
+
import pytunia
|
|
10
|
+
|
|
11
|
+
# assemble a file and write the class file (returns its path)
|
|
12
|
+
path = pytunia.assemble("Hello.j", output_dir="classes")
|
|
13
|
+
|
|
14
|
+
# assemble source text in memory
|
|
15
|
+
class_name, data = pytunia.assemble_string(source)
|
|
16
|
+
|
|
17
|
+
Errors raise pytunia.AssemblyError; its attribute ``errors`` is a list of
|
|
18
|
+
Diagnostic objects, and str(error) is the error output of Jasmin.
|
|
19
|
+
|
|
20
|
+
For debugging, the original command line interface is available as
|
|
21
|
+
``python3 -m pytunia [-d <outpath>] [-g] [-e <encoding>] <file> ...``.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from .api import assemble, assemble_string
|
|
25
|
+
from .classfile import ClassFile
|
|
26
|
+
from .diagnostics import AssemblyError, Diagnostic
|
|
27
|
+
from .main import VERSION as JASMIN_VERSION
|
|
28
|
+
|
|
29
|
+
# the version of pytunia (JASMIN_VERSION is the version of Jasmin that
|
|
30
|
+
# pytunia reproduces)
|
|
31
|
+
__version__ = "0.1"
|
|
32
|
+
|
|
33
|
+
__all__ = ["assemble", "assemble_string", "AssemblyError", "Diagnostic",
|
|
34
|
+
"ClassFile", "JASMIN_VERSION"]
|