constraints

This commit is contained in:
dmitry.shakhtarin 2018-09-08 03:34:40 +03:00
parent 6880db4d11
commit c39467bb93
5 changed files with 10 additions and 9 deletions

View File

@ -16,12 +16,11 @@ object MakeVyperApp extends App {
("address" address) ::
("owner" `public`(address)) ::
("holders" (address ~>> bool)) ::
("struct" `public`(struct)) :: HNil
("structMap" `public`(Mapping(uint256, struct))) ::
("struct" `public`(struct)) ::
("struct2" struct) :: HNil
)
println(data.toVyper)
println(struct.toVyper)
}

View File

@ -1,5 +1,5 @@
package fluence.hackethberlin.types
case class Mapping[K <: PrimitiveType, V <: Type](ktype: K, vtype: V) extends Type {
case class Mapping[K <: PrimitiveType, V <: Type](ktype: K, vtype: V) extends PlainType {
override def toVyper: String = s"${vtype.toVyper}[${ktype.toVyper}]"
}

View File

@ -1,6 +1,6 @@
package fluence.hackethberlin.types
abstract sealed class PrimitiveType(name: String) extends Type {
abstract sealed class PrimitiveType(name: String) extends PlainType {
self
override def toVyper: String = name

View File

@ -1,7 +1,7 @@
package fluence.hackethberlin.types
import shapeless.HList
import shapeless.{HList, LUBConstraint}
class StructType[D <: HList](dataDef: D)(implicit dv: DataVyper[D]) extends Type {
class StructType[D <: HList](dataDef: D)(implicit dv: DataVyper[D], c: LUBConstraint[D, (String, PlainType)]) extends PlainType {
override def toVyper: String = s"{${dv.toVyperDefinitions(dataDef).mkString(", ")}}"
}

View File

@ -2,4 +2,6 @@ package fluence.hackethberlin.types
trait Type {
def toVyper: String
}
}
trait PlainType extends Type