Skip to content

Commit

Permalink
Merges from master
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Ovadia committed Jul 14, 2023
1 parent 7c5d18e commit 7ec8adb
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ class Instantiator(
case VoidLiteralTE(_) => {
(CoordI[sI](MutableShareI, VoidIT()), VoidLiteralIE())
}
case FunctionCallTE(prototypeT, args) => {
case FunctionCallTE(prototypeT, args, returnType) => {
val innersCE =
args.map(argTE => {
val (argIT, argCE) =
Expand Down
2 changes: 1 addition & 1 deletion Frontend/IntegrationTests/test/dev/vale/ClosureTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class ClosureTests extends FunSuite with Matchers {
Collector.all(
coutputs.lookupFunction("main"),
{
case FunctionCallTE(p @ PrototypeT(IdT(_, _, LambdaCallFunctionNameT(_, _, _)), _), _) => p
case FunctionCallTE(p @ PrototypeT(IdT(_, _, LambdaCallFunctionNameT(_, _, _)), _), _, _) => p
}))
params.head match {
case CoordT(ShareT, _, StructTT(IdT(_, Vector(FunctionNameT(FunctionTemplateNameT(StrI("main"), _),Vector(),Vector())),LambdaCitizenNameT(_)))) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class InferTemplateTests extends FunSuite with Matchers {
}
val main = compile.expectCompilerOutputs().lookupFunction("main")
Collector.only(main, {
case FunctionCallTE(PrototypeT(IdT(_, _, FunctionNameT(FunctionTemplateNameT(StrI("moo"), _), templateArgs, _)), _), _) => {
case FunctionCallTE(PrototypeT(IdT(_, _, FunctionNameT(FunctionTemplateNameT(StrI("moo"), _), templateArgs, _)), _), _, _) => {
templateArgs match {
case Vector(CoordTemplataT(CoordT(OwnT, _, StructTT(IdT(x, Vector(), StructNameT(StructTemplateNameT(StrI("Muta")), Vector())))))) => {
vassert(x.isTest)
Expand Down
28 changes: 14 additions & 14 deletions Frontend/IntegrationTests/test/dev/vale/OwnershipTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class OwnershipTests extends FunSuite with Matchers {
""".stripMargin)

val main = compile.expectCompilerOutputs().lookupFunction("main")
Collector.only(main, { case FunctionCallTE(functionNameT("drop"), _) => })
Collector.all(main, { case FunctionCallTE(_, _) => }).size shouldEqual 2
Collector.only(main, { case FunctionCallTE(functionNameT("drop"), _, _) => })
Collector.all(main, { case FunctionCallTE(_, _, _) => }).size shouldEqual 2

compile.evalForKind(Vector())
}
Expand All @@ -94,8 +94,8 @@ class OwnershipTests extends FunSuite with Matchers {
""".stripMargin)

val main = compile.expectCompilerOutputs().lookupFunction("main")
Collector.only(main, { case FunctionCallTE(functionNameT("drop"), _) => })
Collector.all(main, { case FunctionCallTE(_, _) => }).size shouldEqual 2
Collector.only(main, { case FunctionCallTE(functionNameT("drop"), _, _) => })
Collector.all(main, { case FunctionCallTE(_, _, _) => }).size shouldEqual 2

compile.evalForStdout(Vector()) shouldEqual "Destroying!\n"
}
Expand All @@ -119,7 +119,7 @@ class OwnershipTests extends FunSuite with Matchers {
""".stripMargin)

val main = compile.expectCompilerOutputs().lookupFunction("main")
Collector.only(main, { case FunctionCallTE(functionNameT("drop"), _) => })
Collector.only(main, { case FunctionCallTE(functionNameT("drop"), _, _) => })

compile.evalForKindAndStdout(Vector()) match { case (VonInt(10), "Destroying!\n") => }
}
Expand All @@ -143,8 +143,8 @@ class OwnershipTests extends FunSuite with Matchers {
""".stripMargin)

val main = compile.expectCompilerOutputs().lookupFunction("main")
Collector.only(main, { case FunctionCallTE(functionNameT("drop"), _) => })
Collector.all(main, { case FunctionCallTE(_, _) => }).size shouldEqual 2
Collector.only(main, { case FunctionCallTE(functionNameT("drop"), _, _) => })
Collector.all(main, { case FunctionCallTE(_, _, _) => }).size shouldEqual 2

compile.evalForStdout(Vector()) shouldEqual "Destroying!\n"
}
Expand Down Expand Up @@ -184,18 +184,18 @@ class OwnershipTests extends FunSuite with Matchers {
}
}))
// The only function lookup should be println
Collector.only(destructor, { case FunctionCallTE(functionNameT("println"), _) => })
Collector.only(destructor, { case FunctionCallTE(functionNameT("println"), _, _) => })
// Only one call (the above println)
Collector.all(destructor, { case FunctionCallTE(_, _) => }).size shouldEqual 1
Collector.all(destructor, { case FunctionCallTE(_, _, _) => }).size shouldEqual 1

// moo should be calling the destructor
val moo = coutputs.lookupFunction("moo")
Collector.only(moo, { case FunctionCallTE(functionNameT("drop"), _) => })
Collector.only(moo, { case FunctionCallTE(_, _) => })
Collector.only(moo, { case FunctionCallTE(functionNameT("drop"), _, _) => })
Collector.only(moo, { case FunctionCallTE(_, _, _) => })

// main should not be calling the destructor
val main = coutputs.lookupFunction("main")
Collector.all(main, { case FunctionCallTE(functionNameT("drop"), _) => true }).size shouldEqual 0
Collector.all(main, { case FunctionCallTE(functionNameT("drop"), _, _) => true }).size shouldEqual 0

compile.evalForStdout(Vector()) shouldEqual "Destroying!\n"
}
Expand All @@ -220,8 +220,8 @@ class OwnershipTests extends FunSuite with Matchers {
""".stripMargin)

val main = compile.expectCompilerOutputs().lookupFunction("main")
Collector.only(main, { case FunctionCallTE(functionNameT("drop"), _) => })
Collector.all(main, { case FunctionCallTE(_, _) => }).size shouldEqual 2
Collector.only(main, { case FunctionCallTE(functionNameT("drop"), _, _) => })
Collector.all(main, { case FunctionCallTE(_, _, _) => }).size shouldEqual 2

compile.evalForKindAndStdout(Vector()) match { case (VonInt(10), "Destroying!\n") => }
}
Expand Down
1 change: 0 additions & 1 deletion Frontend/TypingPass/src/dev/vale/typing/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import dev.vale.typing.expression.LocalHelper
import dev.vale.typing.types._
import dev.vale.typing.templata._
import dev.vale.typing.function.FunctionCompiler
import dev.vale.typing.function.FunctionCompiler._
import dev.vale.typing.macros.citizen.StructDropMacro
import dev.vale.typing.macros.ssa.SSALenMacro

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class CompilerLambdaTests extends FunSuite with Matchers {
vassert(coutputs.nameIsLambdaIn(lambda.header.id, "main"))

val main = coutputs.lookupFunction("main");
Collector.only(main, { case FunctionCallTE(callee, _) if coutputs.nameIsLambdaIn(callee.id, "main") => })
Collector.only(main, { case FunctionCallTE(callee, _, _) if coutputs.nameIsLambdaIn(callee.id, "main") => })
}

test("Tests lambda and concept function") {
Expand Down
19 changes: 11 additions & 8 deletions Frontend/TypingPass/test/dev/vale/typing/CompilerSolverTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class CompilerSolverTests extends FunSuite with Matchers {
Vector(FunctionTemplateNameT(StrI("bork"),_)),
KindPlaceholderNameT(KindPlaceholderTemplateNameT(0, _)))))))),
CoordT(ShareT,_, VoidT())),
_,
_) =>
}
}
Expand Down Expand Up @@ -115,7 +116,8 @@ class CompilerSolverTests extends FunSuite with Matchers {
Vector(CoordTemplataT(CoordT(ShareT,RegionT(), IntT(32)))),
Vector(CoordT(ShareT,RegionT(), IntT(32))))),
CoordT(ShareT,RegionT(), IntT(32))),
Vector(ConstantIntTE(IntegerTemplataT(3),32, _))) =>
Vector(ConstantIntTE(IntegerTemplataT(3),32, _)),
_) =>
}
}

Expand Down Expand Up @@ -168,7 +170,7 @@ class CompilerSolverTests extends FunSuite with Matchers {
case BlockTE(
ReturnTE(
ConsecutorTE(
Vector(FunctionCallTE(prototype, _),
Vector(FunctionCallTE(prototype, _, _),
VoidLiteralTE(_))))) => prototype
}
prototype match {
Expand Down Expand Up @@ -357,7 +359,7 @@ class CompilerSolverTests extends FunSuite with Matchers {
)
val coutputs = compile.expectCompilerOutputs()
Collector.only(coutputs.lookupFunction("main"), {
case FunctionCallTE(PrototypeT(simpleNameT("moo"), _), _) =>
case FunctionCallTE(PrototypeT(simpleNameT("moo"), _), _, _) =>
})
}

Expand All @@ -375,7 +377,7 @@ class CompilerSolverTests extends FunSuite with Matchers {
)
val coutputs = compile.expectCompilerOutputs()
Collector.only(coutputs.lookupFunction("main"), {
case FunctionCallTE(PrototypeT(simpleNameT("moo"), _), _) =>
case FunctionCallTE(PrototypeT(simpleNameT("moo"), _), _, _) =>
})
}

Expand Down Expand Up @@ -426,7 +428,7 @@ class CompilerSolverTests extends FunSuite with Matchers {
val coutputs = compile.expectCompilerOutputs()
val arg =
coutputs.lookupFunction("main").body shouldHave {
case FunctionCallTE(_, Vector(arg)) => arg
case FunctionCallTE(_, Vector(arg), _) => arg
}
arg.result.coord match {
case CoordT(_, _, StructTT(_)) =>
Expand All @@ -452,7 +454,7 @@ class CompilerSolverTests extends FunSuite with Matchers {
val moo = coutputs.lookupFunction("moo")
val main = coutputs.lookupFunction("main")
main.body shouldHave {
case FunctionCallTE(prototype, Vector(_, _)) => {
case FunctionCallTE(prototype, Vector(_, _), _) => {
prototype.id.localName.templateArgs.head match {
case CoordTemplataT(CoordT(_, _, InterfaceTT(_))) =>
}
Expand Down Expand Up @@ -489,7 +491,8 @@ class CompilerSolverTests extends FunSuite with Matchers {
UpcastTE(
_,
InterfaceTT(IdT(_,_,InterfaceNameT(InterfaceTemplateNameT(StrI("IShip")),Vector(CoordTemplataT(CoordT(ShareT,_,IntT(32))))))),
_))) =>
_)),
_) =>
}
}

Expand Down Expand Up @@ -622,7 +625,7 @@ class CompilerSolverTests extends FunSuite with Matchers {
val main = coutputs.lookupFunction("main")
val call =
Collector.only(main, {
case call @ FunctionCallTE(PrototypeT(IdT(_, _, FunctionNameT(FunctionTemplateNameT(StrI("swap"), _), _, _)), _), _) => call
case call @ FunctionCallTE(PrototypeT(IdT(_, _, FunctionNameT(FunctionTemplateNameT(StrI("swap"), _), _, _)), _), _, _) => call
})
call.callable.id.localName.templateArgs.last match {
case CoordTemplataT(CoordT(ShareT, _, IntT(32))) =>
Expand Down
28 changes: 16 additions & 12 deletions Frontend/TypingPass/test/dev/vale/typing/CompilerTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class CompilerTests extends FunSuite with Matchers {
functionNameT("+"),
Vector(
ConstantIntTE(IntegerTemplataT(2), _, _),
ConstantIntTE(IntegerTemplataT(3), _, _))) =>
ConstantIntTE(IntegerTemplataT(3), _, _)),
_) =>
})
}

Expand Down Expand Up @@ -163,7 +164,7 @@ class CompilerTests extends FunSuite with Matchers {
val coutputs = compile.expectCompilerOutputs()
val main = coutputs.lookupFunction("main")
Collector.only(main, {
case FunctionCallTE(PrototypeT(IdT(_, _, FunctionNameT(FunctionTemplateNameT(StrI("drop"), _), _, _)), _), _) =>
case FunctionCallTE(PrototypeT(IdT(_, _, FunctionNameT(FunctionTemplateNameT(StrI("drop"), _), _, _)), _), _, _) =>
})
}

Expand All @@ -182,7 +183,7 @@ class CompilerTests extends FunSuite with Matchers {
val coutputs = compile.expectCompilerOutputs()
val main = coutputs.lookupFunction("main")
Collector.only(main, {
case FunctionCallTE(PrototypeT(IdT(_, _, FunctionNameT(FunctionTemplateNameT(StrI("drop"), _), _, _)), _), _) =>
case FunctionCallTE(PrototypeT(IdT(_, _, FunctionNameT(FunctionTemplateNameT(StrI("drop"), _), _, _)), _), _, _) =>
})
}

Expand Down Expand Up @@ -301,7 +302,8 @@ class CompilerTests extends FunSuite with Matchers {
Collector.only(main, {
case FunctionCallTE(
PrototypeT(simpleNameT("MyStruct"), _),
Vector(ConstantIntTE(IntegerTemplataT(7), _, _))) =>
Vector(ConstantIntTE(IntegerTemplataT(7), _, _)),
_) =>
})
}

Expand All @@ -320,8 +322,8 @@ class CompilerTests extends FunSuite with Matchers {
""".stripMargin)

val main = compile.expectCompilerOutputs().lookupFunction("main")
Collector.only(main, { case FunctionCallTE(PrototypeT(IdT(_, _, FunctionNameT(FunctionTemplateNameT(StrI("drop"), _), _, _)), _), _) => })
Collector.all(main, { case FunctionCallTE(_, _) => }).size shouldEqual 2
Collector.only(main, { case FunctionCallTE(PrototypeT(IdT(_, _, FunctionNameT(FunctionTemplateNameT(StrI("drop"), _), _, _)), _), _, _) => })
Collector.all(main, { case FunctionCallTE(_, _, _) => }).size shouldEqual 2
}

test("Tests defining an empty interface and an implementing struct") {
Expand Down Expand Up @@ -462,7 +464,7 @@ class CompilerTests extends FunSuite with Matchers {
FunctionTemplateNameT(StrI("drop"),_),
Vector(),
Vector(CoordT(OwnT,_,StructTT(IdT(_,_,StructNameT(StructTemplateNameT(StrI("MyStruct")),Vector()))))))),
CoordT(ShareT,_,VoidT())), _) =>
CoordT(ShareT,_,VoidT())), _, _) =>
}
}

Expand Down Expand Up @@ -602,7 +604,7 @@ class CompilerTests extends FunSuite with Matchers {
}

Collector.all(coutputs.lookupFunction("main"), {
case FunctionCallTE(functionNameT("MySome"), _) =>
case FunctionCallTE(functionNameT("MySome"), _, _) =>
})
}

Expand Down Expand Up @@ -660,7 +662,7 @@ class CompilerTests extends FunSuite with Matchers {

val main = coutputs.lookupFunction("main")
Collector.only(main, {
case f @ FunctionCallTE(PrototypeT(simpleNameT("doCivicDance"),CoordT(ShareT,_, IntT.i32)), _) => {
case f @ FunctionCallTE(PrototypeT(simpleNameT("doCivicDance"),CoordT(ShareT,_, IntT.i32)), _, _) => {
// vassert(f.callable.paramTypes == Vector(Coord(Borrow,InterfaceRef2(simpleName("Car")))))
}
})
Expand Down Expand Up @@ -822,7 +824,7 @@ class CompilerTests extends FunSuite with Matchers {

val main = coutputs.lookupFunction("main")
Collector.only(main, {
case f @ FunctionCallTE(functionNameT("forEach"), _) => f
case f @ FunctionCallTE(functionNameT("forEach"), _, _) => f
})
}

Expand All @@ -847,7 +849,8 @@ class CompilerTests extends FunSuite with Matchers {
val main = coutputs.lookupFunction("main")
val destructorCalls =
Collector.all(main, {
case fpc @ FunctionCallTE(PrototypeT(IdT(_,Vector(StructTemplateNameT(StrI("Marine"))),FunctionNameT(FunctionTemplateNameT(StrI("drop"),_),Vector(),Vector(CoordT(OwnT,_, StructTT(IdT(_,Vector(),StructNameT(StructTemplateNameT(StrI("Marine")),Vector()))))))),_),_) => fpc
case fpc @ FunctionCallTE(
PrototypeT(IdT(_,Vector(StructTemplateNameT(StrI("Marine"))),FunctionNameT(FunctionTemplateNameT(StrI("drop"),_),Vector(),Vector(CoordT(OwnT,_, StructTT(IdT(_,Vector(),StructNameT(StructTemplateNameT(StrI("Marine")),Vector()))))))),_),_,_) => fpc
})
destructorCalls.size shouldEqual 2
}
Expand Down Expand Up @@ -1866,7 +1869,8 @@ class CompilerTests extends FunSuite with Matchers {
Collector.only(mainFunc, {
case FunctionCallTE(
prototype @ PrototypeT(IdT(_,Vector(),FunctionNameT(FunctionTemplateNameT(StrI("as"),_),_,_)), _),
Vector(arg)) => {
Vector(arg),
_) => {
(prototype, arg)
}
})
Expand Down

0 comments on commit 7ec8adb

Please sign in to comment.