Skip to content

Commit

Permalink
Partial fix
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Mar 17, 2024
1 parent f0cdc17 commit ffb0336
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 9 deletions.
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import org.typelevel.scalacoptions.ScalacOptions
import indigoplugin.IndigoOptions

Global / onChangedBuildSource := ReloadOnSourceChanges
Global / semanticdbEnabled := true

val scala3Version = "3.3.1"
val scala3Version = "3.4.2-RC1-bin-20240311-02c2a6e-NIGHTLY"

ThisBuild / versionScheme := Some("early-semver")
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0"
Expand All @@ -19,6 +20,7 @@ lazy val commonSettings: Seq[sbt.Def.Setting[_]] = Seq(
crossScalaVersions := Seq(scala3Version),
organization := "io.indigoengine",
libraryDependencies ++= Shared.munit.value,
libraryDependencies += "org.scala-lang" %% "scala2-library-tasty-experimental" % scalaVersion.value,
scalacOptions ++= Seq("-language:strictEquality"),
scalafixOnCompile := true,
semanticdbEnabled := true,
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object Dependencies {

object Versions {
val munit = "0.7.29"
val indigo = "0.15.2"
val indigo = "0.16.0"
}

object Shared {
Expand Down
62 changes: 62 additions & 0 deletions scratch.worksheet.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Inlined(
Some(
TypeApply(Ident("summonLabels"), List(TypeSelect(Inlined(None, Nil, Ident("x$1$proxy1")), "MirroredElemLabels")))
),
Nil,
Typed(
Block(
List(
ValDef(
"elem$2",
Inferred(),
Some(TypeApply(Select(Literal(StringConstant("TIME")), "asInstanceOf"), List(TypeIdent("String"))))
)
),
Apply(
TypeApply(
Select(
Inlined(
Some(TypeApply(Ident("summonLabels"), List(Inferred()))),
Nil,
Typed(
Block(
List(
ValDef(
"elem$2",
Inferred(),
Some(
TypeApply(
Select(Literal(StringConstant("VIEWPORT_SIZE")), "asInstanceOf"),
List(TypeIdent("String"))
)
)
)
),
Apply(
TypeApply(
Select(
Inlined(
Some(TypeApply(Ident("summonLabels"), List(Inferred()))),
Nil,
Typed(Ident("Nil"), Applied(TypeIdent("List"), List(TypeIdent("String"))))
),
"::"
),
List(Inferred())
),
List(Ident("elem$2"))
)
),
Applied(TypeIdent("List"), List(TypeIdent("String")))
)
),
"::"
),
List(Inferred())
),
List(Ident("elem$2"))
)
),
Applied(TypeIdent("List"), List(TypeIdent("String")))
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object ShaderPrinter:
render(ast)

@SuppressWarnings(Array("scalafix:DisableSyntax.throw"))
private def render(ast: ShaderAST)(using pp: ShaderPrinter[_]): List[String] =
private def render(ast: ShaderAST)(using pp: ShaderPrinter[?]): List[String] =
val r: ShaderAST => List[String] = {
case Empty() =>
Nil
Expand Down Expand Up @@ -362,7 +362,7 @@ object ShaderPrinter:

p(ast.traverse(pp.transformer.orElse(n => n)))

private def renderStatements(statements: List[ShaderAST])(using pp: ShaderPrinter[_]): List[String] =
private def renderStatements(statements: List[ShaderAST])(using pp: ShaderPrinter[?]): List[String] =
val p =
pp.printer.orElse {
case ShaderAST.RawLiteral(raw) =>
Expand Down Expand Up @@ -397,7 +397,7 @@ object ShaderPrinter:

private def addIndent: String => String = str => " " + str

private def decideType(a: ShaderAST)(using pp: ShaderPrinter[_]): String =
private def decideType(a: ShaderAST)(using pp: ShaderPrinter[?]): String =
a match
case Empty() => "void"
case Block(_) => "void"
Expand Down Expand Up @@ -458,7 +458,7 @@ object ShaderPrinter:
private def processFunctionStatements(
statements: List[ShaderAST],
maybeReturnType: Option[String]
)(using pp: ShaderPrinter[_]): (List[String], String) =
)(using pp: ShaderPrinter[?]): (List[String], String) =
val nonEmpty = statements
.filterNot(_.isEmpty)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ExtractUBOUtils[Q <: Quotes](using val qq: Q):
),
_
)
) if isArray.matches(arrayInstanceName) =>
) if isArray.matches(arrayInstanceName) =>
// e.g. "given_ShaderTypeOf_Float"
val label = typeclassName.split("_").last match
case "Int" => "int"
Expand Down Expand Up @@ -95,6 +95,25 @@ class ExtractUBOUtils[Q <: Quotes](using val qq: Q):
)
) =>
List(label)

case Inlined(
_,
_,
Typed(
Block(
List(
ValDef(
_,
_,
Some(TypeApply(Select(Literal(StringConstant(label)), _), _))
)
),
_
),
_
)
) =>
List(label)

case _ =>
Nil
Expand Down Expand Up @@ -220,7 +239,10 @@ class ExtractUBOUtils[Q <: Quotes](using val qq: Q):
uboName,
pn.zip(lb.zip(tn)).map(p => UBOField(p._1, p._2._2, p._2._1))
)
else throw ShaderError.UBORead("A UBO field was misread.")
else
throw ShaderError.UBORead(
"A UBO field was misread. " + Printer.TreeStructure.show(findTermsOf("summonLabels")(term).head)
)

// General traversal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object UBOReader:
case _: EmptyTuple => Nil
case _: (t *: ts) => summonInline[ValueOf[t]].value.asInstanceOf[String] :: summonLabels[ts]

inline private def summonTypeName[T <: Tuple]: List[ShaderTypeOf[_]] =
inline private def summonTypeName[T <: Tuple]: List[ShaderTypeOf[?]] =
inline erasedValue[T] match
case _: EmptyTuple => Nil
case _: (t *: ts) => summonInline[ShaderTypeOf[t]] :: summonTypeName[ts]
Expand Down

0 comments on commit ffb0336

Please sign in to comment.