mirror of
https://github.com/fluencelabs/hackethberlin
synced 2025-04-24 17:02:18 +00:00
trying to get from struct type
This commit is contained in:
parent
aa725a41ba
commit
f759c64868
@ -11,13 +11,15 @@ class FuncDef[Args <: HList: DataVyper, Ret <: types.Type](
|
||||
) {
|
||||
|
||||
def toVyper: String =
|
||||
s"${decorators.map(_.toVyper).mkString("\n")}\ndef $name(${DataVyper[Args].mkString(argsDef, ", ")})${ret.fold("")(" -> "+_.toVyper)}:\n body;\n"
|
||||
s"${decorators.map(_.toVyper).mkString("\n")}\ndef $name(${DataVyper[Args]
|
||||
.mkString(argsDef, ", ")})${ret.fold("")(" -> " + _.toVyper)}:\n body;\n"
|
||||
|
||||
def @:(decorator: Decorator): FuncDef[Args, Ret] =
|
||||
new FuncDef[Args, Ret](name, argsDef, ret, decorators + decorator)
|
||||
}
|
||||
|
||||
object FuncDef {
|
||||
|
||||
def apply[Args <: HList: DataVyper, Ret <: types.Type](
|
||||
name: String,
|
||||
argsDef: Args,
|
||||
@ -25,7 +27,6 @@ object FuncDef {
|
||||
): FuncDef[Args, Ret] =
|
||||
new FuncDef(name, argsDef, Some(ret))
|
||||
|
||||
|
||||
def apply[Args <: HList: DataVyper](
|
||||
name: String,
|
||||
argsDef: Args
|
||||
|
@ -2,7 +2,9 @@ package fluence.hackethberlin
|
||||
|
||||
import shapeless._
|
||||
import types._
|
||||
import record._
|
||||
import Decorator._
|
||||
import shapeless.labelled.FieldType
|
||||
import syntax.singleton._
|
||||
|
||||
object MakeVyperApp extends App {
|
||||
@ -36,6 +38,8 @@ object MakeVyperApp extends App {
|
||||
('record_address ->> address) :: ('other_some ->> uint256) :: HNil
|
||||
)
|
||||
|
||||
println(Console.RED + recordStruct.get('other_some) + Console.RESET)
|
||||
|
||||
println(recordStruct.toVyper)
|
||||
|
||||
println(data.toVyper)
|
||||
|
@ -1,7 +1,12 @@
|
||||
package fluence.hackethberlin.types
|
||||
|
||||
import shapeless.HList
|
||||
import fluence.hackethberlin.Expr
|
||||
import shapeless.{HList, Witness}
|
||||
import shapeless.ops.record.Selector
|
||||
|
||||
class StructType[D <: HList](dataDef: D)(implicit dv: DataVyper[D]) extends Type {
|
||||
def get(k: Witness)(implicit selector : Selector[D, k.T], ev: k.T <:< Type): Expr.Ref[k.T] =
|
||||
Expr.Ref[k.T]("field should be there")
|
||||
|
||||
override def toVyper: String = s"{${dv.toVyperDefinitions(dataDef).mkString(", ")}}"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user