-
Couldn't load subscription status.
- Fork 641
Add partial cross-compilation for Scala 3 #4549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
f4b01bc
Add Scala3 sources
adkian-sifive cbaeaa5
Update build.sc
adkian-sifive fa910dc
Fix SerializableModuleGenerator
adkian-sifive 88c18b6
Fix D/I sources to cross compile
adkian-sifive c8a1fcc
Move SerializableModuleGenerator
adkian-sifive fe3a9a7
Remove copy method from IR
adkian-sifive cb866e2
Explicit import in ModuleImpl
adkian-sifive 8103a01
Cross compilation fixes
adkian-sifive dbd96b7
Convert cloneType to an extension method
adkian-sifive a5afb37
Updates
adkian-sifive 416cdda
Add missing return type to unary_~
adkian-sifive 182770d
Remove do-apply pattern from Definition and Instance
adkian-sifive 3fb5779
Rebase fixes
adkian-sifive 65d04a1
Switch Scala3 sourceInfo implicits to contextual parameters
adkian-sifive 8d32700
Add Scala 3 compilation to CI
adkian-sifive 365e084
Update workflows with explicit scala version
adkian-sifive cee3eea
CI and build.sc updates
adkian-sifive 2f3df15
Revert "Convert cloneType to an extension method"
jackkoenig c0fe7bb
Get things working with this.type
jackkoenig 65f87c1
Move plugins to plugin/src/main/scala-2
adkian-sifive 5763b57
Add plugin 3.3.4 stub and change version to 3.3.4
adkian-sifive 04821b7
Code review updates
adkian-sifive 77a10f4
Add compileAll function in build.sc
adkian-sifive e694a6a
Update Printf.scala
adkian-sifive 88cb4d3
Hierarchy updates
adkian-sifive bc6ff61
Fix Instance.scala
adkian-sifive 9a8b282
Fix ChiselEnum
adkian-sifive f46d276
Add remaining units to buildUnits build.sc
adkian-sifive dfd3245
Code review updates
adkian-sifive d754f9f
Code review updates
adkian-sifive 8ccc39c
Merge branch 'main' into adkian-sifive/scala3-v0.1
jackkoenig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
core/src/main/scala-2/chisel3/experimental/hierarchy/IsA.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package chisel3.experimental.hierarchy.core | ||
|
|
||
| import chisel3._ | ||
| import scala.reflect.runtime.universe.TypeTag | ||
|
|
||
| trait HierarchyProto[+A] { | ||
| private[chisel3] def underlying: Underlying[A] | ||
| private[chisel3] def proto: A = underlying match { | ||
| case Proto(value) => value | ||
| case Clone(i: IsClone[A]) => i.getProto | ||
| } | ||
| } | ||
|
|
||
| trait HierarchyIsA[+A] extends HierarchyProto[A] { | ||
| // This code handles a special-case where, within an mdoc context, the type returned from | ||
| // scala reflection (typetag) looks different than when returned from java reflection. | ||
| // This function detects this case and reshapes the string to match. | ||
| private def modifyReplString(clz: String): String = { | ||
| if (clz != null) { | ||
| clz.split('.').toList match { | ||
| case "repl" :: "MdocSession" :: app :: rest => s"$app.this." + rest.mkString(".") | ||
| case other => clz | ||
| } | ||
| } else clz | ||
| } | ||
|
|
||
| private lazy val superClasses = calculateSuperClasses(super.proto.getClass()) | ||
| private def calculateSuperClasses(clz: Class[_]): Set[String] = { | ||
| if (clz != null) { | ||
| Set(modifyReplString(clz.getCanonicalName())) ++ | ||
| clz.getInterfaces().flatMap(i => calculateSuperClasses(i)) ++ | ||
| calculateSuperClasses(clz.getSuperclass()) | ||
| } else { | ||
| Set.empty[String] | ||
| } | ||
| } | ||
| private def inBaseClasses(clz: String): Boolean = superClasses.contains(clz) | ||
|
|
||
| /** Determine whether underlying proto is of type provided. | ||
| * | ||
| * @note IMPORTANT: this function requires summoning a TypeTag[B], which will fail if B is an inner class. | ||
| * @note IMPORTANT: this function IGNORES type parameters, akin to normal type erasure. | ||
| * @note IMPORTANT: this function relies on Java reflection for underlying proto, but Scala reflection for provided type | ||
| * | ||
| * E.g. isA[List[Int]] will return true, even if underlying proto is of type List[String] | ||
| * @return Whether underlying proto is of provided type (with caveats outlined above) | ||
| */ | ||
| def isA[B: TypeTag]: Boolean = { | ||
| val tptag = implicitly[TypeTag[B]] | ||
| // drop any type information for the comparison, because the proto will not have that information. | ||
| val name = tptag.tpe.toString.takeWhile(_ != '[') | ||
| inBaseClasses(name) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.