-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #857 from darkdrag00nv2/eip5_template_ds_poc
Implement ContractTemplate data structures according to EIP5
- Loading branch information
Showing
11 changed files
with
907 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
21 changes: 21 additions & 0 deletions
21
common/shared/src/main/scala/scalan/util/ReflectionUtil.scala
This file contains 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,21 @@ | ||
package scalan.util | ||
|
||
import scala.language.existentials | ||
|
||
object ReflectionUtil { | ||
|
||
implicit class ClassOps(val cl: Class[_]) extends AnyVal { | ||
private def isSpecialChar(c: Char): Boolean = { | ||
('0' <= c && c <= '9') || c == '$' | ||
} | ||
def safeSimpleName: String = { | ||
if (cl.getEnclosingClass == null) return cl.getSimpleName | ||
val simpleName = cl.getName.substring(cl.getEnclosingClass.getName.length) | ||
val length = simpleName.length | ||
var index = 0 | ||
while (index < length && isSpecialChar(simpleName.charAt(index))) { index += 1 } | ||
// Eventually, this is the empty string iff this is an anonymous class | ||
simpleName.substring(index) | ||
} | ||
} | ||
} |
This file contains 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 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 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
Oops, something went wrong.