diff --git a/LICENSES/Apache-2.0.md b/LICENSES/Apache-2.0.md new file mode 100644 index 0000000..f5f4b8b --- /dev/null +++ b/LICENSES/Apache-2.0.md @@ -0,0 +1,195 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### Terms and Conditions for use, reproduction, and distribution + +#### 1. Definitions + +“License” shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +“Licensor” shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +“Legal Entity” shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, “control” means **(i)** the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the +outstanding shares, or **(iii)** beneficial ownership of such entity. + +“You” (or “Your”) shall mean an individual or Legal Entity exercising +permissions granted by this License. + +“Source” form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +“Object” form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +“Work” shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +“Derivative Works” shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +“Contribution” shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +“submitted” means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as “Not a Contribution.” + +“Contributor” shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +#### 2. Grant of Copyright License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +#### 3. Grant of Patent License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +#### 4. Redistribution + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +* **(a)** You must give any other recipients of the Work or Derivative Works a copy of +this License; and +* **(b)** You must cause any modified files to carry prominent notices stating that You +changed the files; and +* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +#### 5. Submission of Contributions + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +#### 6. Trademarks + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +#### 7. Disclaimer of Warranty + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +#### 8. Limitation of Liability + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +#### 9. Accepting Warranty or Additional Liability + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +_END OF TERMS AND CONDITIONS_ + +### APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets `[]` replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same “printed page” as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/LICENSES/Unlicense.md b/LICENSES/Unlicense.md new file mode 100644 index 0000000..7f6e5ae --- /dev/null +++ b/LICENSES/Unlicense.md @@ -0,0 +1,27 @@ +Unlicense (Public Domain) +============================ + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to <> diff --git a/serialization/scala_signature/2.13.3_scala.reflect.internal.Trees b/serialization/scala_signature/2.13.3_scala.reflect.internal.Trees new file mode 100644 index 0000000..2a8e16c Binary files /dev/null and b/serialization/scala_signature/2.13.3_scala.reflect.internal.Trees differ diff --git a/serialization/scala_signature/2.13.3_scala.reflect.internal.Trees.license b/serialization/scala_signature/2.13.3_scala.reflect.internal.Trees.license new file mode 100644 index 0000000..cb60a0e --- /dev/null +++ b/serialization/scala_signature/2.13.3_scala.reflect.internal.Trees.license @@ -0,0 +1,5 @@ +SPDX-FileCopyrightText: | + Copyright (c) 2002- EPFL + Copyright (c) 2011- Lightbend, Inc. + +SPDX-License-Identifier: Apache-2.0 diff --git a/serialization/scala_signature/ReadMe.md b/serialization/scala_signature/ReadMe.md new file mode 100644 index 0000000..62a4e13 --- /dev/null +++ b/serialization/scala_signature/ReadMe.md @@ -0,0 +1,11 @@ + + +## Scala 2.13.3 signature for scala.reflect.internal.Trees + +Source: harvested from Scala jars + +Used a self-written script [`harvest_signatures.py`](./harvest_signatures.py), then put one of the largest files into this dir. diff --git a/serialization/scala_signature/harvest_signatures.py b/serialization/scala_signature/harvest_signatures.py new file mode 100644 index 0000000..115a005 --- /dev/null +++ b/serialization/scala_signature/harvest_signatures.py @@ -0,0 +1,278 @@ +import sys +import time +import typing +import warnings +import zipfile +from pathlib import Path, PurePath + +import jpype +from JAbs import SelectedJVMInitializer +from pantarei import chosenProgressReporter + + +def _extractClassesFromAJar(jarPath: Path) -> typing.Iterator[typing.Tuple[str, ...]]: + classExt = ".class" + with zipfile.ZipFile(jarPath) as z: + for f in z.infolist(): + if f.filename.endswith(classExt): + path = PurePath(f.filename) + yield path.parts[:-1] + (path.stem,) + + +def extractClassesFromAJar(jarPath: Path) -> typing.Any: + return tuple(sorted(_extractClassesFromAJar(jarPath))) + + +#scalaPath = Path("/usr/share/scala-2.11/lib") +#scalaPath = Path("./scala-2.13.3/lib") +scalaPath = Path("/usr/share/kaitai-struct-compiler/lib") + + +additionalClasspath = [Path("/usr/share/maven-repo/org/apache/ant/ant/debian/ant-debian.jar"), Path("./scala-2.13.3/lib/scala-reflect.jar")] +classpath = sorted(scalaPath.glob("*.jar")) +ji = SelectedJVMInitializer(classpath + additionalClasspath, []) + +try: + from scalaTransformArray import decode as decodeScalaSignaturePython + + def decodeScalaSignature(s: bytes) -> bytes: + s = bytearray(bytes(s)) + l = decodeScalaSignaturePython(s) + return bytes(s[:l]) + + +except ImportError: + ByteCodecs = ji.loadClass("scala.reflect.internal.pickling.ByteCodecs") + + def decodeScalaSignature(s: bytes) -> bytes: + l = ByteCodecs.decode(s) + s = bytes(s) + return s[:l] + + +def getScalaSigAnnotation(classRefl) -> typing.Any: + for annot in classRefl.annotations: + if annot.annotationType().name == "scala.reflect.ScalaSignature": + return annot + + +def extractAndDecodeScalaSignature(cls) -> bytes: + classRefl = ji.reflectClass(cls) + scalaSignAnnot = getScalaSigAnnotation(classRefl) + if scalaSignAnnot: + s = scalaSignAnnot.bytes().getBytes("UTF-8") + return decodeScalaSignature(s) + + +sc = "scala." +scc = sc + "collection." +scrf = sc + "reflect." +scrfi = scrf + "internal." +sct = sc + "tools." +sctn = sct + "nsc." +sctnbj = sctn + "backend.jvm." +sctnc = sctn + "typechecker." +sctnt = sctn + "transform." +sctntp = sctnt + "patmat." +sctni = sctn + "interpreter." +scrfit = scrfi + "tpe." + +sc = "scala." +scc = sc + "collection." +scrf = sc + "reflect." +scrfi = scrf + "internal." +scrfo = scrf + "io." +sct = sc + "tools." +sctn = sct + "nsc." +sctnbj = sctn + "backend.jvm." +sctnc = sctn + "typechecker." +sctnt = sctn + "transform." +sctntp = sctnt + "patmat." +sctni = sctn + "interpreter." +scrfit = scrfi + "tpe." +scrfm = scrf + "macros." +scrfmc = scrfm + "contexts." + +blackList = { + scc + "Iterator$Leading$1", + scc + "Iterator$PartitionIterator$1", + scc + "Iterator$Partner$1", + scc + "parallel.mutable.ParHashMapCombiner$table$2$", + scrfi + "ExistentialsAndSkolems$$anonfun$packSymbols$1", + scrfi + "ExistentialsAndSkolems$Deskolemizer$1", + scrfi + "Internals$SymbolTableInternal$changeOwnerAndModuleClassTraverser$2$", + scrfit + "TypeMaps$InstantiateDependentMap$StabilizedArgTp$", + scrfit + "TypeMaps$InstantiateDependentMap$StableArgTp$", + scrfit + "TypeMaps$InstantiateDependentMap$UnstableArgTp$", + scrfit + "TypeMaps$InstantiateDependentMap$treeTrans$2$", + scrfit + "TypeMaps$SubstSymMap$mapTreeSymbols$$anonfun$transform$2", + scrfit + "TypeMaps$SubstSymMap$mapTreeSymbols$$anonfun$transform$1", + scrfit + "TypeMaps$SubstTypeMap", + scrfit + "TypeMaps$SubstTypeMap$trans$2$", + scc + "immutable.ChampBaseIterator", + scrfo + "FileZipArchive$FileEntry$1", + scrfo + "JavaToolsPlatformArchive$$anonfun$iterator$2$FileEntry$4", + scrfo + "ManifestResources$$anonfun$iterator$1$FileEntry$3", + scrfo + "URLZipArchive$EmptyFileEntry$1", + scrfo + "URLZipArchive$FileEntry$2", + scrfm + "compiler.Validators$Validator$SigGenerator$2$", + scrfm + "compiler.Validators$Validator$SigGenerator$2$SigmaTypeMap$", + scrfmc + "Internals$$anon$1$HofTransformer", + scrfmc + "Internals$$anon$1$HofTypingTransformer", + scrfmc + "Reifiers$utils$2$", + sctn + "Global$ClassPathOrdering$2$", + sctnbj + "GenASM$JPlainBuilder$$anonfun$isClosureApply$1$1", + sctnbj + "GenASM$JPlainBuilder$Interval$3", + sctnbj + "GenASM$JPlainBuilder$Interval$4$", + sctnbj + "GenASM$JPlainBuilder$LineNumberEntry$3", + sctnbj + "GenASM$JPlainBuilder$LineNumberEntry$4$", + sctnbj + "GenASM$JPlainBuilder$LocVarEntry$3", + sctnbj + "GenASM$JPlainBuilder$LocVarEntry$4$", + sctnbj + "GenASM$JPlainBuilder$scoping$2$", + sctnbj + "opt.CallGraph$CallsiteInfo$3", + sctnbj + "opt.CallGraph$CallsiteInfo$4$", + sctnbj + "opt.ClosureOptimizer$closureInitOrdering$2$", + sctn + "doc.model.IndexModelFactory$$anon$1$result$2$", + sctn + "doc.model.ModelFactory$EntityImpl$$anonfun$annotations$1$$typecreator1$1", + sctn + "interactive.REPL$compiler$2$", + sctni + "IMain$$typecreator2$1", + sctni + "Imports$ReqAndHandler$3", + sctni + "Imports$ReqAndHandler$4$", + sctni + "ReplVals$AppliedTypeFromTags$1", + sctn + "symtab.BrowsingLoaders$BrowserTraverser$1", + sctnt + "Constructors$OmittablesHelper$detectUsages$2$", + sctnt + "Mixin$MixinTransformer$AddInitBitsTransformer$1", + sctnt + "Mixin$MixinTransformer$AddInitBitsTransformer$1$$anonfun$transformStats$1", + sctnt + "Mixin$MixinTransformer$TreeSymSubstituterWithCopying$1", + sctnt + "Mixin$SingleUseTraverser$2$", + sctnt + "SpecializeTypes$$anon$2$CollectMethodBodies", + sctnt + "SpecializeTypes$FullTypeMap$1", + sctntp + "Interface$TypedSubstitution$Substitution$substIdentsForTrees$2$", + sctntp + "Logic$PropositionalLogic$gatherEqualities$2$", + sctntp + "Logic$PropositionalLogic$rewriteEqualsToProp$2$", + sctntp + "MatchAnalysis$MatchAnalyzer$VariableAssignment$3", + sctntp + "MatchAnalysis$MatchAnalyzer$VariableAssignment$3$$anonfun$uniqueEqualTo$1$$anonfun$apply$20", + sctntp + "MatchAnalysis$MatchAnalyzer$VariableAssignment$4$", + sctntp + "MatchApproximation$MatchApproximator$TreeMakersToProps$TreeMakerToProp$condStrategy$2$", + sctntp + "MatchTranslation$MatchTranslator$ExtractorCallRegular", + sctntp + "MatchTranslation$MatchTranslator$ExtractorCallRegular$splice$2$", + sctntp + "ScalaLogic$TreesAndTypesDomain$Var$ExcludedPair$2", + sctntp + "ScalaLogic$TreesAndTypesDomain$Var$ExcludedPair$3$", + sctntp + "Solving$Solver$TseitinSolution$3", + sctntp + "Solving$Solver$TseitinSolution$4$", + sctntp + "TreeAndTypeAnalysis$CheckableTreeAndTypeAnalysis$typeArgsToWildcardsExceptArray$2$", + sctnc + "Implicits$ImplicitSearch$ImplicitComputation$LocalShadower$1", + sctnc + "Implicits$ImplicitSearch$ImplicitComputation$LocalShadower$1", + sctnc + "Implicits$ImplicitSearch$ImplicitComputation$NoShadower$2$", + sctnc + "Infer$Inferencer$InferMethodAlternativeTwice$1", + sctnc + "Infer$Inferencer$InferTwice$1", + sctnc + "Macros$UnsigmaTypeMap$2$", + sctnc + "RefChecks$RefCheckTransformer$LevelInfo", + sctnc + "RefChecks$RefCheckTransformer$MixinOverrideError$3", + sctnc + "RefChecks$RefCheckTransformer$MixinOverrideError$4$", + sctnc + "Typers$Typer$ArrayInstantiation$2$", + sctnc + "Typers$Typer$checkEphemeralDeep$2$", + sct + "reflect.FormatInterpolator$$typecreator1$1", + + # scala 2.13 + sc + "reflect.macros.compiler.Validators$Validator$SigGenerator$1$", + sc + "reflect.macros.compiler.Validators$Validator$SigGenerator$1$SigmaTypeMap$", + sc + "reflect.macros.contexts.Reifiers$utils$1$", + sc + "tools.nsc.Global$ClassPathOrdering$1$", + sc + "tools.nsc.InterpreterLoop$$anon$1$Compat$1", + sc + "tools.nsc.doc.model.IndexModelFactory$$anon$1$result$1$", + sc + "tools.nsc.doc.model.ModelFactory$EntityImpl$$typecreator1$1", + sc + "tools.nsc.interactive.REPL$compiler$1$", + sc + "tools.nsc.interpreter.Imports$ReqAndHandler$1", + sc + "tools.nsc.interpreter.Imports$ReqAndHandler$2$", + sc + "tools.nsc.interpreter.shell.Scripted$$typecreator2$1", + sctnt + "Constructors$OmittablesHelper$DetectAssigns$1", + sctnt + "Constructors$OmittablesHelper$detectUsages$1$", + sctnt + "Erasure$ErasureTransformer$$anon$4$SingletonInstanceCheck$", + sctnt + "Mixin$MixinTransformer$SingleUseTraverser$1$", + sctnt + "async.AsyncAnalysis$UnsupportedAwaitAnalyzer$traverser$1$", + sctnt + "async.Lifter$companionship$1$", + sctnt + "async.Lifter$traverser$1$", + sctnt + "async.LiveVariables$FindUseTraverser$1", + sctntp + "Interface$TypedSubstitution$Substitution$substIdentsForTrees$1$", + sctntp + "Logic$PropositionalLogic$gatherEqualities$1$", + sctntp + "Logic$PropositionalLogic$rewriteEqualsToProp$1$", + sctntp + "MatchAnalysis$MatchAnalyzer$VariableAssignment$1$", + sctntp + "MatchApproximation$MatchApproximator$TreeMakersToProps$TreeMakerToProp$condStrategy$1$", + sctntp + "MatchTranslation$MatchTranslator$ExtractorCallRegular$splice$1$", + sctntp + "ScalaLogic$TreesAndTypesDomain$Var$ExcludedPair$1", + sctntp + "ScalaLogic$TreesAndTypesDomain$Var$ExcludedPair$2$", + sctntp + "Solving$Solver$TseitinSolution$1", + sctntp + "Solving$Solver$TseitinSolution$2$", + sctntp + "TreeAndTypeAnalysis$CheckableTreeAndTypeAnalysis$typeArgsToWildcardsExceptArray$1$", + sctnc + "Contexts$Context$DictionarySubstituter$1", + sctnc + "Contexts$Context$ReferenceSubstituter$1", + sctnc + "Implicits$ImplicitSearch$ImplicitComputation$Candidate$1", + sctnc + "Implicits$ImplicitSearch$ImplicitComputation$Candidate$2$", + sctnc + "Infer$Inferencer$typeMap$1$", + sctnc + "MacroAnnotationNamers$MacroAnnotationNamer$PatchedContext$1", + sctnc + "MacroAnnotationNamers$MacroAnnotationNamer$PatchedContext$1$$anon$3", + sctnc + "MacroAnnotationNamers$MacroAnnotationNamer$PatchedContext$1$PatchedLookupResult", + sctnc + "RefChecks$RefCheckTransformer$MixinOverrideError$1", + sctnc + "RefChecks$RefCheckTransformer$MixinOverrideError$2$", + sctnc + "Typers$Typer$checkEphemeralDeep$1$", + sctnc + "Typers$Typer$setRange$1$", + sctnc + "Typers$Typer$substResetForOriginal$1$", + scc + "immutable.HashMap$accum$1", + sc + "util.hashing.MurmurHash3$accum$1", + sc + "volatile", + scrfi + "Positions$worker$1$", + scrfi + "Positions$worker$1$solidChildrenCollector$", + scrfi + "tpe.TypeMaps$InstantiateDependentMap$treeTrans$1$", + scrfi + "tpe.TypeMaps$SubstTypeMap$trans$1$", + sc + "reflect.io.ManifestResources$FileEntry$2", + sc + "reflect.io.URLZipArchive$FileEntry$1", + + "fastparse.utils.MacroUtils$$typecreator1$1", + "fastparse.utils.MacroUtils$$typecreator2$1", + "sourcecode.Args$$typecreator7$1", + "sourcecode.Args$$typecreator8$1", + "sourcecode.File$$typecreator5$1", + "sourcecode.FullName$$typecreator3$1", + "sourcecode.FullName$Machine$$typecreator4$1", + "sourcecode.Impls$$typecreator10$1", + "sourcecode.Impls$$typecreator9$1", + "sourcecode.Line$$typecreator6$1", + "sourcecode.Name$$typecreator1$1", + "sourcecode.Name$Machine$$typecreator2$1", +} + + +def harvestSignatures() -> None: + with zipfile.ZipFile("./scalaSignatures.zip", mode="w", compression=zipfile.ZIP_LZMA) as z: + for jarPath in classpath[:]: + classesComps = extractClassesFromAJar(jarPath) + with chosenProgressReporter(len(classesComps), "extracting signatures") as pb: + for clsComps in classesComps[:]: + clsName = ".".join(clsComps) + #print(clsName, file=sys.stderr) + if clsName in blackList: + pb.report(key=clsName, incr=1, op="blocked") + continue + #for i in range(10): + # time.sleep(0.01) + # sys.stderr.flush() + pb.report(key=clsName, incr=0, op="Loading class") + try: + cls = ji.loadClass(clsName) + except BaseException: + pb.report(key=clsName, incr=1, op="import failure") + continue + + sigDecoded = extractAndDecodeScalaSignature(cls) + if sigDecoded: + with z.open(str(PurePath(jarPath.stem)._make_child(clsComps)), mode="w") as sf: + sf.write(sigDecoded) + pb.report(key=clsName, incr=1, op="Extracted") + else: + pb.report(key=clsName, incr=1, op="empty") + pass + + +if __name__ == "__main__": + harvestSignatures() diff --git a/serialization/scala_signature/scalaTransformArray.py b/serialization/scala_signature/scalaTransformArray.py new file mode 100644 index 0000000..33929c7 --- /dev/null +++ b/serialization/scala_signature/scalaTransformArray.py @@ -0,0 +1,104 @@ +__license__ = "Apache-2.0 https://github.com/scala/scala/blob/2.13.x/LICENSE" +# https://github.com/scala/scala/blob/ba9701059216c629410f4f23a2175d20ad62484b/src/reflect/scala/reflect/internal/pickling/ByteCodecs.scala + +__copyright__ = """ +Scala (https://www.scala-lang.org) + +Copyright EPFL and Lightbend, Inc. + +Licensed under Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0). + +See the NOTICE file distributed with this work for additional information regarding copyright ownership. +""" + + +def regenerateZero(src: bytearray) -> int: + i = 0 + srclen = len(src) + j = 0 + while i < srclen: + inp: int = src[i] & 0xff + if inp == 0xc0 and (src[i + 1] & 0xff) == 0x80: + src[j] = 0x7f + i += 2 + elif inp == 0: + src[j] = 0x7f + i += 1 + else: + src[j] = inp - 1 + i += 1 + j += 1 + return j + + +def decode7to8(src: bytearray, srclen: int) -> int: + i = 0 + j = 0 + dstlen = (srclen * 7 + 7) // 8 + while i + 7 < srclen: + out: int = src[i] + inp: Byte = src[i + 1] + src[j] = out | (inp & 0x01) << 7 + out = inp >> 1 + inp = src[i + 2] + src[j + 1] = out | (inp & 0x03) << 6 + out = inp >> 2 + inp = src[i + 3] + src[j + 2] = out | (inp & 0x07) << 5 + out = inp >> 3 + inp = src[i + 4] + src[j + 3] = out | (inp & 0x0f) << 4 + out = inp >> 4 + inp = src[i + 5] + src[j + 4] = out | (inp & 0x1f) << 3 + out = inp >> 5 + inp = src[i + 6] + src[j + 5] = out | (inp & 0x3f) << 2 + out = inp >> 6 + inp = src[i + 7] + src[j + 6] = out | inp << 1 + i += 8 + j += 7 + + if i < srclen: + out: int = src[i] + if i + 1 < srclen: + inp: Byte = src[i + 1] + src[j] = out | (inp & 0x01) << 7 + j += 1 + out = inp >> 1 + if i + 2 < srclen: + inp = src[i + 2] + src[j] = out | (inp & 0x03) << 6 + j += 1 + out = inp >> 2 + if i + 3 < srclen: + inp = src[i + 3] + src[j] = out | (inp & 0x07) << 5 + j += 1 + out = inp >> 3 + if i + 4 < srclen: + inp = src[i + 4] + src[j] = out | (inp & 0x0f) << 4 + j += 1 + out = inp >> 4 + if i + 5 < srclen: + inp = src[i + 5] + src[j] = out | (inp & 0x1f) << 3 + j += 1 + out = inp >> 5 + if i + 6 < srclen: + inp = src[i + 6] + src[j] = out | (inp & 0x3f) << 2 + j += 1 + out = inp >> 6 + + if j < dstlen: + src[j] = out + + return dstlen + + +def decode(xs: bytearray) -> int: + len = regenerateZero(xs) + return decode7to8(xs, len)