Skip to content

Commit

Permalink
Merge pull request #487 from Verdagon/master
Browse files Browse the repository at this point in the history
Fixing build breakages
  • Loading branch information
Verdagon authored Apr 29, 2022
2 parents 17ea329 + 4dedda1 commit c0bcd57
Show file tree
Hide file tree
Showing 35 changed files with 180 additions and 92 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: install prereqs
run: cmd /c '.\scripts\windows\install-compiler-prereqs.bat C:\LLVM13 C:\BootstrappingValeCompiler'
- name: run vcvars and build-compiler-windows.bat
run: cmd /c '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && .\scripts\windows\build-compiler.bat C:\LLVM13\llvm-project-llvmorg-13.0.1 C:\BootstrappingValeCompiler'
run: cmd /c '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && .\scripts\windows\build-compiler.bat C:\LLVM13\llvm-project-llvmorg-13.0.1 C:\BootstrappingValeCompiler --test=all scripts\VERSION'
- uses: actions/upload-artifact@v2
with:
name: Vale-Windows-0.zip
Expand All @@ -30,7 +30,7 @@ jobs:
- name: install prereqs
run: ./scripts/ubuntu/install-compiler-prereqs.sh ~/LLVMForVale ~/BootstrappingValeCompiler
- name: build compiler
run: ./scripts/ubuntu/build-compiler.sh ~/LLVMForVale/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04 ~/BootstrappingValeCompiler --test=all
run: ./scripts/ubuntu/build-compiler.sh ~/LLVMForVale/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04 ~/BootstrappingValeCompiler --test=all ./scripts/VERSION
- uses: actions/upload-artifact@v2
with:
name: Vale-Ubuntu-0.zip
Expand All @@ -43,7 +43,7 @@ jobs:
- name: install prereqs
run: ./scripts/mac/install-compiler-prereqs.sh ~/BootstrappingValeCompiler
- name: build compiler
run: source ~/.zshrc && ./scripts/mac/build-compiler.sh ~/BootstrappingValeCompiler --test=all
run: source ~/.zshrc && ./scripts/mac/build-compiler.sh ~/BootstrappingValeCompiler --test=all ./scripts/VERSION
- uses: actions/upload-artifact@v2
with:
name: Vale-Mac-0.zip
Expand Down
2 changes: 2 additions & 0 deletions Backend/src/globalstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ IRegion* GlobalState::getRegion(RegionId* regionId) {
return rcImm;
} else if (regionId == metalCache->linearRegionId) {
return linearRegion;
} else if (regionId == metalCache->mutRegionId) {
return mutRegion;
// } else if (regionId == metalCache->unsafeRegionId) {
// return unsafeRegion;
// } else if (regionId == metalCache->assistRegionId) {
Expand Down
14 changes: 7 additions & 7 deletions Frontend/Builtins/src/dev/vale/resources/arrays.vale
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import v.builtins.arith.*;

func drop_into<V, S, E, F>(arr [#S]<imm, V>E, consumer &F) void
where Prot["__call", Refs(&F, E), void]
where func(&F, E)void
{}

extern("vale_static_sized_array_drop_into")
func drop_into<V, S, E, F>(arr [#S]<mut, V>E, consumer &F) void
where Prot["__call", Refs(&F, E), void];
where func(&F, E)void;

func drop<V, S, E>(arr [#S]<mut, V>E) void {
drop_into(arr, {_;});
}
func drop<V, S, E>(arr [#S]<imm, V>E) void {}

func drop_into<E, F>(arr []<mut>E, consumer &F) void
where Prot["__call", Refs(&F, E), void]
where func(&F, E)void
{
while (arr.len() > 0) {
consumer(arr.pop());
}
[] = arr;
}
func drop<E>(arr []<mut>E) void
where Prot["drop", Refs(E), void] {
where func drop(E)void {
drop_into(arr, {_;});
}

func drop_into<E, F>(arr []<imm>E, consumer &F) void
where Prot["__call", Refs(&F, E), void]
where func(&F, E)void
{
i = arr.len() - 1;
while (i >= 0) {
Expand Down Expand Up @@ -68,7 +68,7 @@ func Array<M, E, G>(n int, generator G) []<M>E
where
M Mutability = mut,
G Ref = Ref[any(share, borrow), _],
F Prot = Prot["__call", Refs(G, int), E]
F Prot = func(G, int)E
{
arr = Array<mut, E>(n);
i = 0;
Expand All @@ -85,4 +85,4 @@ where
M Mutability = imm,
E Ref,
G Ref = Ref[any(share, borrow), _],
F Prot = Prot["__call", Refs(G, int), E];
F Prot = func(G, int)E;
4 changes: 2 additions & 2 deletions Frontend/Builtins/src/dev/vale/resources/opt.vale
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ struct None<T> where T Ref { }
impl<T> Opt<T> for None<T>;

abstract func drop<T>(virtual opt Opt<T>)
where Prot["drop", Refs(T), void];
where func drop(T)void;

func drop<T>(opt Some<T>)
where Prot["drop", Refs(T), void]
where func drop(T)void
{
[x] = opt;
}
Expand Down
6 changes: 3 additions & 3 deletions Frontend/Builtins/src/dev/vale/resources/result.vale
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ impl<OkType, ErrType> Result<OkType, ErrType> for Err<OkType, ErrType>;


abstract func drop<OkType, ErrType>(virtual self Result<OkType, ErrType>)
where Prot["drop", Refs(OkType), void], Prot["drop", Refs(ErrType), void];
where func drop(OkType)void, func drop(ErrType)void;

func drop<OkType, ErrType>(self Ok<OkType, ErrType>)
where Prot["drop", Refs(OkType), void]
where func drop(OkType)void
{
[x] = self;
}

func drop<OkType, ErrType>(self Err<OkType, ErrType>)
where Prot["drop", Refs(ErrType), void] {
where func drop(ErrType)void {
[x] = self;
}

Expand Down
2 changes: 1 addition & 1 deletion Frontend/Builtins/src/dev/vale/resources/tup.vale
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

struct Tup<T> M
struct Tup<T RefList> M
where T RefList, M Mutability, M = refListCompoundMutability(T) {
_ ..T;
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class HigherTypingPassTests extends FunSuite with Matchers {
val compilation =
HigherTypingTestCompilation.test(
"""func moo<T>()
|where Prot["moo", Refs(T, bool), str]
|where func moo(T, bool)str
|{
|}
|""".stripMargin)
Expand Down
6 changes: 6 additions & 0 deletions Frontend/Highlighter/src/dev/vale/highlighter/Spanner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,12 @@ object Spanner {
range,
Vector())
}
case VariabilityPT(range, variability) => {
makeSpan(
Rune,
range,
Vector())
}
case other => vimpl(other.toString)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Frontend/IntegrationTests/test/dev/vale/ArrayTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class ArrayTests extends FunSuite with Matchers {
|func __call(lam Lam, i int) int { return i; }
|
|exported func main() int
|where F Prot = Prot["__call", Refs(Lam, int), int] {
|where F Prot = func(Lam, int)int {
| a = #[](10, Lam());
| return a.3;
|}
Expand Down Expand Up @@ -481,7 +481,7 @@ class ArrayTests extends FunSuite with Matchers {
val compile = RunCompilation.test(
"""
|func myFunc<F>(generator F) T
|where T Ref, Prot["__call", Refs(F, int), T]
|where T Ref, func(F, int)T
|{
| return generator(9);
|}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ class IntegrationTestsA extends FunSuite with Matchers {
val compile = RunCompilation.test(
"""
|func each<E, F>(func F) void
|where Prot["__call", Refs(&F, &E), void] {
|where func(&F, &E)void {
|}
|
|struct PageMember { x int; }
Expand Down
7 changes: 7 additions & 0 deletions Frontend/ParsingPass/src/dev/vale/parsing/ParsedLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,13 @@ object ParsedLoader {
loadRange(getObjectField(jobj, "range")),
loadTemplex(getObjectField(jobj, "inner")))
}
case "PrototypeT" => {
PrototypePT(
loadRange(getObjectField(jobj, "range")),
loadName(getObjectField(jobj, "name")),
getArrayField(jobj, "parameters").map(expectObject).map(loadTemplex),
loadTemplex(getObjectField(jobj, "returnType")))
}
case x => vimpl(x.toString)
}
}
Expand Down
9 changes: 9 additions & 0 deletions Frontend/ParsingPass/src/dev/vale/parsing/PatternParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,20 @@ class PatternParser {
return Ok(ConstructingMemberNameDeclarationP(NameP(ast.RangeP(begin, name.range.end), name.str)))
}

if (iter.trySkip(() => "^let".r)) {
iter.consumeWhitespace()

if (iter.trySkip(() => "^mut".r)) {
iter.consumeWhitespace()
}
}

val name =
Parser.parseLocalOrMemberName(iter) match {
case None => return Err(BadLocalName(iter.getPos()))
case Some(n) => n
}
iter.trySkip(() => "^!".r)
return Ok(LocalNameDeclarationP(name))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,17 @@ class TemplexParser {
iter.consumeWhitespace()

val name =
Parser.parseFunctionOrLocalOrMemberName(iter) match {
case None => return Err(BadPrototypeName(iter.getPos()))
case Some(x) => x
if (iter.peek(() => "^\\(".r)) {
NameP(RangeP(iter.getPos(), iter.getPos()), "__call")
} else {
Parser.parseFunctionOrLocalOrMemberName(iter) match {
case None => return Err(BadPrototypeName(iter.getPos()))
case Some(x) => x
}
}

iter.consumeWhitespace()

val args =
parseTuple(iter) match {
case Err(e) => return Err(e)
Expand Down Expand Up @@ -511,18 +517,27 @@ class TemplexParser {
Ok(Some(ast.TypedPR(RangeP(begin, iter.getPos()), maybeRuneName, runeType)))
}

def parseRuleCall(iter: ParsingIterator): Result[Option[IRulexPR], IParseError] = {
val begin = iter.getPos()
def parseRuleCall(originalIter: ParsingIterator): Result[Option[IRulexPR], IParseError] = {
val tentativeIter = originalIter.clone()

val begin = tentativeIter.getPos()
val nameAndOpenParen =
iter.tryy(() => "^\\w+\\(".r) match {
case None => return Ok(None)
case Some(nameAndOpenParen) => nameAndOpenParen
}
tentativeIter.tryy(() => "^\\w+\\(".r) match {
case None => return Ok(None)
case Some(nameAndOpenParen) => nameAndOpenParen
}

val nameStr = nameAndOpenParen.init
val nameEnd = iter.getPos() - 1
if (nameStr == "func") {
return Ok(None)
}

val nameEnd = tentativeIter.getPos() - 1
val name = NameP(RangeP(begin, nameEnd), nameStr)

originalIter.skipTo(tentativeIter.getPos())
val iter = originalIter

iter.consumeWhitespace()
if (iter.trySkip(() => "^\\s*\\)".r)) {
return Ok(Some(BuiltinCallPR(RangeP(begin, iter.getPos()), name, Vector())))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.vale.postparsing

import dev.vale.postparsing.rules.{AugmentSR, CallSR, CoerceToCoordSR, CoordComponentsSR, CoordIsaSR, EqualsSR, IRulexSR, IsConcreteSR, IsInterfaceSR, IsStructSR, KindComponentsSR, KindIsaSR, LiteralSR, LookupSR, OneOfSR, PackSR, PrototypeComponentsSR, PrototypeSR, RefListCompoundMutabilitySR, RuneParentEnvLookupSR, RuntimeSizedArraySR, StaticSizedArraySR}
import dev.vale.postparsing.rules.{AugmentSR, CallSR, CoerceToCoordSR, CoordComponentsSR, CoordIsaSR, EqualsSR, IRulexSR, IsConcreteSR, IsInterfaceSR, IsStructSR, KindComponentsSR, KindIsaSR, LiteralSR, LookupSR, OneOfSR, PackSR, PrototypeComponentsSR, RefListCompoundMutabilitySR, RuneParentEnvLookupSR, RuntimeSizedArraySR, StaticSizedArraySR}
import dev.vale.solver.{IIncompleteOrFailedSolve, ISolveRule, ISolverError, IStepState, IncompleteSolve, Solver}
import dev.vale.{Err, Ok, RangeS, Result, vassert, vimpl, vpass}
import dev.vale._
Expand Down Expand Up @@ -35,7 +35,7 @@ object IdentifiabilitySolver {
case LiteralSR(range, rune, literal) => Array(rune)
case AugmentSR(range, resultRune, ownership, innerRune) => Array(resultRune, innerRune)
case CallSR(range, resultRune, templateRune, args) => Array(resultRune, templateRune) ++ args
case PrototypeSR(range, resultRune, name, parameters, returnTypeRune) => Array(resultRune) ++ parameters ++ Array(returnTypeRune)
// case PrototypeSR(range, resultRune, name, parameters, returnTypeRune) => Array(resultRune) ++ parameters ++ Array(returnTypeRune)
case PackSR(range, resultRune, members) => Array(resultRune) ++ members
case StaticSizedArraySR(range, resultRune, mutabilityRune, variabilityRune, sizeRune, elementRune) => Array(resultRune, mutabilityRune, variabilityRune, sizeRune, elementRune)
case RuntimeSizedArraySR(range, resultRune, mutabilityRune, elementRune) => Array(resultRune, mutabilityRune, elementRune)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.vale.postparsing

import dev.vale.{Err, Interner, Ok, RangeS, Result, vassert, vassertSome, vfail, vpass, vwat}
import dev.vale.postparsing.rules.{AugmentSR, CallSR, CoerceToCoordSR, CoordComponentsSR, CoordIsaSR, EqualsSR, IRulexSR, IsConcreteSR, IsInterfaceSR, IsStructSR, KindComponentsSR, KindIsaSR, LiteralSR, LookupSR, OneOfSR, PackSR, PrototypeComponentsSR, PrototypeSR, RefListCompoundMutabilitySR, RuneParentEnvLookupSR, RuntimeSizedArraySR, StaticSizedArraySR}
import dev.vale.postparsing.rules.{AugmentSR, CallSR, CoerceToCoordSR, CoordComponentsSR, CoordIsaSR, EqualsSR, IRulexSR, IsConcreteSR, IsInterfaceSR, IsStructSR, KindComponentsSR, KindIsaSR, LiteralSR, LookupSR, OneOfSR, PackSR, PrototypeComponentsSR, RefListCompoundMutabilitySR, RuneParentEnvLookupSR, RuntimeSizedArraySR, StaticSizedArraySR}
import dev.vale.solver.{IIncompleteOrFailedSolve, ISolveRule, ISolverError, IStepState, IncompleteSolve, Solver, SolverConflict}
import dev.vale._
import dev.vale.postparsing.rules._
Expand Down Expand Up @@ -36,7 +36,7 @@ class RuneTypeSolver(interner: Interner) {
case LiteralSR(range, rune, literal) => Array(rune)
case AugmentSR(range, resultRune, ownership, innerRune) => Array(resultRune, innerRune)
case CallSR(range, resultRune, templateRune, args) => Array(resultRune, templateRune) ++ args
case PrototypeSR(range, resultRune, name, parameters, returnTypeRune) => Array(resultRune) ++ parameters ++ Array(returnTypeRune)
// case PrototypeSR(range, resultRune, name, parameters, returnTypeRune) => Array(resultRune, returnTypeRune) ++ parameters
case PackSR(range, resultRune, members) => Array(resultRune) ++ members
case StaticSizedArraySR(range, resultRune, mutabilityRune, variabilityRune, sizeRune, elementRune) => Array(resultRune, mutabilityRune, variabilityRune, sizeRune, elementRune)
case RuntimeSizedArraySR(range, resultRune, mutabilityRune, elementRune) => Array(resultRune, mutabilityRune, elementRune)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,31 @@ class TemplexScout(
translateTemplex(env, lidb.child(), ruleBuilder, returnType)))
resultRuneS
}
case PrototypePT(range, NameP(_, name), parameters, returnType) => {
case PrototypePT(range, NameP(nameRange, name), paramsP, returnTypeP) => {

val nameRuneS = rules.RuneUsage(evalRange(range), ImplicitRuneS(lidb.child().consume()))
ruleBuilder +=
LiteralSR(evalRange(nameRange), nameRuneS, StringLiteralSL(name))

val paramsS =
paramsP.map(paramP => {
translateTemplex(env, lidb.child(), ruleBuilder, paramP)
})
val paramListRuneS = rules.RuneUsage(evalRange(range), ImplicitRuneS(lidb.child().consume()))
ruleBuilder +=
PackSR(evalRange(nameRange), paramListRuneS, paramsS.toArray)

val returnTypeS = translateTemplex(env, lidb.child(), ruleBuilder, returnTypeP)

val resultRuneS = rules.RuneUsage(evalRange(range), ImplicitRuneS(lidb.child().consume()))
ruleBuilder +=
PrototypeSR(
evalRange(range),
PrototypeComponentsSR(
PostParser.evalRange(env.file, range),
resultRuneS,
name,
parameters.map(translateTemplex(env, lidb.child(), ruleBuilder, _)).toArray,
translateTemplex(env, lidb.child(), ruleBuilder, returnType))
nameRuneS,
paramListRuneS,
returnTypeS)

resultRuneS
}
case PackPT(range, members) => {
Expand Down
20 changes: 10 additions & 10 deletions Frontend/PostParsingPass/src/dev/vale/postparsing/rules/rules.scala
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,16 @@ case class CallSR(
override def runeUsages: Array[RuneUsage] = Array(resultRune, templateRune) ++ args
}

case class PrototypeSR(
range: RangeS,
resultRune: RuneUsage,
name: String,
parameters: Array[RuneUsage],
returnTypeRune: RuneUsage
) extends IRulexSR {
override def equals(obj: Any): Boolean = vcurious(); override def hashCode(): Int = vcurious()
override def runeUsages: Array[RuneUsage] = Array(resultRune, returnTypeRune) ++ parameters
}
//case class PrototypeSR(
// range: RangeS,
// resultRune: RuneUsage,
// name: String,
// parameters: Array[RuneUsage],
// returnTypeRune: RuneUsage
//) extends IRulexSR {
// override def equals(obj: Any): Boolean = vcurious(); override def hashCode(): Int = vcurious()
// override def runeUsages: Array[RuneUsage] = Array(resultRune, returnTypeRune) ++ parameters
//}

case class PackSR(
range: RangeS,
Expand Down
6 changes: 3 additions & 3 deletions Frontend/Tests/test/main/resources/array/make/make.vale
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ func MakeArray<T, G>(n int, generator G) []<mut>T
where
T Ref,
G Ref = Ref[any(share, borrow), _],
F Prot = Prot["__call", Refs(G, int), T]
F Prot = func(G, int)T
{
arr = Array<mut, T>(n);
i = 0;
Expand All @@ -18,7 +18,7 @@ func MakeVaryArray<T, G>(n int, generator G) []<mut>T
where
T Ref,
G Ref = Ref[any(share, borrow), _],
F Prot = Prot["__call", Refs(G, int), T]
F Prot = func(G, int)T
{
arr = Array<mut, T>(n);
i = 0;
Expand All @@ -33,7 +33,7 @@ func MakeImmArray<G>(n int, generator G) []<imm>T
where
T Ref,
G Ref = Ref[any(share, borrow), _],
F Prot = Prot["__call", Refs(G, int), T]
F Prot = func(G, int)T
{
return Array<imm, T>(n, generator);
}
Expand Down
Loading

0 comments on commit c0bcd57

Please sign in to comment.