diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba5929c9f..750be7f15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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 diff --git a/Backend/src/globalstate.cpp b/Backend/src/globalstate.cpp index 604402c6a..b8f1a08a7 100644 --- a/Backend/src/globalstate.cpp +++ b/Backend/src/globalstate.cpp @@ -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) { diff --git a/Frontend/Builtins/src/dev/vale/resources/arrays.vale b/Frontend/Builtins/src/dev/vale/resources/arrays.vale index 8624e771b..3c352029f 100644 --- a/Frontend/Builtins/src/dev/vale/resources/arrays.vale +++ b/Frontend/Builtins/src/dev/vale/resources/arrays.vale @@ -1,12 +1,12 @@ import v.builtins.arith.*; func drop_into(arr [#S]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(arr [#S]E, consumer &F) void -where Prot["__call", Refs(&F, E), void]; +where func(&F, E)void; func drop(arr [#S]E) void { drop_into(arr, {_;}); @@ -14,7 +14,7 @@ func drop(arr [#S]E) void { func drop(arr [#S]E) void {} func drop_into(arr []E, consumer &F) void -where Prot["__call", Refs(&F, E), void] +where func(&F, E)void { while (arr.len() > 0) { consumer(arr.pop()); @@ -22,12 +22,12 @@ where Prot["__call", Refs(&F, E), void] [] = arr; } func drop(arr []E) void -where Prot["drop", Refs(E), void] { +where func drop(E)void { drop_into(arr, {_;}); } func drop_into(arr []E, consumer &F) void -where Prot["__call", Refs(&F, E), void] +where func(&F, E)void { i = arr.len() - 1; while (i >= 0) { @@ -68,7 +68,7 @@ func Array(n int, generator G) []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(n); i = 0; @@ -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; diff --git a/Frontend/Builtins/src/dev/vale/resources/opt.vale b/Frontend/Builtins/src/dev/vale/resources/opt.vale index e3962ec5e..f7d43cc4e 100644 --- a/Frontend/Builtins/src/dev/vale/resources/opt.vale +++ b/Frontend/Builtins/src/dev/vale/resources/opt.vale @@ -12,10 +12,10 @@ struct None where T Ref { } impl Opt for None; abstract func drop(virtual opt Opt) -where Prot["drop", Refs(T), void]; +where func drop(T)void; func drop(opt Some) -where Prot["drop", Refs(T), void] +where func drop(T)void { [x] = opt; } diff --git a/Frontend/Builtins/src/dev/vale/resources/result.vale b/Frontend/Builtins/src/dev/vale/resources/result.vale index 0df173c07..507d00fcb 100644 --- a/Frontend/Builtins/src/dev/vale/resources/result.vale +++ b/Frontend/Builtins/src/dev/vale/resources/result.vale @@ -15,16 +15,16 @@ impl Result for Err; abstract func drop(virtual self Result) -where Prot["drop", Refs(OkType), void], Prot["drop", Refs(ErrType), void]; +where func drop(OkType)void, func drop(ErrType)void; func drop(self Ok) -where Prot["drop", Refs(OkType), void] +where func drop(OkType)void { [x] = self; } func drop(self Err) -where Prot["drop", Refs(ErrType), void] { +where func drop(ErrType)void { [x] = self; } diff --git a/Frontend/Builtins/src/dev/vale/resources/tup.vale b/Frontend/Builtins/src/dev/vale/resources/tup.vale index 01c8ef883..64d71e28e 100644 --- a/Frontend/Builtins/src/dev/vale/resources/tup.vale +++ b/Frontend/Builtins/src/dev/vale/resources/tup.vale @@ -1,5 +1,5 @@ -struct Tup M +struct Tup M where T RefList, M Mutability, M = refListCompoundMutability(T) { _ ..T; } diff --git a/Frontend/HigherTypingPass/test/dev/vale/highertyping/HigherTypingPassTests.scala b/Frontend/HigherTypingPass/test/dev/vale/highertyping/HigherTypingPassTests.scala index 588b7efcb..e8f6d869c 100644 --- a/Frontend/HigherTypingPass/test/dev/vale/highertyping/HigherTypingPassTests.scala +++ b/Frontend/HigherTypingPass/test/dev/vale/highertyping/HigherTypingPassTests.scala @@ -141,7 +141,7 @@ class HigherTypingPassTests extends FunSuite with Matchers { val compilation = HigherTypingTestCompilation.test( """func moo() - |where Prot["moo", Refs(T, bool), str] + |where func moo(T, bool)str |{ |} |""".stripMargin) diff --git a/Frontend/Highlighter/src/dev/vale/highlighter/Spanner.scala b/Frontend/Highlighter/src/dev/vale/highlighter/Spanner.scala index c495dee50..120efcd86 100644 --- a/Frontend/Highlighter/src/dev/vale/highlighter/Spanner.scala +++ b/Frontend/Highlighter/src/dev/vale/highlighter/Spanner.scala @@ -457,6 +457,12 @@ object Spanner { range, Vector()) } + case VariabilityPT(range, variability) => { + makeSpan( + Rune, + range, + Vector()) + } case other => vimpl(other.toString) } } diff --git a/Frontend/IntegrationTests/test/dev/vale/ArrayTests.scala b/Frontend/IntegrationTests/test/dev/vale/ArrayTests.scala index f09891f3d..09471326d 100644 --- a/Frontend/IntegrationTests/test/dev/vale/ArrayTests.scala +++ b/Frontend/IntegrationTests/test/dev/vale/ArrayTests.scala @@ -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; |} @@ -481,7 +481,7 @@ class ArrayTests extends FunSuite with Matchers { val compile = RunCompilation.test( """ |func myFunc(generator F) T - |where T Ref, Prot["__call", Refs(F, int), T] + |where T Ref, func(F, int)T |{ | return generator(9); |} diff --git a/Frontend/IntegrationTests/test/dev/vale/IntegrationTestsA.scala b/Frontend/IntegrationTests/test/dev/vale/IntegrationTestsA.scala index 0ac02d04c..25a5788fe 100644 --- a/Frontend/IntegrationTests/test/dev/vale/IntegrationTestsA.scala +++ b/Frontend/IntegrationTests/test/dev/vale/IntegrationTestsA.scala @@ -797,7 +797,7 @@ class IntegrationTestsA extends FunSuite with Matchers { val compile = RunCompilation.test( """ |func each(func F) void - |where Prot["__call", Refs(&F, &E), void] { + |where func(&F, &E)void { |} | |struct PageMember { x int; } diff --git a/Frontend/ParsingPass/src/dev/vale/parsing/ParsedLoader.scala b/Frontend/ParsingPass/src/dev/vale/parsing/ParsedLoader.scala index f6a618252..7c3fff373 100644 --- a/Frontend/ParsingPass/src/dev/vale/parsing/ParsedLoader.scala +++ b/Frontend/ParsingPass/src/dev/vale/parsing/ParsedLoader.scala @@ -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) } } diff --git a/Frontend/ParsingPass/src/dev/vale/parsing/PatternParser.scala b/Frontend/ParsingPass/src/dev/vale/parsing/PatternParser.scala index de058f109..832c28253 100644 --- a/Frontend/ParsingPass/src/dev/vale/parsing/PatternParser.scala +++ b/Frontend/ParsingPass/src/dev/vale/parsing/PatternParser.scala @@ -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)) } diff --git a/Frontend/ParsingPass/src/dev/vale/parsing/templex/TemplexParser.scala b/Frontend/ParsingPass/src/dev/vale/parsing/templex/TemplexParser.scala index f53645a61..087906529 100644 --- a/Frontend/ParsingPass/src/dev/vale/parsing/templex/TemplexParser.scala +++ b/Frontend/ParsingPass/src/dev/vale/parsing/templex/TemplexParser.scala @@ -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) @@ -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()))) diff --git a/Frontend/PostParsingPass/src/dev/vale/postparsing/IdentifiabilitySolver.scala b/Frontend/PostParsingPass/src/dev/vale/postparsing/IdentifiabilitySolver.scala index 3283e50e4..a4d8ccded 100644 --- a/Frontend/PostParsingPass/src/dev/vale/postparsing/IdentifiabilitySolver.scala +++ b/Frontend/PostParsingPass/src/dev/vale/postparsing/IdentifiabilitySolver.scala @@ -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._ @@ -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) diff --git a/Frontend/PostParsingPass/src/dev/vale/postparsing/RuneTypeSolver.scala b/Frontend/PostParsingPass/src/dev/vale/postparsing/RuneTypeSolver.scala index d8ef56b9f..19dd145ba 100644 --- a/Frontend/PostParsingPass/src/dev/vale/postparsing/RuneTypeSolver.scala +++ b/Frontend/PostParsingPass/src/dev/vale/postparsing/RuneTypeSolver.scala @@ -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._ @@ -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) diff --git a/Frontend/PostParsingPass/src/dev/vale/postparsing/rules/TemplexScout.scala b/Frontend/PostParsingPass/src/dev/vale/postparsing/rules/TemplexScout.scala index 49d455c42..fc8ecbd80 100644 --- a/Frontend/PostParsingPass/src/dev/vale/postparsing/rules/TemplexScout.scala +++ b/Frontend/PostParsingPass/src/dev/vale/postparsing/rules/TemplexScout.scala @@ -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) => { diff --git a/Frontend/PostParsingPass/src/dev/vale/postparsing/rules/rules.scala b/Frontend/PostParsingPass/src/dev/vale/postparsing/rules/rules.scala index 807577861..9c1e4ee1e 100644 --- a/Frontend/PostParsingPass/src/dev/vale/postparsing/rules/rules.scala +++ b/Frontend/PostParsingPass/src/dev/vale/postparsing/rules/rules.scala @@ -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, diff --git a/Frontend/Tests/test/main/resources/array/make/make.vale b/Frontend/Tests/test/main/resources/array/make/make.vale index df8fe94ff..243b14b88 100644 --- a/Frontend/Tests/test/main/resources/array/make/make.vale +++ b/Frontend/Tests/test/main/resources/array/make/make.vale @@ -3,7 +3,7 @@ func MakeArray(n int, generator G) []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(n); i = 0; @@ -18,7 +18,7 @@ func MakeVaryArray(n int, generator G) []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(n); i = 0; @@ -33,7 +33,7 @@ func MakeImmArray(n int, generator G) []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(n, generator); } diff --git a/Frontend/TypingPass/src/dev/vale/typing/infer/CompilerSolver.scala b/Frontend/TypingPass/src/dev/vale/typing/infer/CompilerSolver.scala index 86ba57b28..3e2e87350 100644 --- a/Frontend/TypingPass/src/dev/vale/typing/infer/CompilerSolver.scala +++ b/Frontend/TypingPass/src/dev/vale/typing/infer/CompilerSolver.scala @@ -2,7 +2,7 @@ package dev.vale.typing.infer import dev.vale.options.GlobalOptions import dev.vale.parsing.ast.ShareP -import dev.vale.postparsing.rules.{AugmentSR, CallSR, CoerceToCoordSR, CoordComponentsSR, CoordIsaSR, CoordSendSR, EqualsSR, Equivalencies, ILiteralSL, IRulexSR, IntLiteralSL, IsConcreteSR, IsInterfaceSR, IsStructSR, KindComponentsSR, KindIsaSR, LiteralSR, LookupSR, MutabilityLiteralSL, OneOfSR, OwnershipLiteralSL, PackSR, PrototypeComponentsSR, PrototypeSR, RefListCompoundMutabilitySR, RuneParentEnvLookupSR, RuntimeSizedArraySR, StaticSizedArraySR, StringLiteralSL, VariabilityLiteralSL} +import dev.vale.postparsing.rules.{AugmentSR, CallSR, CoerceToCoordSR, CoordComponentsSR, CoordIsaSR, CoordSendSR, EqualsSR, Equivalencies, ILiteralSL, IRulexSR, IntLiteralSL, IsConcreteSR, IsInterfaceSR, IsStructSR, KindComponentsSR, KindIsaSR, LiteralSR, LookupSR, MutabilityLiteralSL, OneOfSR, OwnershipLiteralSL, PackSR, PrototypeComponentsSR, RefListCompoundMutabilitySR, RuneParentEnvLookupSR, RuntimeSizedArraySR, StaticSizedArraySR, StringLiteralSL, VariabilityLiteralSL} import dev.vale.{Err, Ok, RangeS, Result, vassert, vassertSome, vimpl, vwat} import dev.vale.postparsing.{CoordTemplataType, IImpreciseNameS, IRuneS, ITemplataType} import dev.vale.solver.{CompleteSolve, FailedSolve, ISolveRule, ISolverError, ISolverOutcome, IStepState, IncompleteSolve, RuleError, Solver} @@ -128,7 +128,7 @@ class CompilerSolver[Env, State]( 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) diff --git a/Frontend/TypingPass/test/dev/vale/typing/CompilerOwnershipTests.scala b/Frontend/TypingPass/test/dev/vale/typing/CompilerOwnershipTests.scala index 2d4562f17..b60e95565 100644 --- a/Frontend/TypingPass/test/dev/vale/typing/CompilerOwnershipTests.scala +++ b/Frontend/TypingPass/test/dev/vale/typing/CompilerOwnershipTests.scala @@ -129,10 +129,10 @@ class CompilerOwnershipTests extends FunSuite with Matchers { |impl Opt for Some; | |abstract func drop(virtual opt Opt) - |where Prot["drop", Refs(T), void]; + |where func drop(T)void; | |func drop(opt Some) - |where Prot["drop", Refs(T), void] + |where func drop(T)void |{ | [x] = opt; |} @@ -173,10 +173,10 @@ class CompilerOwnershipTests extends FunSuite with Matchers { |impl Opt for Some; | |abstract func drop(virtual opt Opt) - |where Prot["drop", Refs(T), void]; + |where func drop(T)void; | |func drop(opt Some) - |where Prot["drop", Refs(T), void] + |where func drop(T)void |{ | [x] = opt; |} diff --git a/Frontend/TypingPass/test/dev/vale/typing/CompilerSolverTests.scala b/Frontend/TypingPass/test/dev/vale/typing/CompilerSolverTests.scala index 30e31dc27..4f1cc74ee 100644 --- a/Frontend/TypingPass/test/dev/vale/typing/CompilerSolverTests.scala +++ b/Frontend/TypingPass/test/dev/vale/typing/CompilerSolverTests.scala @@ -174,7 +174,7 @@ class CompilerSolverTests extends FunSuite with Matchers { |import v.builtins.tup.*; |func moo(i int, b bool) str { return "hello"; } |exported func main() str - |where mooFunc Prot = Prot["moo", Refs(int, bool), _] + |where mooFunc Prot = func moo(int, bool)_ |{ | return (mooFunc)(5, true); |} @@ -186,6 +186,24 @@ class CompilerSolverTests extends FunSuite with Matchers { }) } + test("Prototype rule sugar") { + val compile = CompilerTestCompilation.test( + """ + |import v.builtins.tup.*; + |func moo(i int, b bool) str { return "hello"; } + |exported func main() str + |where func moo(int, bool)_ + |{ + | return moo(5, true); + |} + |""".stripMargin + ) + val coutputs = compile.expectCompilerOutputs() + Collector.only(coutputs.lookupFunction("main"), { + case FunctionCallTE(PrototypeT(simpleName("moo"), _), _) => + }) + } + test("Send struct to struct") { val compile = CompilerTestCompilation.test( """ diff --git a/Frontend/TypingPass/test/dev/vale/typing/CompilerTests.scala b/Frontend/TypingPass/test/dev/vale/typing/CompilerTests.scala index df8e3bd03..b60d10e0b 100644 --- a/Frontend/TypingPass/test/dev/vale/typing/CompilerTests.scala +++ b/Frontend/TypingPass/test/dev/vale/typing/CompilerTests.scala @@ -1122,8 +1122,8 @@ class CompilerTests extends FunSuite with Matchers { CompilerTestCompilation.test( """ |func moo(a str) { } - |func foo(f T) void where Prot["moo", Refs(str), void] { } - |func foo(f T) void where Prot["moo", Refs(bool), void] { } + |func foo(f T) void where func moo(str)void { } + |func foo(f T) void where func moo(bool)void { } |func main() { foo("hello"); } |""".stripMargin).expectCompilerOutputs() } diff --git a/README.md b/README.md index 035b09139..c487dad2a 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ Vale is a programming language whose goal is to show the world that **speed and safety can be easy!** Vale is: - * *Fast:* Vale is an AOT compiled language that uses an entirely new approach to memory management: [generational references](https://verdagon.dev/blog/generational-references), which have zero aliasing costs and no garbage collection pauses. - * *Fearless:* It is the [safest native language](/fearless): memory safety, data-race safety, region isolation, extern boundaries, and dependency extern whitelisting. - * *Flexible:* Its new take on [regions](/guide/regions) enables alternate memory management and allocation strategies, with the [region borrow checker](https://verdagon.dev/blog/zero-cost-refs-regions) enabling seamless, fast, and _easy_ interop between them. + * *Fast:* Vale is an AOT compiled language that uses the new [generational references](https://verdagon.dev/blog/generational-references) technique, enabling memory-safe control over data layout. + * *Fearless:* It is the [safest native language](/fearless), using region isolation and "Fearless FFI" to keep extern code's bugs from affecting Vale objects. + * *Flexible:* Its new take on [regions](/guide/regions) enables alternate memory management and allocation strategies, with the planned [region borrow checker](https://verdagon.dev/blog/zero-cost-refs-regions) enabling easy interop between them, and eliminating the vast majority of generational references' overhead. Vale is part of the [Vale Language Project](https://vale.dev/project), which explores, discovers, and publishes new programming language mechanisms that enable speed, safety, and ease of use. diff --git a/scripts/build-compiler.md b/build-compiler.md similarity index 79% rename from scripts/build-compiler.md rename to build-compiler.md index 6ad91cf26..3c35c700d 100644 --- a/scripts/build-compiler.md +++ b/build-compiler.md @@ -10,7 +10,7 @@ sudo apt install -y git git clone --single-branch --branch master https://github.com/ValeLang/Vale Vale/install-compiler-prereqs-linux.sh ~/LLVMForVale ~/BootstrappingValeCompiler cd Vale -./build-compiler-linux.sh ~/LLVMForVale/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz ~/BootstrappingValeCompiler +./scripts/ubuntu/build-compiler.sh ~/LLVMForVale/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04 ~/BootstrappingValeCompiler --test=all ./scripts/VERSION ``` @@ -22,7 +22,7 @@ git clone --single-branch --branch master https://github.com/ValeLang/Vale Vale/install-compiler-prereqs-mac.sh ~/BootstrappingValeCompiler source ~/.zshrc cd Vale -./build-compiler-mac.sh ~/BootstrappingValeCompiler +./scripts/mac/build-compiler.sh ~/BootstrappingValeCompiler --test=all ./scripts/VERSION ``` @@ -48,7 +48,7 @@ If you still want to compile the compiler on Windows, keep reading. ### Build LLVM -If you want to skip this, you can download and extract [this file](https://firebasestorage.googleapis.com/v0/b/valesite.appspot.com/o/llvm-install-minimum.zip?alt=media&token=1022ffea-c43b-4fea-a5e9-696c6f0d0175) to `C:\llvm`. **Disclaimer**: Download at your own risk, this is a stripped down and zipped up version of what we got from the below steps. +If you want to skip this, you can download and extract [this file](https://github.com/Verdagon/LLVM13WinMinimal/releases/download/v1.1/llvm-project-llvmorg-13.0.1.zip) to `C:\llvm`. **Disclaimer**: Download at your own risk, this is a stripped down and zipped up version of what we got from the below steps. Ensure your machine (or VM) has sufficient resources: 5 cores, 10gb ram, 200gb disk. You'll be building all of LLVM, which is quite resource intensive. @@ -79,5 +79,5 @@ Once youve done the above steps and installed LLVM, run the below commands: ```sh git clone https://github.com/ValeLang/Vale --single-branch --branch master cd Vale -.\\build-compiler-windows.bat C:\\llvm C:\\OldValeCompiler +.\scripts\windows\build-compiler.bat C:\llvm\llvm-project-llvmorg-13.0.1 C:\OldValeCompiler --test=all ./scripts/VERSION ``` diff --git a/scripts/VERSION b/scripts/VERSION index 90aa6f8c7..1683a2661 100644 --- a/scripts/VERSION +++ b/scripts/VERSION @@ -1 +1 @@ -0.2.0.2 \ No newline at end of file +0.2.0.8 \ No newline at end of file diff --git a/scripts/mac/build-compiler.sh b/scripts/mac/build-compiler.sh index f2a3cf00f..20896dfbd 100755 --- a/scripts/mac/build-compiler.sh +++ b/scripts/mac/build-compiler.sh @@ -27,10 +27,10 @@ fi shift; -VALEC_VERSION="$1" +VALEC_VERSION=`cat "$1"` if [ "$VALEC_VERSION" == "" ] then - echo "Please specify the new version." + echo "Please specify a file containing the new version." exit 1 fi shift; diff --git a/scripts/ubuntu/build-compiler.sh b/scripts/ubuntu/build-compiler.sh index 84618a5b6..fb9d711be 100755 --- a/scripts/ubuntu/build-compiler.sh +++ b/scripts/ubuntu/build-compiler.sh @@ -41,7 +41,7 @@ fi shift; -VALEC_VERSION="$1" +VALEC_VERSION=`cat "$1"` if [ "$VALEC_VERSION" == "" ] then echo "Please specify the new version." diff --git a/scripts/windows/build-compiler.bat b/scripts/windows/build-compiler.bat index 99578f404..487b5a8c2 100644 --- a/scripts/windows/build-compiler.bat +++ b/scripts/windows/build-compiler.bat @@ -1,3 +1,20 @@ +SETLOCAL ENABLEDELAYEDEXPANSION + +if "%5" == "" ( echo "Invalid version file" && exit /b 1 ) +if exist "%5" ( + set VALEC_VERSION= + for /f %%a in (%5) do ( + set VALEC_VERSION=!VALEC_VERSION!%%a + ) + if "!VALEC_VERSION!" == "" ( + echo "Invalid version" + exit /b 1 + ) + echo "Version: !VALEC_VERSION!" +) else ( + echo "Version file doesn't exist!" + exit /b 1 +) cd Backend @@ -28,8 +45,6 @@ cd ..\scripts - - if exist "..\release-windows" rmdir /S /Q "..\release-windows" mkdir "..\release-windows" mkdir "..\release-windows\samples" diff --git a/stdlib/src/collections/hashmap/HashMap.vale b/stdlib/src/collections/hashmap/HashMap.vale index e7efdb4d0..de9d44a5e 100644 --- a/stdlib/src/collections/hashmap/HashMap.vale +++ b/stdlib/src/collections/hashmap/HashMap.vale @@ -8,7 +8,7 @@ struct HashMapNode { } func drop(self HashMapNode) void -where Prot["drop", Refs(V), void] +where func drop(V)void { [k, v] = self; } @@ -39,7 +39,7 @@ func HashMap(hasher H, equator E, capacity int) HashMap } func drop(self HashMap) void -where Prot["drop", Refs(V), void] +where func drop(V)void { [hasher, equator, table, size] = self; } diff --git a/stdlib/src/collections/hashmap/hash_map_iter.vale b/stdlib/src/collections/hashmap/hash_map_iter.vale index 125d3a556..bcc4fbbdf 100644 --- a/stdlib/src/collections/hashmap/hash_map_iter.vale +++ b/stdlib/src/collections/hashmap/hash_map_iter.vale @@ -23,7 +23,7 @@ func next(iter &HashMapIter) Opt<(K, &V)> { func each(self &HashMap, func &F) -where Prot["__call", Refs(&F, &K, &V), _] { +where func(&F, &K, &V)_] { list = List(); index = 0; while index < self.table.len() { diff --git a/stdlib/src/collections/list/List.vale b/stdlib/src/collections/list/List.vale index 437316ba2..d6873dec0 100644 --- a/stdlib/src/collections/list/List.vale +++ b/stdlib/src/collections/list/List.vale @@ -199,7 +199,7 @@ func toVaryArray(list List) []E { func each(list &List, func F) void where F = Ref[_, _], - Prot["__call", Refs(&F, &E), void] { + func(&F, &E)void] { i = 0; l = len(&list); while i < l { @@ -231,7 +231,7 @@ func indexOf(list &List, element E) Opt { } func indexWhere(list &List, func F) Opt -where Prot["__call", Refs(&F, &E), _] { +where func(&F, &E)_] { i = 0; l = len(&list); while i < l { @@ -313,7 +313,7 @@ func join(list &List, joiner str) str { } func map(list &List, func &F) List -where T Ref, Prot["__call", Refs(&F, E), T] { +where T Ref, func(&F, E)T] { result = List(); list.each({ result.add((func)(_)); }); return result; @@ -340,7 +340,7 @@ where T Ref, Prot["__call", Refs(&F, E), T] { func exists(list &List, func F) bool -where T Ref, Prot["__call", Refs(&F, E), T] { +where T Ref, func(&F, E)T] { i = 0; while i < list.len() { if (&func)(list.get(i)) { diff --git a/stdlib/src/command/command.vale b/stdlib/src/command/command.vale index 60988a236..7abf9d50a 100644 --- a/stdlib/src/command/command.vale +++ b/stdlib/src/command/command.vale @@ -165,7 +165,7 @@ struct ExecResult { func expect_or(result &ExecResult, func F) str -where Prot["__call", Refs(&F, &ExecResult), void] +where func(&F, &ExecResult)void] { if result.return_code != 0 { func(result); diff --git a/stdlib/src/command2/command2.vale b/stdlib/src/command2/command2.vale index a8a108527..8e82c8dcd 100644 --- a/stdlib/src/command2/command2.vale +++ b/stdlib/src/command2/command2.vale @@ -190,7 +190,7 @@ struct ExecResult { func expect_or(result &ExecResult, func F) str -where Prot["__call", Refs(&F, &ExecResult), void] +where func(&F, &ExecResult)void] { if result.return_code != 0 { func(result); diff --git a/stdlib/src/optutils/optutils.vale b/stdlib/src/optutils/optutils.vale index a9e837c5b..1d79ef810 100644 --- a/stdlib/src/optutils/optutils.vale +++ b/stdlib/src/optutils/optutils.vale @@ -14,7 +14,7 @@ func get(opt &None, msg str) &T { panic(msg); } func get(opt &Some, msg str) &T { return &opt.value; } func ==(a &Opt, b &Opt) bool -where Prot["==", Refs(&T, &T), bool] { +where func ==(&T, &T)bool { if a.isEmpty() and b.isEmpty() { return true; } @@ -25,7 +25,7 @@ where Prot["==", Refs(&T, &T), bool] { } func clone(self &Opt) Opt -where Prot["clone", Refs(&T), T] { +where func clone(&T)T { if self.isEmpty() { return None(); } @@ -34,7 +34,7 @@ where Prot["clone", Refs(&T), T] { func map(self &Opt, func &F) Opt -where Prot["__call", Refs(&F, &T), R Ref] { +where func(&F, &T)R Ref] { if self.isEmpty() { None() } else { @@ -43,7 +43,7 @@ where Prot["__call", Refs(&F, &T), R Ref] { } func or(self Opt, func F) T -where Prot["__call", Refs(&F), _] { +where func(&F)_] { if self.isEmpty() { [ ] = self.as>().expect("zork f"); return func(); @@ -53,7 +53,7 @@ where Prot["__call", Refs(&F), _] { } func or(self &Opt, func F) &T -where Prot["__call", Refs(&F), _] { +where func(&F)_] { if self.isEmpty() { [ ] = self.as>().expect("zork g"); return func(); diff --git a/stdlib/src/resultutils/resultutils.vale b/stdlib/src/resultutils/resultutils.vale index 30a097148..0cacfaebb 100644 --- a/stdlib/src/resultutils/resultutils.vale +++ b/stdlib/src/resultutils/resultutils.vale @@ -15,7 +15,7 @@ func expect(ok &Ok, msg str) &OkType { return func get_or(result &Result, func F) &OkType -where Prot["__call", Refs(&F, ErrType), _] +where func(&F, ErrType)_] { if result.is_ok() { (result).expect() @@ -27,14 +27,14 @@ where Prot["__call", Refs(&F, ErrType), _] func expect_or(result &Result, func F) OkType -where Prot["__call", Refs(&F, &ErrType), _] +where func(&F, &ErrType)_] { return if result.is_ok() { result.expect() } else { func(result.expect_err()) }; } func expect_or(result Result, func F) OkType -where Prot["__call", Refs(&F, ErrType), _] +where func(&F, ErrType)_] { return if result.is_ok() { (result).expect() } else { func((result).expect_err()) }; }