├── .dockerignore ├── .gitattributes ├── .github ├── FUNDING.yml ├── contributors └── workflows │ └── ci.yml ├── .gitignore ├── Backend ├── .gitignore ├── CMakeLists.txt ├── __init__.py ├── builtins │ ├── ValeBuiltins.h │ ├── assert.c │ ├── census.c │ ├── mainargs.c │ ├── math.c │ ├── stdio.c │ ├── strings.c │ ├── vchashmap.c │ └── weaks.c ├── clion_env.sh ├── setupclion.txt ├── src │ ├── addresshasher.h │ ├── determinism │ │ ├── determinism.cpp │ │ └── determinism.h │ ├── error.h │ ├── externs.cpp │ ├── externs.h │ ├── fileio.cpp │ ├── fileio.h │ ├── function │ │ ├── boundary.cpp │ │ ├── boundary.h │ │ ├── expression.cpp │ │ ├── expression.h │ │ ├── expressions │ │ │ ├── block.cpp │ │ │ ├── call.cpp │ │ │ ├── constantstr.cpp │ │ │ ├── construct.cpp │ │ │ ├── constructunknownsizearray.cpp │ │ │ ├── destructure.cpp │ │ │ ├── discard.cpp │ │ │ ├── expressions.h │ │ │ ├── externs.cpp │ │ │ ├── if.cpp │ │ │ ├── interfacecall.cpp │ │ │ ├── localload.cpp │ │ │ ├── mutabilify.cpp │ │ │ ├── newarrayfromvalues.cpp │ │ │ ├── newimmruntimesizearray.cpp │ │ │ ├── newmutruntimesizearray.cpp │ │ │ ├── precheckborrow.cpp │ │ │ ├── shared │ │ │ │ ├── afl.h │ │ │ │ ├── elements.cpp │ │ │ │ ├── elements.h │ │ │ │ ├── members.cpp │ │ │ │ ├── members.h │ │ │ │ ├── ref.cpp │ │ │ │ ├── ref.h │ │ │ │ ├── shared.cpp │ │ │ │ ├── shared.h │ │ │ │ ├── string.cpp │ │ │ │ └── string.h │ │ │ ├── staticarrayfromcallable.cpp │ │ │ └── while.cpp │ │ ├── function.cpp │ │ └── function.h │ ├── globalstate.cpp │ ├── globalstate.h │ ├── json.hpp │ ├── mainFunction.cpp │ ├── metal │ │ ├── ast.cpp │ │ ├── ast.h │ │ ├── instructions.h │ │ ├── json.h │ │ ├── metalcache.h │ │ ├── name.h │ │ ├── readjson.cpp │ │ ├── readjson.h │ │ ├── types.cpp │ │ └── types.h │ ├── options.cpp │ ├── options.h │ ├── region │ │ ├── common │ │ │ ├── common.cpp │ │ │ ├── common.h │ │ │ ├── controlblock.cpp │ │ │ ├── controlblock.h │ │ │ ├── defaultlayout │ │ │ │ ├── structs.cpp │ │ │ │ ├── structs.h │ │ │ │ ├── structsrouter.cpp │ │ │ │ └── structsrouter.h │ │ │ ├── fatweaks │ │ │ │ ├── fatweaks.cpp │ │ │ │ └── fatweaks.h │ │ │ ├── heap.cpp │ │ │ ├── heap.h │ │ │ ├── hgm │ │ │ │ ├── hgm.cpp │ │ │ │ └── hgm.h │ │ │ ├── lgtweaks │ │ │ │ ├── lgtweaks.cpp │ │ │ │ └── lgtweaks.h │ │ │ ├── migration.cpp │ │ │ ├── migration.h │ │ │ ├── primitives.h │ │ │ ├── referendptrmaker.h │ │ │ └── wrcweaks │ │ │ │ ├── wrcweaks.cpp │ │ │ │ └── wrcweaks.h │ │ ├── iregion.cpp │ │ ├── iregion.h │ │ ├── linear │ │ │ ├── linear.cpp │ │ │ ├── linear.h │ │ │ ├── linearstructs.cpp │ │ │ └── linearstructs.h │ │ ├── naiverc │ │ │ ├── naiverc.cpp │ │ │ └── naiverc.h │ │ ├── rcimm │ │ │ ├── rcimm.cpp │ │ │ └── rcimm.h │ │ ├── regions.cpp │ │ ├── resilientv3 │ │ │ ├── resilientv3.cpp │ │ │ └── resilientv3.h │ │ ├── safe-fastest │ │ │ ├── safefastest.cpp │ │ │ └── safefastest.h │ │ ├── safe │ │ │ ├── safe.cpp │ │ │ └── safe.h │ │ ├── unsafe │ │ │ ├── unsafe.cpp │ │ │ └── unsafe.h │ │ ├── urefstructlt.cpp │ │ └── urefstructlt.h │ ├── simplehash │ │ ├── cppsimplehashmap.cpp │ │ ├── cppsimplehashmap.h │ │ ├── llvmsimplehashmap.cpp │ │ └── llvmsimplehashmap.h │ ├── translatetype.cpp │ ├── translatetype.h │ ├── utils │ │ ├── branch.cpp │ │ ├── branch.h │ │ ├── call.cpp │ │ ├── call.h │ │ ├── counters.cpp │ │ ├── counters.h │ │ ├── definefunction.cpp │ │ ├── definefunction.h │ │ ├── flags.cpp │ │ ├── flags.h │ │ ├── llvm.cpp │ │ ├── llvm.h │ │ ├── randomgeneration.cpp │ │ ├── randomgeneration.h │ │ ├── structlt.cpp │ │ └── structlt.h │ ├── vale.cpp │ ├── valeopts.cpp │ └── valeopts.h ├── test.sh ├── test │ ├── __init__.py │ ├── prettify_vir.py │ ├── testbuiltins.c │ └── tethercrash.vale └── vstl │ ├── hashmap.vale │ ├── hashset.vale │ └── list.vale ├── Coordinator ├── .gitignore ├── build.bat ├── build.sh └── src │ ├── build.vale │ ├── clang.vale │ ├── main.vale │ ├── midas.vale │ └── valestrom.vale ├── Frontend ├── .gitignore ├── .idea │ ├── .gitignore │ ├── .name │ ├── codeStyles │ │ ├── Project.xml │ │ └── codeStyleConfig.xml │ ├── google-java-format.xml │ ├── inspectionProfiles │ │ └── Project_Default.xml │ ├── libraries │ │ ├── com_google_cloud_functions_functions_framework_api_1_0_1.xml │ │ ├── commons_lang3_3_13_0.xml │ │ ├── lift_json_2_12_3_5_0.xml │ │ ├── org_scalatest_scalatest_2_12_3_0_8.xml │ │ └── scala_reflect_2_12_8.xml │ ├── misc.xml │ ├── modules.xml │ ├── modules │ │ ├── Frontend-build.iml │ │ └── Frontend.iml │ ├── sbt.xml │ ├── scala_compiler.xml │ ├── scala_settings.xml │ ├── uiDesigner.xml │ └── vcs.xml ├── Builtins │ ├── Builtins.iml │ └── src │ │ └── dev │ │ └── vale │ │ ├── Builtins.scala │ │ └── resources │ │ ├── arith.vale │ │ ├── arrays.vale │ │ ├── as.vale │ │ ├── clone.vale │ │ ├── drop.vale │ │ ├── functor1.vale │ │ ├── logic.vale │ │ ├── mainargs.vale │ │ ├── migrate.vale │ │ ├── opt.vale │ │ ├── panic.vale │ │ ├── panicutils.vale │ │ ├── print.vale │ │ ├── result.vale │ │ ├── runtime_sized_array_capacity.vale │ │ ├── runtime_sized_array_len.vale │ │ ├── runtime_sized_array_mut_drop.vale │ │ ├── runtime_sized_array_mut_new.vale │ │ ├── runtime_sized_array_pop.vale │ │ ├── runtime_sized_array_push.vale │ │ ├── sameinstance.vale │ │ ├── static_sized_array_mut_drop.vale │ │ ├── str.vale │ │ ├── streq.vale │ │ ├── tup0.vale │ │ ├── tup1.vale │ │ ├── tup2.vale │ │ ├── tupN.vale │ │ └── weak.vale ├── CompileOptions │ ├── CompileOptions.iml │ └── src │ │ └── dev │ │ └── vale │ │ └── options │ │ └── GlobalOptions.scala ├── CompileServer │ ├── CompileServer.iml │ └── src │ │ └── dev │ │ └── vale │ │ └── compileserver │ │ ├── BuildAction.scala │ │ └── RunAction.scala ├── FinalAST │ ├── FinalAST.iml │ └── src │ │ └── dev │ │ └── vale │ │ └── finalast │ │ ├── MetalPrinter.scala │ │ ├── ast.scala │ │ ├── instructions.scala │ │ └── types.scala ├── HigherTypingPass │ ├── HigherTypingPass.iml │ ├── src │ │ └── dev │ │ │ └── vale │ │ │ └── highertyping │ │ │ ├── AstronomerErrorReporter.scala │ │ │ ├── HigherTypingErrorHumanizer.scala │ │ │ ├── HigherTypingPass.scala │ │ │ ├── Textifier.scala │ │ │ ├── ast.scala │ │ │ └── patterns.scala │ └── test │ │ └── dev │ │ └── vale │ │ └── highertyping │ │ ├── ErrorTests.scala │ │ ├── HigherTypingPassTests.scala │ │ └── HigherTypingTestCompilation.scala ├── Highlighter │ ├── Highlighter.iml │ ├── src │ │ └── dev │ │ │ └── vale │ │ │ └── highlighter │ │ │ ├── Highlighter.scala │ │ │ └── Spanner.scala │ └── test │ │ └── dev │ │ └── vale │ │ └── highlighter │ │ ├── HighlighterTests.scala │ │ └── SpannerTests.scala ├── InstantiatingPass │ ├── InstantiatingPass.iml │ ├── src │ │ └── dev │ │ │ └── vale │ │ │ └── instantiating │ │ │ ├── InstantiatedCompilation.scala │ │ │ ├── InstantiatedHumanizer.scala │ │ │ ├── Instantiator.scala │ │ │ ├── RegionCollapserConsistent.scala │ │ │ ├── RegionCollapserIndividual.scala │ │ │ ├── RegionCounter.scala │ │ │ └── ast │ │ │ ├── HinputsI.scala │ │ │ ├── TemplataUtils.scala │ │ │ ├── ast.scala │ │ │ ├── citizens.scala │ │ │ ├── expressions.scala │ │ │ ├── names.scala │ │ │ ├── templata.scala │ │ │ └── types.scala │ └── test │ │ └── dev │ │ └── vale │ │ └── instantiating │ │ └── InstantiatedTests.scala ├── IntegrationTests │ ├── IntegrationTests.iml │ └── test │ │ └── dev │ │ └── vale │ │ ├── AfterRegionsIntegrationTests.scala │ │ ├── ArithmeticTestsA.scala │ │ ├── ArrayListTest.scala │ │ ├── ArrayTests.scala │ │ ├── BlockTests.scala │ │ ├── ClosureTests.scala │ │ ├── ConjunctionTests.scala │ │ ├── FloatTests.scala │ │ ├── HammerTests.scala │ │ ├── HashMapTest.scala │ │ ├── IfTests.scala │ │ ├── ImportTests.scala │ │ ├── InferTemplateTests.scala │ │ ├── IntegrationTestsA.scala │ │ ├── IntegrationTestsB.scala │ │ ├── IntegrationTestsC.scala │ │ ├── OptTests.scala │ │ ├── OwnershipTests.scala │ │ ├── PackTests.scala │ │ ├── PatternTests.scala │ │ ├── PrintTests.scala │ │ ├── PureFunctionTests.scala │ │ ├── ResultTests.scala │ │ ├── RunCompilation.scala │ │ ├── StringTests.scala │ │ ├── StructTests.scala │ │ ├── TupleTests.scala │ │ ├── VirtualTests.scala │ │ ├── WeakTests.scala │ │ ├── WhileTests.scala │ │ └── benchmark │ │ └── Benchmark.scala ├── LexingPass │ ├── LexingPass.iml │ └── src │ │ └── dev │ │ └── vale │ │ └── lexing │ │ ├── LexAndExplore.scala │ │ ├── Lexer.scala │ │ ├── LexingIterator.scala │ │ ├── ast.scala │ │ └── errors.scala ├── ParsingPass │ ├── ParsingPass.iml │ ├── src │ │ └── dev │ │ │ └── vale │ │ │ └── parsing │ │ │ ├── ExpressionParser.scala │ │ │ ├── Formatter.scala │ │ │ ├── ParseAndExplore.scala │ │ │ ├── ParseErrorHumanizer.scala │ │ │ ├── ParseUtils.scala │ │ │ ├── ParsedLoader.scala │ │ │ ├── Parser.scala │ │ │ ├── ParserVonifier.scala │ │ │ ├── PatternParser.scala │ │ │ ├── StringParserTests.scala │ │ │ ├── TestParseUtils.scala │ │ │ ├── ast │ │ │ ├── ast.scala │ │ │ ├── expressions.scala │ │ │ ├── pattern.scala │ │ │ ├── rules.scala │ │ │ └── templex.scala │ │ │ ├── expressions │ │ │ └── StringParser.scala │ │ │ └── templex │ │ │ └── TemplexParser.scala │ └── test │ │ └── dev │ │ └── vale │ │ └── parsing │ │ ├── AfterRegionsTests.scala │ │ ├── ExpressionTests.scala │ │ ├── IfTests.scala │ │ ├── ImplTests.scala │ │ ├── LoadTests.scala │ │ ├── ParseSamplesTests.scala │ │ ├── ParserTestCompilation.scala │ │ ├── StatementTests.scala │ │ ├── StructTests.scala │ │ ├── TopLevelTests.scala │ │ ├── WhileTests.scala │ │ ├── functions │ │ ├── AfterRegionsFunctionTests.scala │ │ └── FunctionTests.scala │ │ ├── patterns │ │ ├── CaptureAndDestructureTests.scala │ │ ├── CaptureAndTypeTests.scala │ │ ├── DestructureParserTests.scala │ │ ├── PatternParserTests.scala │ │ ├── TypeAndDestructureTests.scala │ │ └── TypeTests.scala │ │ └── rules │ │ ├── CoordRuleTests.scala │ │ ├── KindRuleTests.scala │ │ ├── RuleTests.scala │ │ └── RulesEnumsTests.scala ├── PassManager │ ├── PassManager.iml │ └── src │ │ └── dev │ │ └── vale │ │ └── passmanager │ │ ├── FullCompilation.scala │ │ └── PassManager.scala ├── PostParsingPass │ ├── PostParsingPass.iml │ ├── src │ │ └── dev │ │ │ └── vale │ │ │ └── postparsing │ │ │ ├── ExpressionScout.scala │ │ │ ├── FunctionScout.scala │ │ │ ├── ITemplataType.scala │ │ │ ├── IdentifiabilitySolver.scala │ │ │ ├── LoopPostParser.scala │ │ │ ├── PostParser.scala │ │ │ ├── PostParserErrorHumanizer.scala │ │ │ ├── RuneTypeSolver.scala │ │ │ ├── VariableUses.scala │ │ │ ├── ast.scala │ │ │ ├── expressions.scala │ │ │ ├── names.scala │ │ │ ├── patterns │ │ │ ├── PatternScout.scala │ │ │ └── patterns.scala │ │ │ └── rules │ │ │ ├── RuleScout.scala │ │ │ ├── TemplexScout.scala │ │ │ └── rules.scala │ └── test │ │ └── dev │ │ └── vale │ │ └── postparsing │ │ ├── AfterRegionsErrorTests.scala │ │ ├── PostParserErrorHumanizerTests.scala │ │ ├── PostParserTestCompilation.scala │ │ ├── PostParserTests.scala │ │ ├── PostParserVariableTests.scala │ │ ├── PostParsingParametersTests.scala │ │ └── PostParsingRuleTests.scala ├── SimplifyingPass │ ├── SimplifyingPass.iml │ ├── src │ │ └── dev │ │ │ └── vale │ │ │ └── simplifying │ │ │ ├── BlockHammer.scala │ │ │ ├── Conversions.scala │ │ │ ├── ExpressionHammer.scala │ │ │ ├── FunctionHammer.scala │ │ │ ├── Hammer.scala │ │ │ ├── HammerCompilation.scala │ │ │ ├── Hamuts.scala │ │ │ ├── LetHammer.scala │ │ │ ├── LoadHammer.scala │ │ │ ├── MutateHammer.scala │ │ │ ├── NameHammer.scala │ │ │ ├── StructHammer.scala │ │ │ ├── TypeHammer.scala │ │ │ └── VonHammer.scala │ └── test │ │ └── dev │ │ └── vale │ │ └── simplifying │ │ ├── HammerTest.scala │ │ └── TestCompilation.scala ├── Solver │ ├── Solver.iml │ ├── src │ │ └── dev │ │ │ └── vale │ │ │ └── solver │ │ │ ├── ISolverState.scala │ │ │ ├── OptimizedSolverState.scala │ │ │ ├── SimpleSolverState.scala │ │ │ ├── Solver.scala │ │ │ └── SolverErrorHumanizer.scala │ └── test │ │ └── dev │ │ └── vale │ │ └── solver │ │ ├── SolverTests.scala │ │ ├── TestRuleSolver.scala │ │ └── TestRules.scala ├── TestVM │ ├── TestVM.iml │ ├── src │ │ └── dev │ │ │ └── vale │ │ │ └── testvm │ │ │ ├── Call.scala │ │ │ ├── ExpressionVivem.scala │ │ │ ├── FunctionVivem.scala │ │ │ ├── Heap.scala │ │ │ ├── Values.scala │ │ │ ├── Vivem.scala │ │ │ └── VivemExterns.scala │ └── test │ │ └── dev │ │ └── vale │ │ └── testvm │ │ └── VivemTests.scala ├── Tests │ ├── Tests.iml │ ├── src │ │ └── dev │ │ │ └── vale │ │ │ └── Tests.scala │ └── test │ │ └── main │ │ └── resources │ │ ├── array │ │ ├── drop_into │ │ │ └── drop_into.vale │ │ ├── each │ │ │ └── each.vale │ │ ├── has │ │ │ └── has.vale │ │ ├── indices │ │ │ └── indices.vale │ │ ├── iter │ │ │ └── iter.vale │ │ └── make │ │ │ └── make.vale │ │ ├── castutils │ │ └── castutils.vale │ │ ├── hashmap │ │ └── hashmap.vale │ │ ├── ifunction │ │ └── ifunction1 │ │ │ └── ifunction1.vale │ │ ├── intrange │ │ └── intrange.vale │ │ ├── ioutils │ │ └── ioutils.vale │ │ ├── list │ │ └── list.vale │ │ ├── listprintutils │ │ └── listprintutils.vale │ │ ├── logic │ │ └── logic.vale │ │ ├── math │ │ └── math.vale │ │ ├── optutils │ │ └── optutils.vale │ │ ├── panicutils │ │ └── panicutils.vale │ │ ├── printutils │ │ └── printutils.vale │ │ ├── programs │ │ ├── add64ret.vale │ │ ├── addret.vale │ │ ├── arrays │ │ │ ├── inlssaimm.vale │ │ │ ├── rsaimm.vale │ │ │ ├── rsaimmfromcallable.vale │ │ │ ├── rsaimmlen.vale │ │ │ ├── rsamut.vale │ │ │ ├── rsamutcapacity.vale │ │ │ ├── rsamutdestroyintocallable.vale │ │ │ ├── rsamutfromcallable.vale │ │ │ ├── rsamutlen.vale │ │ │ ├── ssaimmfromcallable.vale │ │ │ ├── ssaimmfromvalues.vale │ │ │ ├── ssamutdestroyintocallable.vale │ │ │ ├── ssamutfromcallable.vale │ │ │ ├── ssamutfromvalues.vale │ │ │ └── swaprsamutdestroy.vale │ │ ├── borrowRef.vale │ │ ├── cellularautomata.vale │ │ ├── cellularautomata_canonical.vale │ │ ├── comparei64.vale │ │ ├── concatstrfloat.vale │ │ ├── constraintRef.vale │ │ ├── destructure_restackify.vale │ │ ├── downcast │ │ │ ├── downcastBorrowFailed.vale │ │ │ ├── downcastBorrowSuccessful.vale │ │ │ ├── downcastOwningFailed.vale │ │ │ ├── downcastOwningSuccessful.vale │ │ │ ├── downcastPointerFailed.vale │ │ │ └── downcastPointerSuccess.vale │ │ ├── externs │ │ │ ├── README.txt │ │ │ ├── export.vale │ │ │ ├── extern.vale │ │ │ ├── interfaceimmparamdeepexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── interfaceimmparamdeepextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── interfaceimmparamexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── interfaceimmparamextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── interfaceimmreturnexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── interfaceimmreturnextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── interfacemutparamexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── interfacemutreturnexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── replayprint │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── rsaimmparamdeepexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── rsaimmparamdeepextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── rsaimmparamexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── rsaimmparamextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── rsaimmreturnexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── rsaimmreturnextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── rsamutparamexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── rsamutreturnexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── simpleexternparam │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── simpleexternreturn │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── ssaimmparamdeepexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── ssaimmparamdeepextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── ssaimmparamexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── ssaimmparamextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── ssaimmreturnexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── ssaimmreturnextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── ssamutparamexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── ssamutreturnexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── strlenextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── strreturnexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── structimmparamdeepexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── structimmparamdeepextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── structimmparamexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── structimmparamextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── structimmreturnexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── structimmreturnextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── structmutparamdeepexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── structmutparamexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── structmutreturnexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── tupleparamextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── tupleretextern │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ ├── voidreturnexport │ │ │ │ ├── native │ │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ │ └── voidreturnextern │ │ │ │ ├── native │ │ │ │ └── test.c │ │ │ │ └── test.vale │ │ ├── floatarithmetic.vale │ │ ├── floateq.vale │ │ ├── functions │ │ │ ├── overloads.vale │ │ │ └── recursion.vale │ │ ├── genericvirtuals │ │ │ ├── callingAbstract.vale │ │ │ ├── foreachlinkedlist.vale │ │ │ ├── getOr.vale │ │ │ ├── mapFunc.vale │ │ │ ├── specializeinterface.vale │ │ │ ├── stampMultipleAncestors.vale │ │ │ ├── templatedinterface.vale │ │ │ ├── templatedlinkedlist.vale │ │ │ └── templatedoption.vale │ │ ├── if │ │ │ ├── if.vale │ │ │ ├── ifnevers.vale │ │ │ ├── nestedif.vale │ │ │ ├── neverif.vale │ │ │ └── upcastif.vale │ │ ├── invalidaccess.vale │ │ ├── lambdas │ │ │ ├── doubleclosure.vale │ │ │ ├── lambda.vale │ │ │ ├── lambdamut.vale │ │ │ └── mutate.vale │ │ ├── loop_restackify.vale │ │ ├── multiUnstackify.vale │ │ ├── mutlocal.vale │ │ ├── mutswaplocals.vale │ │ ├── nestedblocks.vale │ │ ├── panic.vale │ │ ├── panicnot.vale │ │ ├── printfloat.vale │ │ ├── pure │ │ │ ├── pure_block_produce_ssa.vale │ │ │ ├── pure_block_read_ssa.vale │ │ │ ├── pure_func_return_rsa.vale │ │ │ ├── pure_func_return_ssa.vale │ │ │ ├── pure_func_return_struct.vale │ │ │ └── pure_func_take_ssa.vale │ │ ├── readwriteufcs.vale │ │ ├── regions │ │ │ └── multi_region_extern.vale │ │ ├── restackify.vale │ │ ├── roguelike.vale │ │ ├── scratch.vale │ │ ├── strings │ │ │ ├── complex │ │ │ │ ├── main.vale │ │ │ │ └── strings.c │ │ │ ├── i64tostr.vale │ │ │ ├── inttostr.vale │ │ │ ├── smallstr.vale │ │ │ ├── stradd.vale │ │ │ ├── strlen.vale │ │ │ ├── strneq.vale │ │ │ └── strprint.vale │ │ ├── structs │ │ │ ├── bigstructimm.vale │ │ │ ├── constructor.vale │ │ │ ├── deadmutstruct.vale │ │ │ ├── getMember.vale │ │ │ ├── memberrefcount.vale │ │ │ ├── mutate.vale │ │ │ ├── structimm.vale │ │ │ ├── structmut.vale │ │ │ ├── structmutstore.vale │ │ │ ├── structmutstoreinner.vale │ │ │ └── structs.vale │ │ ├── truncate.vale │ │ ├── tuples │ │ │ └── immtupleaccess.vale │ │ ├── ufcs.vale │ │ ├── unreachablemoot.vale │ │ ├── unstackifyret.vale │ │ ├── virtuals │ │ │ ├── calling.vale │ │ │ ├── callingThroughBorrow.vale │ │ │ ├── interfaceimm.vale │ │ │ ├── interfacemut.vale │ │ │ ├── ordinarylinkedlist.vale │ │ │ ├── retUpcast.vale │ │ │ ├── round.vale │ │ │ └── upcasting.vale │ │ ├── weaks │ │ │ ├── callWeakSelfMethodAfterDrop.vale │ │ │ ├── callWeakSelfMethodWhileLive.vale │ │ │ ├── dropThenLockInterface.vale │ │ │ ├── dropThenLockStruct.vale │ │ │ ├── dropWhileLockedInterface.vale │ │ │ ├── dropWhileLockedStruct.vale │ │ │ ├── loadFromWeakable.vale │ │ │ ├── lockWhileLiveInterface.vale │ │ │ ├── lockWhileLiveStruct.vale │ │ │ ├── weakFromCRefInterface.vale │ │ │ ├── weakFromCRefStruct.vale │ │ │ ├── weakFromLocalCRefInterface.vale │ │ │ └── weakFromLocalCRefStruct.vale │ │ └── while │ │ │ ├── foreach.vale │ │ │ └── while.vale │ │ ├── regionhashmap │ │ └── hashmap.vale │ │ └── string │ │ └── string.vale ├── TypingPass │ ├── TypingPass.iml │ ├── src │ │ └── dev │ │ │ └── vale │ │ │ └── typing │ │ │ ├── ArrayCompiler.scala │ │ │ ├── Compilation.scala │ │ │ ├── Compiler.scala │ │ │ ├── CompilerErrorHumanizer.scala │ │ │ ├── CompilerErrorReporter.scala │ │ │ ├── CompilerOutputs.scala │ │ │ ├── ConvertHelper.scala │ │ │ ├── EdgeCompiler.scala │ │ │ ├── HinputsT.scala │ │ │ ├── InferCompiler.scala │ │ │ ├── OverloadResolver.scala │ │ │ ├── Reachability.scala │ │ │ ├── SequenceCompiler.scala │ │ │ ├── TemplataCompiler.scala │ │ │ ├── ast │ │ │ ├── ast.scala │ │ │ ├── citizens.scala │ │ │ └── expressions.scala │ │ │ ├── citizen │ │ │ ├── ImplCompiler.scala │ │ │ ├── StructCompiler.scala │ │ │ ├── StructCompilerCore.scala │ │ │ └── StructCompilerGenericArgsLayer.scala │ │ │ ├── env │ │ │ ├── Environment.scala │ │ │ ├── FunctionEnvironmentT.scala │ │ │ └── IEnvEntry.scala │ │ │ ├── expression │ │ │ ├── BlockCompiler.scala │ │ │ ├── CallCompiler.scala │ │ │ ├── ExpressionCompiler.scala │ │ │ ├── LocalHelper.scala │ │ │ └── PatternCompiler.scala │ │ │ ├── function │ │ │ ├── DestructorCompiler.scala │ │ │ ├── FunctionBodyCompiler.scala │ │ │ ├── FunctionCompiler.scala │ │ │ ├── FunctionCompilerClosureOrLightLayer.scala │ │ │ ├── FunctionCompilerCore.scala │ │ │ ├── FunctionCompilerMiddleLayer.scala │ │ │ ├── FunctionCompilerSolvingLayer.scala │ │ │ └── VirtualCompiler.scala │ │ │ ├── infer │ │ │ └── CompilerSolver.scala │ │ │ ├── macros │ │ │ ├── AbstractBodyMacro.scala │ │ │ ├── AnonymousInterfaceMacro.scala │ │ │ ├── AsSubtypeMacro.scala │ │ │ ├── FunctorHelper.scala │ │ │ ├── LockWeakMacro.scala │ │ │ ├── RSALenMacro.scala │ │ │ ├── SameInstanceMacro.scala │ │ │ ├── StructConstructorMacro.scala │ │ │ ├── citizen │ │ │ │ ├── InterfaceDropMacro.scala │ │ │ │ └── StructDropMacro.scala │ │ │ ├── macros.scala │ │ │ ├── rsa │ │ │ │ ├── RSADropIntoMacro.scala │ │ │ │ ├── RSAImmutableNewMacro.scala │ │ │ │ ├── RSALenMacro.scala │ │ │ │ ├── RSAMutableCapacityMacro.scala │ │ │ │ ├── RSAMutableNewMacro.scala │ │ │ │ ├── RSAMutablePopMacro.scala │ │ │ │ └── RSAMutablePushMacro.scala │ │ │ └── ssa │ │ │ │ ├── SSADropIntoMacro.scala │ │ │ │ └── SSALenMacro.scala │ │ │ ├── names │ │ │ ├── NameTranslator.scala │ │ │ └── names.scala │ │ │ ├── templata │ │ │ ├── Conversions.scala │ │ │ ├── TemplataUtils.scala │ │ │ └── templata.scala │ │ │ └── types │ │ │ └── types.scala │ └── test │ │ └── dev │ │ └── vale │ │ └── typing │ │ ├── AfterRegionsErrorTests.scala │ │ ├── AfterRegionsTests.scala │ │ ├── CompilerGenericsTests.scala │ │ ├── CompilerLambdaTests.scala │ │ ├── CompilerMutateTests.scala │ │ ├── CompilerOwnershipTests.scala │ │ ├── CompilerProjectTests.scala │ │ ├── CompilerSolverTests.scala │ │ ├── CompilerTestCompilation.scala │ │ ├── CompilerTests.scala │ │ ├── CompilerVirtualTests.scala │ │ ├── InProgressTests.scala │ │ └── TodoTests.scala ├── Utils │ ├── Utils.iml │ └── src │ │ └── dev │ │ └── vale │ │ ├── Accumulator.scala │ │ ├── CodeHierarchy.scala │ │ ├── Collector.scala │ │ ├── Interner.scala │ │ ├── Keywords.scala │ │ ├── Profiler.scala │ │ ├── Range.scala │ │ ├── Result.scala │ │ ├── SourceCodeUtils.scala │ │ ├── Timer.scala │ │ ├── Utils.scala │ │ ├── repeatStr.scala │ │ ├── vassert.scala │ │ └── vpass.scala ├── Vale.iml ├── Von │ ├── Von.iml │ ├── src │ │ └── dev │ │ │ └── vale │ │ │ └── von │ │ │ ├── VonAst.scala │ │ │ └── VonPrinter.scala │ └── test │ │ └── dev │ │ └── vale │ │ └── von │ │ └── VonTest.scala ├── build.sbt ├── lib │ ├── commons-lang3-3.13.0.jar │ ├── functions-framework-api-1.0.1.jar │ ├── lift-json_2.12-3.5.0.jar │ ├── paranamer-2.8.jar │ ├── scalactic_2.12-3.0.8.jar │ ├── scalap-2.12.6.jar │ └── scalatest_2.12-3.0.8.jar └── project │ ├── build.properties │ └── plugins.sbt ├── LICENSE ├── README.md ├── Tester ├── .gitignore ├── build.bat ├── build.sh ├── exampleinvocation.txt └── src │ └── main.vale ├── Utils ├── .gitignore ├── src │ ├── command2 │ │ ├── command.vale │ │ ├── native │ │ │ ├── subprocess.c │ │ │ └── subprocess.h │ │ └── test │ │ │ └── test.vale │ ├── listadditions.vale │ └── stdlibfixes.vale └── test.sh ├── architectural-direction.md ├── build-compiler.md ├── compiler-overview.md ├── docs ├── Allocators.md ├── Architecture.md ├── Catalyst.md ├── ContextWord.md ├── DropFree.md ├── Environments, Templatas, and Parent Entries.md ├── Environments.md ├── FasterCompileTimes.md ├── FearlessFFI.md ├── GenerationalReferences.md ├── Generics.md ├── HigherTypingPass.md ├── IRegion.md ├── InstantiatorRegions.md ├── LinearRegion.md ├── Metacall.md ├── ObjectMetadata.md ├── PerfectReplayability.md ├── RegionBookkeeping.md ├── WeakRef.md ├── concurrency │ ├── Blocking.md │ ├── ConcurrencyRegions.md │ ├── Interleaving.md │ ├── VirtualThreads.md │ ├── VirtualThreadsPrototype.md │ ├── prototype.c │ └── yielding.c ├── hgm │ ├── HGM Overhead Analysis-comments.html │ ├── HGM Overhead Analysis.xlsx │ ├── HGM Pointers and Borrows.md │ ├── HGMv1-10.md │ ├── HGMv11,12.md │ ├── HGMv13.md │ ├── HGMv14,15.md │ ├── HGMv16,17,18.md │ ├── HGMv19.md │ ├── HGMv20.md │ ├── HGMv21.md │ ├── HGMv22.md │ ├── HGMv23.md │ └── HGMv24.md ├── notes │ ├── ArchitectureNotes.md │ ├── ContextWordNotes.md │ ├── LinearRegionNotes.md │ ├── PerfectReplayabilityNotes.md │ ├── SeparatedFFINotes.md │ ├── StandardLibrary.md │ └── VirtualThreadsNotes.md ├── old │ ├── 0.2 Article Plan-comments.html │ ├── Agents.md │ ├── Async.md │ ├── Coercing Templatas, and Overload Sets-comments.html │ ├── Coercing Templatas, and Overload Sets.md │ ├── Comparisons _ Related Work.md │ ├── Compiler │ │ ├── Constructors and Destructors-comments.html │ │ ├── Constructors and Destructors.md │ │ ├── Expressions.md │ │ ├── Hammer.md │ │ ├── LSP.md │ │ ├── Macros.md │ │ ├── Midas.md │ │ ├── Namespaces.md │ │ ├── Optimization.md │ │ ├── Scout.md │ │ ├── Templar │ │ │ ├── Addresses.md │ │ │ ├── Environments, Templatas, and Parent Entries-commen.html │ │ │ ├── Environments, Templatas, and Parent Entries.md │ │ │ ├── FunctionTemplar.md │ │ │ ├── Infer Templar-comments.html │ │ │ ├── Infer Templar.md │ │ │ ├── Patterns.md │ │ │ └── Templar.md │ │ ├── Templates.md │ │ ├── Tests.md │ │ ├── Vale 2020.md │ │ ├── Vale Backend.md │ │ ├── Virtuals.md │ │ └── Vivem.md │ ├── Components Example.md │ ├── Components.md │ ├── Concepts.md │ ├── Custom Backend.md │ ├── Destructors.md │ ├── Doc Template.md │ ├── Enums-comments.html │ ├── Enums.md │ ├── Environments, Closures, Overload Sets.md │ ├── Expressions │ │ ├── Expressions-comments.html │ │ ├── Expressions.md │ │ ├── Implementations for if and match.md │ │ └── Loading, ownership, permissions.md │ ├── Externs and Regions.md │ ├── Externs.md │ ├── Forked Lightning Battle Plan-comments.html │ ├── Forked Lightning Battle Plan.md │ ├── Functions.md │ ├── Futures.md │ ├── Grand Unified Theory of Awesome.md │ ├── HC1-comments.html │ ├── HC1.md │ ├── HGM Overhead Analysis-comments.html │ ├── HGM Overhead Analysis.xlsx │ ├── HGM Pointers and Borrows.md │ ├── HGM V11 and V12.md │ ├── HGM V13.md │ ├── HGM V14 and V15.md │ ├── HGM V16, V17, V18-comments.html │ ├── HGM V16, V17, V18.md │ ├── HGM V19.md │ ├── HGM V20.md │ ├── HGM V21.md │ ├── HGM V22.md │ ├── Impls.md │ ├── Inlining.md │ ├── Interoperability │ │ ├── C# _ Unity.md │ │ └── C++.md │ ├── Let Statements, Functions, Templating, and Pattern.md │ ├── Links.md │ ├── Loading, Permission, Ownership.xlsx │ ├── Managing Memory (Draft).md │ ├── Master Plan.md │ ├── Metaprogramming and Conditional Compilation.md │ ├── Names(1).md │ ├── Names.md │ ├── Next Decade in Languages_ User Code on the GPU-com.html │ ├── Next Decade in Languages_ User Code on the GPU.md │ ├── Null Mode.md │ ├── Optimization │ │ ├── Allocators and Links.md │ │ ├── Hero Thread.md │ │ ├── ML.md │ │ └── Optimization.md │ ├── Parser_Scout-comments.html │ ├── Parser_Scout.md │ ├── Patterns.md │ ├── Posts about Rust.md │ ├── Reference Types.md │ ├── References.md │ ├── Remembering Subclasses, Truthiness.md │ ├── Repl.it Plan-comments.html │ ├── Repl.it Plan.md │ ├── Ret vs Panic, Locals (already migrated).md │ ├── Ret vs Panic, Locals-comments.html │ ├── Simple Docs.md │ ├── Static Lifetimes.md │ ├── Structs │ │ └── Structs.md │ ├── Subprojects │ │ ├── Parser.md │ │ └── Ref Count Improvements.md │ ├── Superstructure │ │ ├── Chronobase-comments.html │ │ ├── Chronobase.md │ │ ├── Deletion Challenge.md │ │ ├── Firestore.md │ │ ├── Incarnation Mutability Challenge.md │ │ ├── Intermediate State Challenge.md │ │ ├── Intro 2.md │ │ ├── Intro.md │ │ ├── Ivytree.md │ │ ├── Lazy Loading and Security.md │ │ ├── Metastate Challenge.md │ │ ├── Network Layer.md │ │ ├── Performance.md │ │ ├── Plan.md │ │ ├── Querying.md │ │ ├── SIMD.md │ │ ├── Starcraft.md │ │ ├── Superstructures Justification.md │ │ ├── To be categorized.md │ │ └── Untitled document.md │ ├── Surprising Weak Ref Implementations_ Vale, Swift,_.md │ ├── Templates │ │ ├── Im_mutable in Templates.md │ │ ├── Solver.md │ │ └── Templatas.md │ ├── Thesis Draft-comments.html │ ├── Thesis Draft.md │ ├── Threading.md │ ├── Tracking Allocator Per-Object-comments.html │ ├── Tracking Allocator Per-Object.md │ ├── Troubleshooting.md │ ├── Types.md │ ├── Uncategorized Notes.md │ ├── Untitled document(1).md │ ├── Untitled document(2).md │ ├── Untitled document.md │ ├── Upcoming Changes (Tentative)-comments.html │ ├── Upcoming Changes (Tentative).md │ ├── Vale Coroutines.md │ ├── Vale FAQ.md │ ├── Vale Module System_ When to Include What Code-comm.html │ ├── Vale Module System_ When to Include What Code.md │ ├── Vale Parser-comments.html │ ├── Vale Steps.md │ ├── Vale_ The Interesting Parts-comments.html │ ├── Vale_ The Interesting Parts.md │ ├── Valeficent.md │ ├── Virtual Templates.md │ ├── Virtuals │ │ ├── Concepts, Interfaces.md │ │ ├── Generating ETables.md │ │ ├── Multimethods.md │ │ ├── Perfect Virtuals Notes.md │ │ ├── Perfect Virtuals-comments.html │ │ ├── Perfect Virtuals.md │ │ ├── Tetris Hashing-comments.html │ │ ├── Tetris Hashing.md │ │ ├── VTable layout.md │ │ ├── Virtuals-comments.html │ │ └── Virtuals.md │ ├── Visual Studio and .DLLs.md │ ├── Voids and Discarding.md │ ├── Von.md │ ├── Weak References in Vale.md │ ├── Weak Refs-comments.html │ ├── Weak Refs.md │ ├── Why Vale_-comments.html │ ├── Why Vale_.md │ ├── fn, Mutable and Immutable Functions.md │ ├── superstructures1.jpg │ ├── superstructures2.jpg │ ├── superstructures2b.jpg │ ├── vlang notes-comments.html │ └── vlang notes.md ├── regions │ ├── Regions.md │ ├── RegionsLayout.md │ └── Transmigration.md ├── ret-vs-panic-locals.md └── virtuals │ └── Impls.md ├── scripts ├── VERSION ├── all │ ├── README │ ├── helloworld │ │ └── main.vale │ ├── valec-help-build.txt │ ├── valec-help.txt │ └── valec-version.txt ├── build-compiler.script.vale ├── docker │ └── Dockerfile ├── mac │ ├── build-compiler.sh │ └── install-compiler-prereqs.sh ├── smoke_benchmark.sh ├── ubuntu │ ├── README │ ├── build-compiler.sh │ └── install-compiler-prereqs.sh └── windows │ ├── README.txt │ ├── build-compiler.bat │ └── install-compiler-prereqs.bat └── stdlib ├── .gitignore ├── src ├── arrays │ └── arrays.vale ├── cast.vale ├── collections │ ├── hashmap │ │ ├── HashMap.vale │ │ ├── hash_map_iter.vale │ │ ├── hash_map_key_set.vale │ │ └── test │ │ │ └── test.vale │ ├── hashset │ │ ├── HashSet.vale │ │ ├── hash_set_diff.vale │ │ ├── hash_set_iter.vale │ │ └── test │ │ │ └── test.vale │ └── list │ │ ├── List.vale │ │ ├── list_iter.vale │ │ └── test │ │ └── test.vale ├── command │ ├── command.vale │ ├── native │ │ ├── subprocess.c │ │ └── subprocess.h │ └── test │ │ └── test.vale ├── date │ ├── date.vale │ └── native │ │ └── date.c ├── error │ └── error.vale ├── flagger │ └── flagger.vale ├── ifunction │ └── ifunction1.vale ├── logic.vale ├── math │ ├── math.vale │ └── native │ │ └── mathnative.c ├── mtpid │ ├── mtpid.vale │ └── native │ │ └── mtpid.c ├── optutils │ └── optutils.vale ├── os │ ├── native │ │ └── os.c │ └── os.vale ├── panic.vale ├── path │ ├── native │ │ ├── list.h │ │ └── path.c │ ├── path.vale │ └── test │ │ └── test.vale ├── print.vale ├── resultutils │ └── resultutils.vale ├── stdin │ ├── native │ │ └── stdin.c │ └── stdin.vale ├── str.vale ├── stringutils │ ├── stringutils.vale │ └── test │ │ └── test.vale ├── test │ └── stdlibtests.vale └── testsuite │ └── testsuite.vale └── test.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | .* 2 | **/*.idea 3 | **/*.md 4 | **/*.bat 5 | **/.gitignore 6 | **/.git 7 | **/.DS_Store 8 | 9 | Backend/build 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.jar filter=lfs diff=lfs merge=lfs -text 2 | **/*.jar filter=lfs diff=lfs merge=lfs -text 3 | **/*.dll filter=lfs diff=lfs merge=lfs -text 4 | **/*.ll filter=lfs diff=lfs merge=lfs -text 5 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: ValeLang 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/contributors: -------------------------------------------------------------------------------- 1 | # This is a scratch file for people to commit to, so that their subsequent PRs can run our CI, the GitHub Actions workflows. 2 | # 3 | # Why is this needed? It's because Github only allows people to trigger CI runs if they've previously contributed to a project. 4 | # 5 | # So, just: 6 | # 1. Make a new SEPARATE pull request, containing a change to this file. 7 | # 2. We'll approve and merge in that PR. 8 | # 9 | # And now, GitHub trusts you to run CI on your other PR! 10 | 11 | # These people are awesome: 12 | Verdagon 13 | solstice333 14 | Ivo-Balbaert 15 | theowatkins 16 | DestyNova 17 | Zodey 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | release-ubuntu 2 | release-mac 3 | release-windows 4 | release-unix 5 | Driver.jar 6 | .DS_Store 7 | __MACOSX 8 | Frontend/lib/lift-json_2.12-3.3.0-RC1.jar 9 | Frontend/lib/scala-library-2.12.8.jar 10 | Frontend/lib/scala-reflect-2.12.8.jar 11 | Frontend/lib/scala-xml_2.12-1.0.6.jar 12 | Frontend/Frontend.jar 13 | Catalyst/catalyst/.* 14 | Catalyst/.* 15 | Catalyst/catalyst/target/ 16 | Catalyst/testing/test*/out/ 17 | removeextra.sh 18 | target 19 | project 20 | .metals 21 | Frontend/.idea/librariesadoptopenjdk.tar.gz 22 | jdk-11.0.10+9-jre 23 | adoptopenjdk.tar.gz 24 | -------------------------------------------------------------------------------- /Backend/__init__.py: -------------------------------------------------------------------------------- 1 | # __init__.py 2 | from .valec import ValeCompiler -------------------------------------------------------------------------------- /Backend/builtins/ValeBuiltins.h: -------------------------------------------------------------------------------- 1 | #ifndef VALE_EXPORTS_ValeBuiltins_H_ 2 | #define VALE_EXPORTS_ValeBuiltins_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | typedef int32_t ValeInt; 9 | typedef struct { ValeInt length; char chars[0]; } ValeStr; 10 | ValeStr* ValeStrNew(ValeInt length); 11 | ValeStr* ValeStrFrom(char* source); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /Backend/builtins/assert.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void __vassert(char value, const char* message) { 9 | if (!value) { 10 | printf("%s\n", message); 11 | exit((unsigned char)1); 12 | } 13 | } 14 | 15 | void __vassertI64Eq(int64_t expected, int64_t actual, const char* message) { 16 | if (expected != actual) { 17 | printf("%s Expected %"PRId64" but was %"PRId64".\n", message, expected, actual); 18 | exit((unsigned char)1); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Backend/builtins/mainargs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "ValeBuiltins.h" 7 | 8 | 9 | extern int64_t __main_num_args; 10 | extern char** __main_args; 11 | int64_t __vale_numMainArgs() { 12 | return __main_num_args; 13 | } 14 | ValeStr* __vale_getMainArg(int64_t i) { 15 | char* argCStr = __main_args[i]; 16 | int64_t len = strlen(argCStr); 17 | ValeStr* vstr = ValeStrNew(len); 18 | strncpy(vstr->chars, argCStr, len); 19 | return vstr; 20 | } 21 | -------------------------------------------------------------------------------- /Backend/builtins/math.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | double __vale_castI32Float(int32_t i) { 5 | return (double)i; 6 | } 7 | 8 | int32_t __vale_castFloatI32(double i) { 9 | return (int32_t)i; 10 | } 11 | 12 | double __vale_castI64Float(int64_t i) { 13 | return (double)i; 14 | } 15 | 16 | int64_t __vale_castFloatI64(double i) { 17 | return (int64_t)i; 18 | } 19 | 20 | int32_t __vale_TruncateI64ToI32(int64_t i) { 21 | return (int32_t)i; 22 | } 23 | 24 | int64_t __vale_ExtendI32ToI64(int32_t i) { 25 | return (int64_t)i; 26 | } 27 | -------------------------------------------------------------------------------- /Backend/builtins/stdio.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | void __vprintCStr(const char* str) { 8 | printf("%s", str); 9 | } 10 | 11 | void __vprintCStrToStderr(const char* str) { 12 | fprintf(stderr, "%s", str); 13 | } 14 | 15 | void __vprintI64(int64_t x) { 16 | printf("%lld", x); 17 | } 18 | 19 | void __vprintI64ToStderr(int64_t x) { 20 | fprintf(stderr, "%lld", x); 21 | } 22 | 23 | void __vprintBool(int8_t x) { 24 | if (x) { 25 | printf("true"); 26 | } else { 27 | printf("false"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Backend/clion_env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | if ! brew list llvm@7 &>/dev/null; then 4 | echo install llvm@7 with \`brew install llvm@7\` 5 | exit 1 6 | fi 7 | 8 | printf "paste the below into Preferences -> " 9 | printf "Build, Execution, Deployment -> CMake -> Environment: \n" 10 | brew info llvm@7 | grep -iE "(CPPFLAGS|LDFLAGS)=" \ 11 | | grep -iEv "export LDFLAGS" \ 12 | | sed -E "s/export//" | sed -E "s/^[[:space:]]*//" 13 | printf "PATH=$(brew --prefix llvm@7)/bin:" 14 | printf "$(cat /etc/paths | tr "\n" ":" | sed -nE 's/:$// p')\n" 15 | -------------------------------------------------------------------------------- /Backend/setupclion.txt: -------------------------------------------------------------------------------- 1 | open preferences -> Build,Execution,Deployment -> CMake 2 | 3 | add this to the profile's CMake Options field: 4 | -G "Unix Makefiles" -DLLVM_DIR=/Users/verdagon/clang+llvm-16.0.4-arm64-apple-darwin22.0/lib/cmake/llvm 5 | -------------------------------------------------------------------------------- /Backend/src/error.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef error_h 3 | #define error_h 4 | 5 | #include 6 | 7 | // Exit error codes 8 | enum class ExitCode : int { 9 | Success = 0, 10 | BadOpts = 1, // Invalid compiler options 11 | LlvmSetupFailed = 2, // Failure to set up LLVM 12 | VerifyFailed = 3, // LLVM didn't like the AST we gave it. 13 | }; 14 | 15 | 16 | template 17 | inline void errorExit(ExitCode exitCode, T&&... thingsToPrint); 18 | 19 | template 20 | inline void errorExit(ExitCode exitCode, First&& first, Rest&&... rest) { 21 | std::cerr << std::forward(first); 22 | errorExit(exitCode, std::forward(rest)...); 23 | } 24 | 25 | template<> 26 | inline void errorExit<>(ExitCode exitCode) { 27 | std::cerr << std::endl; 28 | exit((int)exitCode); 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Backend/src/fileio.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef fileio_h 3 | #define fileio_h 4 | 5 | #include 6 | 7 | // Extract the directory for this file path. 8 | std::string fileDirectory(std::string fn); 9 | 10 | // Extract a filename only from a path. 11 | std::string getFileName(std::string fn); 12 | 13 | // Extract a filename only (no extension) from a path. 14 | std::string getFileNameNoExt(std::string fn); 15 | 16 | // Concatenate folder, filename and extension into a path 17 | std::string fileMakePath(const char *dir, const char *srcfn, const char *ext); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /Backend/src/function/boundary.h: -------------------------------------------------------------------------------- 1 | #ifndef BOUNDARY_H_ 2 | #define BOUNDARY_H_ 3 | 4 | #include "../globalstate.h" 5 | #include "boundary.h" 6 | 7 | Ref receiveHostObjectIntoVale( 8 | GlobalState* globalState, 9 | FunctionState* functionState, 10 | LLVMBuilderRef builder, 11 | Ref hostRegionInstance, 12 | Ref valeRegionInstance, 13 | Reference* hostRefMT, 14 | Reference* valeRefMT, 15 | LLVMValueRef hostRefLE); 16 | 17 | // Returns the object and the size. 18 | std::pair sendValeObjectIntoHostAndDealias( 19 | GlobalState* globalState, 20 | FunctionState* functionState, 21 | LLVMBuilderRef builder, 22 | Ref valeRegionInstanceRef, 23 | Ref hostRegionInstanceRef, 24 | Reference* valeRefMT, 25 | Reference* hostRefMT, 26 | Ref valeRef); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Backend/src/function/expression.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPRESSION_H_ 2 | #define EXPRESSION_H_ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "../metal/ast.h" 9 | #include "../metal/instructions.h" 10 | #include "../globalstate.h" 11 | #include "expressions/shared/ref.h" 12 | #include "function.h" 13 | 14 | Ref translateExpression( 15 | GlobalState* globalState, 16 | FunctionState* functionState, 17 | BlockState* blockState, 18 | LLVMBuilderRef builder, 19 | Expression* expr); 20 | 21 | std::vector translateExpressions( 22 | GlobalState* globalState, 23 | FunctionState* functionState, 24 | BlockState* blockState, 25 | LLVMBuilderRef builder, 26 | std::vector exprs); 27 | 28 | #endif -------------------------------------------------------------------------------- /Backend/src/function/expressions/call.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "shared/shared.h" 3 | 4 | #include "../../translatetype.h" 5 | 6 | #include "../expression.h" 7 | 8 | 9 | Ref translateCall( 10 | GlobalState* globalState, 11 | FunctionState* functionState, 12 | BlockState* blockState, 13 | LLVMBuilderRef builder, 14 | Call* call) { 15 | auto argsLE = std::vector{}; 16 | argsLE.reserve(call->argExprs.size()); 17 | for (int i = 0; i < call->argExprs.size(); i++) { 18 | auto argLE = translateExpression(globalState, functionState, blockState, builder, call->argExprs[i]); 19 | buildFlare(FL(), globalState, functionState, builder); 20 | globalState->getRegion(call->function->params[i]) 21 | ->checkValidReference(FL(), functionState, builder, false, call->function->params[i], argLE); 22 | argsLE.push_back(argLE); 23 | } 24 | 25 | return buildCallV(globalState, functionState, builder, call->function, argsLE); 26 | } 27 | -------------------------------------------------------------------------------- /Backend/src/function/expressions/constantstr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../../region/common/controlblock.h" 3 | #include "shared/string.h" 4 | 5 | #include "shared/shared.h" 6 | #include "../../region/common/heap.h" 7 | 8 | Ref translateConstantStr( 9 | AreaAndFileAndLine from, 10 | GlobalState* globalState, 11 | FunctionState* functionState, 12 | LLVMBuilderRef builder, 13 | ConstantStr* constantStr) { 14 | auto strRef = 15 | buildConstantVStr(globalState, functionState, builder, constantStr->value); 16 | // Dont need to alias here, see SRCAO 17 | return strRef; 18 | } 19 | -------------------------------------------------------------------------------- /Backend/src/function/expressions/construct.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../../region/common/controlblock.h" 3 | 4 | #include "../../translatetype.h" 5 | 6 | #include "shared/ref.h" 7 | #include "shared/members.h" 8 | #include "../expression.h" 9 | #include "shared/shared.h" 10 | #include "../../region/common/heap.h" 11 | 12 | Ref translateConstruct( 13 | AreaAndFileAndLine from, 14 | GlobalState* globalState, 15 | FunctionState* functionState, 16 | LLVMBuilderRef builder, 17 | Reference* desiredReference, 18 | const std::vector& memberRefs) { 19 | return globalState->getRegion(desiredReference) 20 | ->allocate( 21 | makeVoidRef(globalState), from, functionState, builder, desiredReference, memberRefs); 22 | } 23 | -------------------------------------------------------------------------------- /Backend/src/function/expressions/shared/afl.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCTION_EXPRESSIONS_SHARED_AFL_H_ 2 | #define FUNCTION_EXPRESSIONS_SHARED_AFL_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | //#include "metal/ast.h" 11 | //#include "metal/instructions.h" 12 | //#include "globalstate.h" 13 | //#include "function/function.h" 14 | //#include "utils/fileio.h" 15 | 16 | struct AreaAndFileAndLine { 17 | std::string area; 18 | std::string file; 19 | int line; 20 | }; 21 | 22 | // File and Line 23 | #define FL() (AreaAndFileAndLine{ "", __FILE__, __LINE__ }) 24 | // Area and File and Line 25 | #define AFL(area) (AreaAndFileAndLine{ (area), __FILE__, __LINE__ }) 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /Backend/src/metal/ast.cpp: -------------------------------------------------------------------------------- 1 | #include "ast.h" 2 | 3 | extern const std::string BUILTIN_PROJECT_NAME = "__vale"; -------------------------------------------------------------------------------- /Backend/src/metal/json.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValeLang/Vale/6fb98324c0b919a55812376f4d74cfcbfc7f2db7/Backend/src/metal/json.h -------------------------------------------------------------------------------- /Backend/src/metal/readjson.h: -------------------------------------------------------------------------------- 1 | #ifndef READ_JSON_H_ 2 | #define READ_JSON_H_ 3 | 4 | #include "../json.hpp" 5 | 6 | #include "types.h" 7 | #include "ast.h" 8 | #include "instructions.h" 9 | #include "metalcache.h" 10 | 11 | //Program* readProgram(MetalCache* cache, const nlohmann::json& program); 12 | Package* readPackage(MetalCache* cache, const nlohmann::json& program); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /Backend/src/metal/types.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "ast.h" 3 | -------------------------------------------------------------------------------- /Backend/src/region/common/heap.cpp: -------------------------------------------------------------------------------- 1 | #include "../../utils/counters.h" 2 | #include "../../fileio.h" 3 | #include "heap.h" 4 | #include "../../function/expressions/shared/members.h" 5 | #include "../../function/expressions/shared/shared.h" 6 | #include "controlblock.h" 7 | #include "../../function/expressions/shared/string.h" 8 | -------------------------------------------------------------------------------- /Backend/src/region/common/heap.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCTION_EXPRESSIONS_SHARED_HEAP_H_ 2 | #define FUNCTION_EXPRESSIONS_SHARED_HEAP_H_ 3 | 4 | #include 5 | 6 | #include "../../function/function.h" 7 | #include "../../globalstate.h" 8 | #include "../../function/expressions/shared/shared.h" 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /Backend/src/region/common/migration.cpp: -------------------------------------------------------------------------------- 1 | #include "migration.h" 2 | -------------------------------------------------------------------------------- /Backend/src/region/common/migration.h: -------------------------------------------------------------------------------- 1 | #ifndef MIDAS_MIGRATION_H 2 | #define MIDAS_MIGRATION_H 3 | 4 | #include 5 | 6 | // TODO: change all GEP to in bounds 7 | 8 | #endif //MIDAS_MIGRATION_H 9 | -------------------------------------------------------------------------------- /Backend/src/region/common/referendptrmaker.h: -------------------------------------------------------------------------------- 1 | #ifndef REGION_COMMON_REFERENDPTRMAKER_ 2 | #define REGION_COMMON_REFERENDPTRMAKER_ 3 | 4 | #include "../../function/expressions/shared/afl.h" 5 | #include 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /Backend/src/region/iregion.cpp: -------------------------------------------------------------------------------- 1 | #include "iregion.h" 2 | 3 | LLVMValueRef checkValidReference( 4 | AreaAndFileAndLine checkerAFL, 5 | GlobalState* globalState, 6 | FunctionState* functionState, 7 | LLVMBuilderRef builder, 8 | bool expectLive, 9 | Reference* refM, 10 | Ref ref) { 11 | return globalState->getRegion(refM)->checkValidReference( 12 | checkerAFL, functionState, builder, expectLive, refM, ref); 13 | } 14 | 15 | LLVMValueRef checkValidReference( 16 | AreaAndFileAndLine checkerAFL, 17 | GlobalState* globalState, 18 | FunctionState* functionState, 19 | LLVMBuilderRef builder, 20 | bool expectLive, 21 | Reference* refM, 22 | LiveRef liveRef) { 23 | auto ref = toRef(globalState, refM, liveRef); 24 | return checkValidReference( 25 | checkerAFL, globalState, functionState, builder, expectLive, refM, ref); 26 | } 27 | -------------------------------------------------------------------------------- /Backend/src/region/regions.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include "../globalstate.h" 5 | #include "../function/function.h" 6 | #include "common/common.h" 7 | -------------------------------------------------------------------------------- /Backend/src/simplehash/cppsimplehashmap.cpp: -------------------------------------------------------------------------------- 1 | #include "cppsimplehashmap.h" 2 | 3 | #include 4 | 5 | const int64_t hashTableSizeList[] = { 6 | 0, 3, 7, 13, 27, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157, 7 | 98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917, 25165843, 8 | 50331653, 100663319, 201326611, 402653189, 805306457, 1610612741 9 | }; 10 | -------------------------------------------------------------------------------- /Backend/src/simplehash/llvmsimplehashmap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Evan Ovadia on 5/5/22. 3 | // 4 | 5 | #include "llvmsimplehashmap.h" 6 | -------------------------------------------------------------------------------- /Backend/src/utils/call.cpp: -------------------------------------------------------------------------------- 1 | #include "call.h" 2 | 3 | LLVMValueRef buildSimpleCall( 4 | LLVMBuilderRef builder, 5 | LLVMValueRef function, 6 | LLVMTypeRef funcLT, 7 | std::vector args, 8 | const std::string& name) { 9 | return LLVMBuildCall2(builder, funcLT, function, args.data(), args.size(), name.c_str()); 10 | } 11 | -------------------------------------------------------------------------------- /Backend/src/utils/call.h: -------------------------------------------------------------------------------- 1 | #ifndef _UTILS_CALL_H_ 2 | #define _UTILS_CALL_H_ 3 | 4 | #include 5 | 6 | LLVMValueRef buildSimpleCall( 7 | LLVMBuilderRef builder, 8 | LLVMValueRef function, 9 | LLVMTypeRef funcLT, 10 | std::vector args, 11 | const std::string& name = ""); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /Backend/src/utils/definefunction.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_DEFINEFUNCTION_H 2 | #define UTILS_DEFINEFUNCTION_H 3 | 4 | #include 5 | 6 | RawFuncPtrLE addRawFunction( 7 | LLVMModuleRef mod, 8 | const std::string& name, 9 | LLVMTypeRef returnLT, 10 | std::vector argsLT); 11 | 12 | ValeFuncPtrLE addValeFunction( 13 | GlobalState* globalState, 14 | const std::string& name, 15 | LLVMTypeRef returnLT, 16 | std::vector argsLT); 17 | 18 | void defineRawFunctionBody( 19 | LLVMContextRef context, 20 | LLVMValueRef functionL, 21 | LLVMTypeRef returnTypeL, 22 | const std::string& name, 23 | std::function definer); 24 | 25 | void defineValeFunctionBody( 26 | LLVMContextRef context, 27 | ValeFuncPtrLE functionL, 28 | LLVMTypeRef returnTypeL, 29 | const std::string& name, 30 | std::function definer); 31 | 32 | #endif //UTILS_DEFINEFUNCTION_H 33 | -------------------------------------------------------------------------------- /Backend/src/utils/flags.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_FLAGS_H 2 | #define UTILS_FLAGS_H 3 | 4 | #include 5 | 6 | // Returns the number of consumed args. 7 | // The caller should adjust argv and argc accordingly, and maybe move argv[0] to argv[2]. 8 | LLVMValueRef processFlag( 9 | GlobalState* globalState, 10 | FunctionState* functionState, 11 | LLVMBuilderRef builder, 12 | const std::string& flagName, 13 | LLVMValueRef mainArgsCountLE, 14 | LLVMValueRef mainArgsLE, 15 | std::function thenBody); 16 | 17 | #endif //UTILS_FLAGS_H 18 | -------------------------------------------------------------------------------- /Backend/src/utils/llvm.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_LLVM_H 2 | #define UTILS_LLVM_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | LLVMValueRef constI64LE(LLVMContextRef context, int64_t n); 9 | 10 | LLVMValueRef ptrIsNull(LLVMContextRef context, LLVMBuilderRef builder, LLVMValueRef ptrLE); 11 | 12 | LLVMValueRef subscript( 13 | LLVMBuilderRef builder, 14 | LLVMTypeRef elementLT, 15 | LLVMValueRef elementsPtrLE, 16 | LLVMValueRef indexLE, 17 | const std::string& name = "element"); 18 | 19 | LLVMValueRef subscriptForPtr( 20 | LLVMBuilderRef builder, 21 | LLVMTypeRef elementLT, 22 | LLVMValueRef elementsPtrLE, 23 | LLVMValueRef indexLE, 24 | const std::string& name = "elementPtr"); 25 | 26 | #endif //UTILS_LLVM_H 27 | -------------------------------------------------------------------------------- /Backend/src/utils/randomgeneration.h: -------------------------------------------------------------------------------- 1 | #ifndef RANDOM_GENERATION_H_ 2 | #define RANDOM_GENERATION_H_ 3 | 4 | #include 5 | 6 | extern uint32_t getRandomGenerationAddend(uint64_t randomNumber); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /Backend/test.sh: -------------------------------------------------------------------------------- 1 | ../Tester/build/testvalec --frontend_path ../Frontend/Frontend.jar --backend_path ./build/backend --builtins_dir ./builtins --valec_path ../Coordinator/build/valec --backend_tests_dir ./test --frontend_tests_dir ../Frontend --stdlib_dir ../stdlib "$@" 2 | -------------------------------------------------------------------------------- /Backend/test/__init__.py: -------------------------------------------------------------------------------- 1 | # __init__.py 2 | from .valetest import ValeTest -------------------------------------------------------------------------------- /Backend/test/prettify_vir.py: -------------------------------------------------------------------------------- 1 | import json 2 | import argparse 3 | 4 | 5 | def main(): 6 | parser = argparse.ArgumentParser(description="prettify VIR") 7 | parser.add_argument("VIR_FILE", help="path to VIR file") 8 | args = parser.parse_args() 9 | 10 | with open(args.VIR_FILE, "r") as vir_f: 11 | j = json.load(vir_f) 12 | with open(args.VIR_FILE, "w") as vir_f: 13 | json.dump(j, fp=vir_f, indent=3) 14 | 15 | 16 | if __name__ == '__main__': 17 | main() 18 | -------------------------------------------------------------------------------- /Backend/test/tethercrash.vale: -------------------------------------------------------------------------------- 1 | import stdlib.*; 2 | 3 | struct Spaceship { 4 | fuel int; 5 | } 6 | exported func main() int { 7 | print("Starting...\n"); 8 | s = Spaceship(73); 9 | b = &s; 10 | print("Dropping...\n"); 11 | drop(s); 12 | print("Getting tether...\n"); 13 | s__tether = b; 14 | print("Should have failed before here!\n"); 15 | s__tether.fuel 16 | } 17 | -------------------------------------------------------------------------------- /Coordinator/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /Coordinator/build.bat: -------------------------------------------------------------------------------- 1 | 2 | %1\valec.exe build coordinator=src valecutils=../Utils/src --output_dir build -o valec 3 | -------------------------------------------------------------------------------- /Coordinator/build.sh: -------------------------------------------------------------------------------- 1 | 2 | BOOTSTRAPPING_VALEC_DIR="$1" 3 | if [ "$BOOTSTRAPPING_VALEC_DIR" == "" ]; then 4 | echo "Please supply the bootstrapping valec directory." 5 | echo "Example: ~/TheValeCompiler" 6 | exit 7 | fi 8 | shift; 9 | 10 | $BOOTSTRAPPING_VALEC_DIR/valec build coordinator=src valecutils=../Utils/src --output_dir build -o valec --pic true $@ 11 | -------------------------------------------------------------------------------- /Frontend/.gitignore: -------------------------------------------------------------------------------- 1 | project/target 2 | target 3 | out 4 | Valestrom.jar 5 | .bsp 6 | -------------------------------------------------------------------------------- /Frontend/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /Frontend/.idea/.name: -------------------------------------------------------------------------------- 1 | frontend -------------------------------------------------------------------------------- /Frontend/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /Frontend/.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /Frontend/.idea/google-java-format.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /Frontend/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | -------------------------------------------------------------------------------- /Frontend/.idea/libraries/com_google_cloud_functions_functions_framework_api_1_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Frontend/.idea/libraries/commons_lang3_3_13_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Frontend/.idea/libraries/lift_json_2_12_3_5_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Frontend/.idea/libraries/org_scalatest_scalatest_2_12_3_0_8.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Frontend/.idea/libraries/scala_reflect_2_12_8.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Frontend/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Frontend/.idea/sbt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /Frontend/.idea/scala_compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Frontend/.idea/scala_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 25 | -------------------------------------------------------------------------------- /Frontend/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Frontend/Builtins/Builtins.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/as.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.result.*; 2 | 3 | extern("vale_as_subtype") 4 | func as(left &SuperType) Result<&SubType, &SuperType> 5 | where implements(SubType, SuperType); 6 | 7 | extern("vale_as_subtype") 8 | func as(left SuperType) Result 9 | where implements(SubType, SuperType), SuperType = Ref[own, _]; 10 | 11 | // extern("vale_as_subtype") 12 | // func as_own(left SuperType) Result 13 | // where SuperKind Kind, 14 | // O = own, 15 | // SubType Ref = Ref[O, SubKind], 16 | // SuperType Ref = Ref[O, SuperKind], 17 | // implements(SubType, SuperType); 18 | // -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/clone.vale: -------------------------------------------------------------------------------- 1 | 2 | func clone(x int) int { x } 3 | func clone(x bool) bool { x } 4 | func clone(x float) float { x } 5 | func clone(x void) { } 6 | func clone(x i64) i64 { x } 7 | func clone(x str) str { x } 8 | 9 | // func clone(x &T) &T where T = Ref[_, Kind[mut]] { x } 10 | // func clone(x &&T) &&T where T = Ref[_, Kind[mut]] { x } 11 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/drop.vale: -------------------------------------------------------------------------------- 1 | 2 | func drop(x int) {} 3 | func drop(x bool) {} 4 | func drop(x float) {} 5 | func drop(x void) {} 6 | func drop(x i64) {} 7 | func drop(x str) {} 8 | 9 | func drop(v void, x T) 10 | where func drop(T)void { 11 | drop(x) 12 | } 13 | 14 | // Because e.g. drop(Opt) looks to see if a type has a drop function. 15 | func drop(x &&T) where T = Ref[_, Kind[mut]] { } 16 | func drop(x &T) where T = Ref[_, Kind[mut]] { } 17 | func drop(x &&T) where T = Ref[_, Kind[mut]] { } 18 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/functor1.vale: -------------------------------------------------------------------------------- 1 | 2 | // This is mainly used for arrays. 3 | // It's not particularly great because it's got that `drop` name hardcoded in there. 4 | // Hopefully soon we can upgrade our generics system to not need this, see CFWG. 5 | func __call(v void, param P1) R 6 | where F Prot = func drop(P1)R { 7 | F(param) 8 | } 9 | 10 | 11 | 12 | // struct Functor1 imm { } 13 | // 14 | // func __call(self &Functor1, param1 P1) R 15 | // where P1 Ref, R Ref, F = Prot[_, R] { 16 | // F(param1) 17 | // } 18 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/logic.vale: -------------------------------------------------------------------------------- 1 | 2 | func not(b bool) bool { return __vbi_not(b); } 3 | extern func __vbi_not(b bool) bool; 4 | 5 | func ==(left bool, right bool) bool { return __vbi_eqBoolBool(left, right); } 6 | extern func __vbi_eqBoolBool(left bool, right bool) bool; 7 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/mainargs.vale: -------------------------------------------------------------------------------- 1 | 2 | extern func numMainArgs() int; 3 | extern func getMainArg(i int) str; 4 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/migrate.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.arrays.*; 2 | 3 | func migrate(from []E, to &[]E) { 4 | intermediate = Array(from.capacity()); 5 | drop_into(from, &{ intermediate.push(_); }); 6 | drop_into(intermediate, &{ to.push(_); }); 7 | } 8 | 9 | func migrate(from [#N]E, to &[]E) { 10 | intermediate = Array(N); 11 | drop_into(from, &{ intermediate.push(_); }); 12 | drop_into(intermediate, &{ to.push(_); }); 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/panic.vale: -------------------------------------------------------------------------------- 1 | extern func __vbi_panic() __Never; 2 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/panicutils.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.print.*; 2 | import v.builtins.str.*; 3 | import v.builtins.panic.*; 4 | 5 | func panic() __Never { 6 | return __vbi_panic(); 7 | } 8 | 9 | func panic(msg str) __Never { 10 | print(msg); 11 | print("\n"); 12 | return __vbi_panic(); 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/print.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.str.*; 2 | 3 | func print(s str) { printstr(s, 0, len(s)) } 4 | extern func printstr(s str, start int, length int); 5 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/runtime_sized_array_capacity.vale: -------------------------------------------------------------------------------- 1 | extern("vale_runtime_sized_array_capacity") 2 | func capacity(arr &[]E) int; 3 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/runtime_sized_array_len.vale: -------------------------------------------------------------------------------- 1 | extern("vale_runtime_sized_array_len") 2 | func len(arr &[]E) int; 3 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/runtime_sized_array_mut_drop.vale: -------------------------------------------------------------------------------- 1 | 2 | func drop_into(arr []E, consumer &F) void 3 | where func(&F, E)void 4 | { 5 | while (arr.len() > 0) { 6 | consumer(arr.pop()); 7 | } 8 | [] = arr; 9 | } 10 | func drop(arr []E) void 11 | where func drop(E)void { 12 | drop_into(arr, {_;}); 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/runtime_sized_array_mut_new.vale: -------------------------------------------------------------------------------- 1 | extern("vale_runtime_sized_array_mut_new") 2 | func Array(size int) []E 3 | where M = mut; 4 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/runtime_sized_array_pop.vale: -------------------------------------------------------------------------------- 1 | extern("vale_runtime_sized_array_pop") 2 | func pop(arr &[]E) E; 3 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/runtime_sized_array_push.vale: -------------------------------------------------------------------------------- 1 | extern("vale_runtime_sized_array_push") 2 | func push(arr &[]E, newElement E) void; 3 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/sameinstance.vale: -------------------------------------------------------------------------------- 1 | 2 | extern("vale_same_instance") 3 | func ===(left &T, right &T) bool; 4 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/static_sized_array_mut_drop.vale: -------------------------------------------------------------------------------- 1 | 2 | extern("vale_static_sized_array_drop_into") 3 | func drop_into(arr [#S]E, consumer &F) void 4 | where func(&F, E)void; 5 | 6 | func drop(arr [#S]E) void 7 | where func drop(E)void { 8 | drop_into(arr, {_;}); 9 | } 10 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/streq.vale: -------------------------------------------------------------------------------- 1 | 2 | extern func streq( 3 | aContainerStr str, 4 | aBegin int, 5 | aEnd int, 6 | bContainerStr str, 7 | bBegin int, 8 | bEnd int) 9 | bool; 10 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/tup0.vale: -------------------------------------------------------------------------------- 1 | 2 | struct Tup0 { } 3 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/tup1.vale: -------------------------------------------------------------------------------- 1 | 2 | // See TAVWG for what it would take to re-enable variadic tuples. 3 | // struct Tup { 4 | // _ ..T; 5 | // } 6 | 7 | #!DeriveStructDrop 8 | struct Tup1 { 0 T0; } 9 | func drop(tup Tup1) 10 | where func drop(T0)void { [a] = tup; } 11 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/tup2.vale: -------------------------------------------------------------------------------- 1 | 2 | // See TAVWG for what it would take to re-enable variadic tuples. 3 | // struct Tup { 4 | // _ ..T; 5 | // } 6 | 7 | #!DeriveStructDrop 8 | struct Tup2 { 0 T0; 1 T1; } 9 | func drop(tup Tup2) 10 | where func drop(T0)void, 11 | func drop(T1)void 12 | { [a, b] = tup; } 13 | -------------------------------------------------------------------------------- /Frontend/Builtins/src/dev/vale/resources/weak.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.opt.*; 2 | 3 | extern("vale_lock_weak") 4 | func lock(weak &&T) Opt<&T>; 5 | -------------------------------------------------------------------------------- /Frontend/CompileOptions/CompileOptions.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Frontend/CompileOptions/src/dev/vale/options/GlobalOptions.scala: -------------------------------------------------------------------------------- 1 | package dev.vale.options 2 | 3 | object GlobalOptions { 4 | def apply(): GlobalOptions = { 5 | GlobalOptions( 6 | sanityCheck = false, 7 | useOverloadIndex = false, 8 | useOptimizedSolver = true, 9 | verboseErrors = false, 10 | debugOutput = false) 11 | } 12 | 13 | def test(): GlobalOptions = { 14 | GlobalOptions(true, false, true, true, true) 15 | } 16 | } 17 | 18 | case class GlobalOptions( 19 | sanityCheck: Boolean, 20 | useOverloadIndex: Boolean, 21 | useOptimizedSolver: Boolean, 22 | verboseErrors: Boolean, 23 | debugOutput: Boolean) 24 | -------------------------------------------------------------------------------- /Frontend/FinalAST/FinalAST.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Frontend/FinalAST/src/dev/vale/finalast/MetalPrinter.scala: -------------------------------------------------------------------------------- 1 | package dev.vale.finalast 2 | 3 | import dev.vale.von.{IVonData, VonPrinter, VonSyntax} 4 | 5 | -------------------------------------------------------------------------------- /Frontend/HigherTypingPass/src/dev/vale/highertyping/patterns.scala: -------------------------------------------------------------------------------- 1 | package dev.vale.highertyping 2 | 3 | import dev.vale.postparsing._ 4 | import dev.vale.postparsing.patterns.AtomSP 5 | import dev.vale.postparsing.patterns._ 6 | import dev.vale.postparsing._ 7 | import dev.vale.vimpl 8 | 9 | import scala.collection.immutable.List 10 | 11 | object PatternSUtils { 12 | def getRuneTypesFromPattern(pattern: AtomSP): Iterable[(IRuneS, ITemplataType)] = { 13 | val runesFromDestructures = 14 | pattern.destructure.toVector.flatten.flatMap(getRuneTypesFromPattern) 15 | (runesFromDestructures ++ pattern.coordRune.map(_.rune -> CoordTemplataType())).distinct 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /Frontend/HigherTypingPass/test/dev/vale/highertyping/HigherTypingTestCompilation.scala: -------------------------------------------------------------------------------- 1 | package dev.vale.highertyping 2 | 3 | import dev.vale.{FileCoordinateMap, Keywords, PackageCoordinate, Tests, _} 4 | import dev.vale.options.GlobalOptions 5 | 6 | object HigherTypingTestCompilation { 7 | def test(code: String*): HigherTypingCompilation = { 8 | val interner = new Interner() 9 | val keywords = new Keywords(interner) 10 | new HigherTypingCompilation( 11 | GlobalOptions.test(), 12 | interner, 13 | keywords, 14 | Vector(PackageCoordinate.TEST_TLD(interner, keywords)), 15 | FileCoordinateMap.test(interner, code.toVector) 16 | .or(Tests.getPackageToResourceResolver)) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Frontend/Highlighter/Highlighter.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Frontend/IntegrationTests/test/dev/vale/ArithmeticTestsA.scala: -------------------------------------------------------------------------------- 1 | package dev.vale 2 | 3 | import dev.vale.simplifying.VonHammer 4 | import dev.vale.finalast.YonderH 5 | import dev.vale.passmanager.FullCompilation 6 | import dev.vale.typing._ 7 | import dev.vale.typing.types.StrT 8 | import dev.vale.testvm.StructInstanceV 9 | import dev.vale.von.VonInt 10 | import dev.vale.{finalast => m} 11 | import org.scalatest.{FunSuite, Matchers} 12 | 13 | class ArithmeticTestsA extends FunSuite with Matchers { 14 | test("Dividing") { 15 | val compile = RunCompilation.test("exported func main() int { return 5 / 2; }") 16 | compile.evalForKind(Vector()) match { case VonInt(2) => } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Frontend/IntegrationTests/test/dev/vale/PrintTests.scala: -------------------------------------------------------------------------------- 1 | package dev.vale 2 | 3 | import org.scalatest._ 4 | 5 | class PrintTests extends FunSuite with Matchers { 6 | test("Println'ing an int") { 7 | val compile = RunCompilation.test( 8 | """ 9 | |import printutils.*; 10 | |exported func main() { 11 | | println(6); 12 | |} 13 | """.stripMargin) 14 | 15 | compile.evalForStdout(Vector()) shouldEqual "6\n" 16 | } 17 | 18 | test("Println'ing a bool") { 19 | val compile = RunCompilation.test( 20 | """ 21 | |import printutils.*; 22 | |exported func main() { 23 | | println(true); 24 | |} 25 | """.stripMargin) 26 | 27 | compile.evalForStdout(Vector()) shouldEqual "true\n" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Frontend/LexingPass/LexingPass.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Frontend/ParsingPass/src/dev/vale/parsing/Formatter.scala: -------------------------------------------------------------------------------- 1 | package dev.vale.parsing 2 | 3 | import dev.vale.vcurious 4 | import dev.vale.vimpl 5 | 6 | object Formatter { 7 | sealed trait IClass 8 | case object W extends IClass 9 | case object Ab extends IClass 10 | case object Ext extends IClass 11 | case object Fn extends IClass 12 | case object FnName extends IClass 13 | case object FnTplSep extends IClass 14 | case object Rune extends IClass 15 | 16 | sealed trait IElement 17 | object Span { 18 | def apply(classs: IClass, elements: IElement*): Span = { 19 | Span(classs, elements.toVector) 20 | } 21 | } 22 | case class Span(classs: IClass, elements: Vector[IElement]) extends IElement { override def equals(obj: Any): Boolean = vcurious(); override def hashCode(): Int = vcurious(); } 23 | case class Text(string: String) extends IElement { override def equals(obj: Any): Boolean = vcurious(); override def hashCode(): Int = vcurious(); } 24 | } 25 | -------------------------------------------------------------------------------- /Frontend/ParsingPass/test/dev/vale/parsing/AfterRegionsTests.scala: -------------------------------------------------------------------------------- 1 | package dev.vale.parsing 2 | 3 | import dev.vale.lexing.{BadExpressionEnd, BadStartOfStatementError, ForgotSetKeyword} 4 | import dev.vale.parsing.ast._ 5 | import dev.vale.{Collector, StrI} 6 | import org.scalatest._ 7 | 8 | class AfterRegionsTests extends FunSuite with Collector with TestParseUtils { 9 | 10 | test("Forgetting set when changing") { 11 | val error = 12 | compileStatement( 13 | """ship.x = 4;""".stripMargin).expectErr() 14 | error match { 15 | case ForgotSetKeyword(_) => 16 | } 17 | } 18 | 19 | test("Report leaving out semicolon or ending body after expression, for paren") { 20 | compileBlockContents( 21 | """ 22 | | a = 3; 23 | | set x = 7 ) 24 | """.stripMargin).expectErr() match { 25 | case BadExpressionEnd(_) => 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Frontend/ParsingPass/test/dev/vale/parsing/ParserTestCompilation.scala: -------------------------------------------------------------------------------- 1 | package dev.vale.parsing 2 | 3 | import dev.vale.options.GlobalOptions 4 | import dev.vale.{FileCoordinateMap, IPackageResolver, Interner, Keywords, PackageCoordinate} 5 | 6 | import scala.collection.immutable.Map 7 | 8 | object ParserTestCompilation { 9 | def test(interner: Interner, keywords: Keywords, code: String*): ParserCompilation = { 10 | val codeMap = FileCoordinateMap.test(interner, code.toVector) 11 | new ParserCompilation( 12 | GlobalOptions(true, true, true, true, true), 13 | interner, 14 | keywords, 15 | Vector(PackageCoordinate.TEST_TLD(interner, keywords)), 16 | new IPackageResolver[Map[String, String]]() { 17 | override def resolve(packageCoord: PackageCoordinate): Option[Map[String, String]] = { 18 | // For testing the parser, we dont want it to fetch things with import statements 19 | Some(codeMap.resolve(packageCoord).getOrElse(Map("" -> ""))) 20 | } 21 | }) 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Frontend/ParsingPass/test/dev/vale/parsing/functions/AfterRegionsFunctionTests.scala: -------------------------------------------------------------------------------- 1 | package dev.vale.parsing.functions 2 | 3 | import dev.vale.lexing.{BadFunctionBodyError, LightFunctionMustHaveParamTypes} 4 | import dev.vale.parsing._ 5 | import dev.vale.parsing.ast._ 6 | import dev.vale.{Collector, StrI, vassertOne, vimpl} 7 | import org.scalatest._ 8 | 9 | 10 | class AfterRegionsFunctionTests extends FunSuite with Collector with TestParseUtils { 11 | 12 | test("Func with func bound with missing 'where'") { 13 | // It parses that func moo as a templex, and apparently a return can be a templex 14 | compileDenizen("func sum() func moo(&T)void {3}").expectErr() match { 15 | case null => vimpl() 16 | } 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Frontend/PostParsingPass/test/dev/vale/postparsing/PostParserTestCompilation.scala: -------------------------------------------------------------------------------- 1 | package dev.vale.postparsing 2 | 3 | import dev.vale.{FileCoordinateMap, Interner, Keywords, PackageCoordinate} 4 | import dev.vale.options.GlobalOptions 5 | 6 | object PostParserTestCompilation { 7 | def test(code: String, interner: Interner = new Interner()): ScoutCompilation = { 8 | val keywords = new Keywords(interner) 9 | new ScoutCompilation( 10 | GlobalOptions(true, true, true, false, false), 11 | interner, 12 | keywords, 13 | Vector(PackageCoordinate.TEST_TLD(interner, keywords)), 14 | FileCoordinateMap.test(interner, Vector(code))) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Frontend/SimplifyingPass/test/dev/vale/simplifying/TestCompilation.scala: -------------------------------------------------------------------------------- 1 | package dev.vale.simplifying 2 | 3 | import dev.vale.options.GlobalOptions 4 | import dev.vale.{Builtins, FileCoordinateMap, Interner, Keywords, PackageCoordinate, Tests} 5 | 6 | import scala.collection.immutable.List 7 | 8 | object HammerTestCompilation { 9 | def test(code: String*): HammerCompilation = { 10 | val interner = new Interner() 11 | val keywords = new Keywords(interner) 12 | new HammerCompilation( 13 | interner, 14 | keywords, 15 | Vector(PackageCoordinate.BUILTIN(interner, keywords), PackageCoordinate.TEST_TLD(interner, keywords)), 16 | Builtins.getCodeMap(interner, keywords) 17 | .or(FileCoordinateMap.test(interner, code.toVector)) 18 | .or(Tests.getPackageToResourceResolver), 19 | HammerCompilationOptions()) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Frontend/Solver/Solver.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Frontend/TestVM/TestVM.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Frontend/Tests/Tests.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/array/drop_into/drop_into.vale: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValeLang/Vale/6fb98324c0b919a55812376f4d74cfcbfc7f2db7/Frontend/Tests/test/main/resources/array/drop_into/drop_into.vale -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/array/each/each.vale: -------------------------------------------------------------------------------- 1 | 2 | func each(arr &[#N]T, func &F) void 3 | where func(&F,&T)void { 4 | i = 0; 5 | l = len(&arr); 6 | while (i < l) { 7 | func(arr[i]); 8 | set i = i + 1; 9 | } 10 | } 11 | 12 | func eachI(arr &[#N]T, func F) void 13 | where func drop(F)void, func(&F,int,&T)void { 14 | i = 0; 15 | l = len(&arr); 16 | while (i < l) { 17 | func(i, arr[i]); 18 | set i = i + 1; 19 | } 20 | } 21 | 22 | func each(arr &[]T, func F) void 23 | where func drop(F)void, func(&F,&T)void { 24 | i = 0; 25 | l = len(&arr); 26 | while (i < l) { 27 | func(arr[i]); 28 | set i = i + 1; 29 | } 30 | } 31 | 32 | func eachI(arr &[]T, func F) void 33 | where func drop(F)void, func(&F,int,&T)void { 34 | i = 0; 35 | l = len(&arr); 36 | while (i < l) { 37 | func(i, arr[i]); 38 | set i = i + 1; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/array/has/has.vale: -------------------------------------------------------------------------------- 1 | 2 | func has(arr &[]E, elem &E, equator &F) bool 3 | where func(&F, &E, &E)bool { 4 | i = 0; 5 | while (i < arr.len()) { 6 | if (equator(arr[i], elem)) { 7 | return true; 8 | } 9 | set i = i + 1; 10 | } 11 | return false; 12 | } 13 | 14 | func has(arr &[]E, elem &E) bool 15 | where func ==(&E, &E)bool { 16 | has(arr, elem, { _ == _ }) 17 | } 18 | 19 | func has(seq &[#N]E, elem &E, equator &F) bool 20 | where func(&F, &E, &E)bool { 21 | i = 0; 22 | while (i < seq.len()) { 23 | if (equator(seq[i], elem)) { 24 | return true; 25 | } 26 | set i = i + 1; 27 | } 28 | return false; 29 | } 30 | 31 | func has(seq &[#N]E, elem &E) bool 32 | where func ==(&E, &E)bool { 33 | return has(seq, elem, { _ == _ }); 34 | } 35 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/array/indices/indices.vale: -------------------------------------------------------------------------------- 1 | 2 | func indices<>(arr []<_>_) []int { 3 | MakeImmArray(len(arr), {_}) 4 | } 5 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/array/iter/iter.vale: -------------------------------------------------------------------------------- 1 | 2 | struct StaticSizedArrayReadonlyIter where E Ref { 3 | arr &[#N]E; 4 | pos! int; 5 | } 6 | func begin(arr &[#N]E) 7 | StaticSizedArrayReadonlyIter { 8 | StaticSizedArrayReadonlyIter(arr, 0) 9 | } 10 | func next(iter &StaticSizedArrayReadonlyIter) Opt<&E> { 11 | if iter.pos < iter.arr.len() { 12 | Some<&E>(&iter.arr[set iter.pos = iter.pos + 1]) 13 | } else { 14 | None<&E>() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/castutils/castutils.vale: -------------------------------------------------------------------------------- 1 | 2 | func str(b bool) str { 3 | return if (b) { "true" } else { "false" }; 4 | } 5 | 6 | func +(i int, s str) str { 7 | return str(i) + s; 8 | } 9 | 10 | func +(s str, i int) str { 11 | return s + str(i); 12 | } 13 | 14 | func +(s str, b bool) str { 15 | return s + str(b); 16 | } 17 | 18 | func +(b bool, s str) str { 19 | return str(b) + s; 20 | } 21 | 22 | func +(f float, s str) str { 23 | return str(f) + s; 24 | } 25 | 26 | func +(s str, f float) str { 27 | return s + str(f); 28 | } 29 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/ifunction/ifunction1/ifunction1.vale: -------------------------------------------------------------------------------- 1 | 2 | interface IFunction1 M { 3 | func __call(virtual self &IFunction1, p1 P1) R; 4 | } 5 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/intrange/intrange.vale: -------------------------------------------------------------------------------- 1 | 2 | func range(begin int, end int) IntRange { return IntRange(begin, end); } 3 | struct IntRange { begin int; end int; } 4 | func begin(self &IntRange) IntRangeIter { return IntRangeIter(self, self.begin); } 5 | struct IntRangeIter { range &IntRange; i! int; } 6 | func next(self &IntRangeIter) Opt { 7 | if self.i < self.range.end { 8 | Some(set self.i = self.i + 1) 9 | } else { 10 | None() 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/ioutils/ioutils.vale: -------------------------------------------------------------------------------- 1 | 2 | func getch() int { __getch() } 3 | extern func __getch() int; 4 | 5 | extern func stdinReadInt() int; 6 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/listprintutils/listprintutils.vale: -------------------------------------------------------------------------------- 1 | 2 | func println(list &List) 3 | where func print(&E)void { 4 | print("["); 5 | l = len(list); 6 | foreach i in 0..l { 7 | if i > 0 { 8 | print(", "); 9 | } 10 | print(list.get(i)); 11 | } 12 | println("]"); 13 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/logic/logic.vale: -------------------------------------------------------------------------------- 1 | 2 | func !=(a &T, b &T) bool 3 | where func ==(&T, &T)bool { 4 | return not (a == b); 5 | } 6 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/math/math.vale: -------------------------------------------------------------------------------- 1 | 2 | func min(a int, b int) int { 3 | return if (a <= b) { a } else { b }; 4 | } 5 | 6 | func max(a int, b int) int { 7 | return if (a >= b) { a } else { b }; 8 | } 9 | 10 | func abs(a int) int { 11 | return if (a < 0) { a * -1 } else { a }; 12 | } 13 | 14 | func signum(a int) int { 15 | return if (a < 0) { -1 } 16 | else if (a > 0) { 1 } 17 | else { 0 }; 18 | } 19 | 20 | extern func sqrt(x float) float; 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/optutils/optutils.vale: -------------------------------------------------------------------------------- 1 | 2 | abstract func getOr(virtual opt &Opt, default T) T; 3 | func getOr(opt &None, default T) T { 4 | return default; 5 | } 6 | func getOr(opt &Some, default T) T { 7 | return opt.value; 8 | } 9 | 10 | abstract func map(virtual opt &Opt, func &IFunction1) Opt; 11 | func map(opt &None, func &IFunction1) Opt { 12 | return None(); 13 | } 14 | func map(opt &Some, func &IFunction1) Opt { 15 | return Some(func(opt.value)); 16 | } 17 | 18 | abstract func len(virtual opt &Opt) int; 19 | func len(opt &None) int { return 0; } 20 | func len(opt &Some) int { return 1; } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/panicutils/panicutils.vale: -------------------------------------------------------------------------------- 1 | import printutils.*; 2 | import v.builtins.panicutils.*; 3 | import v.builtins.logic.*; 4 | 5 | func __pretend() T { __vbi_panic() } 6 | 7 | func vassert(cond bool) { 8 | vassert(cond, "Assertion failed!"); 9 | } 10 | func vassert(cond bool, msg str) { 11 | if (cond == false) { 12 | println(msg); 13 | __vbi_panic(); 14 | } 15 | } 16 | 17 | func vassertEq(a T, b T) void 18 | where func ==(T, T)bool { 19 | vassert(==(a, b), "Assertion failed, not equal!"); 20 | } 21 | 22 | func vassertEq(a T, b T, msg str) void 23 | where func ==(T, T)bool { 24 | vassert(==(a, b), msg); 25 | } 26 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/printutils/printutils.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.print.*; 2 | import v.builtins.str.*; 3 | import castutils.*; 4 | 5 | func println(s str) void { 6 | print(s + "\n"); 7 | } 8 | 9 | func println(i int) void { 10 | print(str(i) + "\n"); 11 | } 12 | 13 | func println(b bool) void { 14 | print(str(b) + "\n"); 15 | } 16 | 17 | func println(f float) void { 18 | print(str(f) + "\n"); 19 | } 20 | 21 | func print(i int) void { 22 | print(str(i)); 23 | } 24 | 25 | func print(b bool) void { 26 | print(str(b)); 27 | } 28 | 29 | func print(f float) void { 30 | print(str(f)); 31 | } 32 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/add64ret.vale: -------------------------------------------------------------------------------- 1 | exported func main() i64 { 2 | // Tests that i32 overflows as expected 3 | if ((2000000042 * 7) / 7 - 2000000000 == 42) { 4 | return 73i64; 5 | } 6 | // Tests that i64 does not 7 | // Should result in 42 8 | return (2000000042i64 * 7i64) / 7i64 - 2000000000i64; 9 | } 10 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/addret.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | 3 + 4 3 | } 4 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/inlssaimm.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | a = #[#](23, 31, 42); 3 | return a.2; 4 | } 5 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/rsaimm.vale: -------------------------------------------------------------------------------- 1 | // immutable runtime-size-array 2 | 3 | exported func main() int { 4 | a = #[]int(5, {_}); 5 | return a[3]; 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/rsaimmfromcallable.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | i = 3; 4 | a = #[]int(5, &{_ * 42}); 5 | return a[1]; 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/rsaimmlen.vale: -------------------------------------------------------------------------------- 1 | // immutable runtime-size-array length 2 | 3 | exported func main() int { 4 | a = MakeImmArray(5, {_}); 5 | return len(a); 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/rsamut.vale: -------------------------------------------------------------------------------- 1 | // mutable runtime-size-array 2 | 3 | struct MyIntIdentity {} 4 | func __call(this &MyIntIdentity, i int) int { i } 5 | 6 | exported func main() int { 7 | a = Array(5, &MyIntIdentity()); 8 | return a[3]; 9 | } 10 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/rsamutcapacity.vale: -------------------------------------------------------------------------------- 1 | // immutable runtime-size-array length 2 | 3 | exported func main() int { 4 | a = Array(42); 5 | a.push(7); 6 | return capacity(&a); 7 | } 8 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/rsamutdestroyintocallable.vale: -------------------------------------------------------------------------------- 1 | struct Spaceship { fuel int; } 2 | exported func main() int { 3 | a = Array(3, &{Spaceship(13 + _)}); 4 | sum = 0; 5 | drop_into(a, &(e) => { set sum = sum + e.fuel; }); 6 | return sum; 7 | } 8 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/rsamutfromcallable.vale: -------------------------------------------------------------------------------- 1 | 2 | import array.make.*; 3 | exported func main() int { 4 | i = 3; 5 | a = []int(5, x => x * 42); 6 | return a[1]; 7 | } 8 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/rsamutlen.vale: -------------------------------------------------------------------------------- 1 | // immutable runtime-size-array length 2 | 3 | exported func main() int { 4 | a = Array(5, {_}); 5 | return len(&a); 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/ssaimmfromcallable.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | i = 3; 4 | a = #[#5](&{_ * 42}); 5 | return a[1]; 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/ssaimmfromvalues.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | a = #[#](23, 31, 37, 42, 49); 4 | return a.3; 5 | } 6 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/ssamutdestroyintocallable.vale: -------------------------------------------------------------------------------- 1 | struct Spaceship { fuel int; } 2 | exported func main() int { 3 | a = [#](Spaceship(13), Spaceship(14), Spaceship(15)); 4 | sum = 0; 5 | drop_into(a, &(e) => { set sum = sum + e.fuel; }); 6 | return sum; 7 | } 8 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/ssamutfromcallable.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | i = 3; 4 | a = [#5](&{_ * 42}); 5 | return a[1]; 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/ssamutfromvalues.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | a = [#](23, 31, 37, 42, 49); 4 | return a.3; 5 | } 6 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/arrays/swaprsamutdestroy.vale: -------------------------------------------------------------------------------- 1 | 2 | struct Goblin { } 3 | 4 | struct GoblinMaker {} 5 | func __call(this &GoblinMaker, i int) Goblin { Goblin() } 6 | 7 | exported func main() int { 8 | m = GoblinMaker(); 9 | arr = Array(1, &m); 10 | set arr.0 = Goblin(); 11 | return 42; 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/borrowRef.vale: -------------------------------------------------------------------------------- 1 | 2 | 3 | struct Carrier { 4 | hp int; 5 | interceptors int; 6 | } 7 | 8 | exported func main() int { 9 | carrier = Carrier(400, 8); 10 | ref = &carrier; 11 | return ref.interceptors; 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/comparei64.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | return if (1i64 >= 4294967296i64) { 73 } else { 42 }; 4 | } 5 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/concatstrfloat.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | matches = streq("hello" + str(42.25), 0, 10, "hello42.25", 0, 10); 3 | return if (matches) { 42 } else { 73 }; 4 | } 5 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/constraintRef.vale: -------------------------------------------------------------------------------- 1 | struct Carrier { 2 | hp int; 3 | interceptors int; 4 | } 5 | 6 | exported func main() int { 7 | carrier = Carrier(400, 8); 8 | ref = &carrier; 9 | return ref.interceptors; 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/destructure_restackify.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.arith.*; 2 | struct Spaceship { fuel int; } 3 | struct FooResult { fuel int; ship Spaceship; } 4 | func foo(ship Spaceship) FooResult { 5 | return FooResult(ship.fuel, ship); 6 | } 7 | exported func main() int { 8 | ship = Spaceship(42); 9 | [fuel, set ship] = foo(ship); 10 | [zzz] = ship; 11 | return fuel; 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/downcast/downcastBorrowFailed.vale: -------------------------------------------------------------------------------- 1 | 2 | sealed interface IShip {} 3 | 4 | struct Serenity {} 5 | impl IShip for Serenity; 6 | 7 | struct Raza { fuel int; } 8 | impl IShip for Raza; 9 | 10 | func moo(ship IShip) int { 11 | maybeRaza Result<&Raza, &IShip> = ship.as(); 12 | return if (maybeRaza.is_ok()) { 13 | maybeRaza.expect("wat").fuel 14 | } else { 15 | 42 16 | }; 17 | } 18 | exported func main() int { 19 | moo(Serenity()) 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/downcast/downcastBorrowSuccessful.vale: -------------------------------------------------------------------------------- 1 | 2 | sealed interface IShip {} 3 | 4 | struct Serenity {} 5 | impl IShip for Serenity; 6 | 7 | struct Raza { fuel int; } 8 | impl IShip for Raza; 9 | 10 | func moo(ship IShip) int { 11 | maybeRaza Result<&Raza, &IShip> = ship.as(); 12 | return if (maybeRaza.is_ok()) { 13 | maybeRaza.expect("wat").fuel 14 | } else { 15 | 72 16 | }; 17 | } 18 | exported func main() int { 19 | moo(Raza(42)) 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/downcast/downcastOwningFailed.vale: -------------------------------------------------------------------------------- 1 | 2 | sealed interface IShip {} 3 | 4 | struct Serenity {} 5 | impl IShip for Serenity; 6 | 7 | struct Raza { fuel int; } 8 | impl IShip for Raza; 9 | 10 | func moo(ship IShip) int { 11 | maybeRaza Result = (ship).as(); 12 | return if (maybeRaza.is_ok()) { 13 | maybeRaza.expect("wat").fuel 14 | } else { 15 | 42 16 | }; 17 | } 18 | exported func main() int { 19 | return moo(Serenity()); 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/downcast/downcastOwningSuccessful.vale: -------------------------------------------------------------------------------- 1 | 2 | sealed interface IShip {} 3 | 4 | struct Serenity {} 5 | impl IShip for Serenity; 6 | 7 | struct Raza { fuel int; } 8 | impl IShip for Raza; 9 | 10 | func moo(ship IShip) int { 11 | maybeRaza Result = (ship).as(); 12 | return if (maybeRaza.is_ok()) { 13 | maybeRaza.expect("wat").fuel 14 | } else { 15 | 72 16 | }; 17 | } 18 | exported func main() int { 19 | return moo(Raza(42)); 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/downcast/downcastPointerFailed.vale: -------------------------------------------------------------------------------- 1 | 2 | sealed interface IShip {} 3 | 4 | struct Serenity {} 5 | impl IShip for Serenity; 6 | 7 | struct Raza { fuel int; } 8 | impl IShip for Raza; 9 | 10 | func moo(ship IShip) int { 11 | maybeRaza Result<&Raza, &IShip> = (&ship).as(); 12 | return if (maybeRaza.is_ok()) { 13 | maybeRaza.expect("wat").fuel 14 | } else { 15 | 42 16 | }; 17 | } 18 | exported func main() int { 19 | return moo(Serenity()); 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/downcast/downcastPointerSuccess.vale: -------------------------------------------------------------------------------- 1 | 2 | sealed interface IShip {} 3 | 4 | struct Serenity {} 5 | impl IShip for Serenity; 6 | 7 | struct Raza { fuel int; } 8 | impl IShip for Raza; 9 | 10 | func moo(ship IShip) int { 11 | maybeRaza Result<&Raza, &IShip> = (&ship).as(); 12 | return if (maybeRaza.is_ok()) { 13 | maybeRaza.expect("wat").fuel 14 | } else { 15 | 72 16 | }; 17 | } 18 | exported func main() int { 19 | return moo(Raza(42)); 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/README.txt: -------------------------------------------------------------------------------- 1 | See EAET for how these tests are organized. -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/export.vale: -------------------------------------------------------------------------------- 1 | exported func moo() { 2 | 42 3 | } 4 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/extern.vale: -------------------------------------------------------------------------------- 1 | 2 | import math.*; 3 | 4 | exported func main() int { 5 | return int(sqrt(float(16))); 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmparamdeepexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "vtest/Engine.h" 6 | #include "vtest/Spaceship.h" 7 | #include "vtest/Seaship.h" 8 | #include "vtest/IShip.h" 9 | #include "vtest/cGetShipFuel.h" 10 | #include "vtest/valeGetShipFuel.h" 11 | 12 | extern ValeInt vtest_cGetShipFuel(vtest_IShip s) { 13 | return vtest_valeGetShipFuel(s); 14 | } 15 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmparamdeepexport/test.vale: -------------------------------------------------------------------------------- 1 | exported struct Engine imm { fuel int; } 2 | 3 | sealed exported interface IShip imm { } 4 | 5 | exported struct Spaceship imm { engine Engine; } 6 | impl IShip for Spaceship; 7 | 8 | exported struct Seaship imm { unused int; } 9 | impl IShip for Seaship; 10 | 11 | abstract func getFuel(virtual this IShip) int; 12 | func getFuel(this Spaceship) int { this.engine.fuel } 13 | func getFuel(this Seaship) int { return 0; } 14 | 15 | exported func valeGetShipFuel(s IShip) int { 16 | return s.getFuel(); 17 | } 18 | 19 | extern func cGetShipFuel(s IShip) int; 20 | 21 | exported func main() int { 22 | cGetShipFuel(Spaceship(Engine(42))) 23 | } 24 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmparamdeepextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "vtest/Engine.h" 6 | #include "vtest/Spaceship.h" 7 | #include "vtest/Seaship.h" 8 | #include "vtest/IShip.h" 9 | #include "vtest/cGetShipFuel.h" 10 | 11 | ValeInt vtest_cGetShipFuel(vtest_IShip s) { 12 | ValeInt result = 0; 13 | switch (s.type) { 14 | case vtest_IShip_Type_Seaship: { 15 | vtest_Seaship* ship = (vtest_Seaship*)s.obj; 16 | result = ship->engine->leftFuel + ship->engine->rightFuel; 17 | break; 18 | } 19 | case vtest_IShip_Type_Spaceship: { 20 | vtest_Spaceship* ship = (vtest_Spaceship*)s.obj; 21 | result = ship->fuel; 22 | break; 23 | } 24 | default: 25 | exit(1); 26 | } 27 | free(s.obj); 28 | return result; 29 | } 30 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmparamdeepextern/test.vale: -------------------------------------------------------------------------------- 1 | exported struct Engine imm { leftFuel int; rightFuel int; } 2 | 3 | sealed exported interface IShip imm { } 4 | 5 | exported struct Spaceship imm { fuel int; } 6 | impl IShip for Spaceship; 7 | 8 | exported struct Seaship imm { engine Engine; } 9 | impl IShip for Seaship; 10 | 11 | extern func cGetShipFuel(s IShip) int; 12 | 13 | exported func main() int { 14 | x IShip = Spaceship(7); // to force the above impl to happen 15 | cGetShipFuel(Seaship(Engine(37, 5))) 16 | } 17 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmparamexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "vtest/Spaceship.h" 6 | #include "vtest/Seaship.h" 7 | #include "vtest/IShip.h" 8 | #include "vtest/cGetShipFuel.h" 9 | #include "vtest/valeGetShipFuel.h" 10 | 11 | extern ValeInt vtest_cGetShipFuel(vtest_IShip s) { 12 | return vtest_valeGetShipFuel(s); 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmparamexport/test.vale: -------------------------------------------------------------------------------- 1 | sealed exported interface IShip imm { } 2 | 3 | exported struct Spaceship imm { fuel int; } 4 | impl IShip for Spaceship; 5 | 6 | exported struct Seaship imm { leftFuel int; rightFuel int; } 7 | impl IShip for Seaship; 8 | 9 | abstract func getFuel(virtual this IShip) int; 10 | func getFuel(this Spaceship) int { this.fuel } 11 | func getFuel(this Seaship) int { this.leftFuel + this.rightFuel } 12 | 13 | exported func valeGetShipFuel(s IShip) int { 14 | return s.getFuel(); 15 | } 16 | 17 | extern func cGetShipFuel(s IShip) int; 18 | 19 | exported func main() int { 20 | x IShip = Spaceship(7); // to force the above impl to happen 21 | cGetShipFuel(Seaship(37, 5)) 22 | } 23 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmparamextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "vtest/Spaceship.h" 6 | #include "vtest/Seaship.h" 7 | #include "vtest/IShip.h" 8 | #include "vtest/cGetShipFuel.h" 9 | 10 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 11 | int64_t incrementIntFile(const char* filename); 12 | 13 | ValeInt vtest_cGetShipFuel(vtest_IShip s) { 14 | int runNumber = incrementIntFile("myfile.bin"); 15 | ValeInt result = 0; 16 | switch (s.type) { 17 | case vtest_IShip_Type_Seaship: { 18 | vtest_Seaship* ship = (vtest_Seaship*)s.obj; 19 | result = (ship->leftFuel + ship->rightFuel) * runNumber; 20 | break; 21 | } 22 | case vtest_IShip_Type_Spaceship: { 23 | vtest_Spaceship* ship = (vtest_Spaceship*)s.obj; 24 | result = ship->fuel * runNumber; 25 | break; 26 | } 27 | default: 28 | exit(1); 29 | } 30 | free(s.obj); 31 | return result; 32 | } 33 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmparamextern/test.vale: -------------------------------------------------------------------------------- 1 | sealed exported interface IShip imm { } 2 | 3 | exported struct Spaceship imm { fuel int; } 4 | impl IShip for Spaceship; 5 | 6 | exported struct Seaship imm { leftFuel int; rightFuel int; } 7 | impl IShip for Seaship; 8 | 9 | extern func cGetShipFuel(s IShip) int; 10 | 11 | exported func main() int { 12 | x IShip = Spaceship(7); // to force the above impl to happen 13 | cGetShipFuel(Seaship(37, 5)) 14 | } 15 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmreturnexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "vtest/IShip.h" 6 | #include "vtest/Firefly.h" 7 | #include "vtest/cMakeShip.h" 8 | #include "vtest/valeMakeShip.h" 9 | 10 | extern vtest_IShip vtest_cMakeShip() { 11 | return vtest_valeMakeShip(); 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmreturnexport/test.vale: -------------------------------------------------------------------------------- 1 | exported sealed interface IShip imm { } 2 | abstract func getFuel(virtual ship &IShip) int; 3 | 4 | exported struct Firefly imm { fuel int; } 5 | impl IShip for Firefly; 6 | func getFuel(ship Firefly) int { ship.fuel } 7 | 8 | exported func valeMakeShip() IShip { 9 | Firefly(42) 10 | } 11 | 12 | extern func cMakeShip() IShip; 13 | 14 | exported func main() int { 15 | res = cMakeShip(); 16 | return getFuel(&res); 17 | } 18 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmreturnextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "vtest/IShip.h" 6 | #include "vtest/Firefly.h" 7 | #include "vtest/cMakeShip.h" 8 | 9 | vtest_IShip vtest_cMakeShip() { 10 | vtest_Firefly* firefly = (vtest_Firefly*)malloc(sizeof(vtest_Firefly)); 11 | firefly->fuel = 42; 12 | 13 | // If the enum isnt 64 bits, we run into some undefined padding when there 14 | // are only 1 or 2 values in the enum. 15 | // Oddly, when we have 3 values in the enum, the problem disappears. 16 | // Anyway, we generate a vtest_IShip_Type_MAX_VALUE = 0x7FFFFFFFFFFFFFFF to 17 | // force this and fix it for good. 18 | // This assert is to check that it's 64 bits even though there's only one 19 | // entry in the enum. 20 | // Nevermind, it doesn't work for windows! 21 | 22 | vtest_IShip shipRef; 23 | shipRef.obj = firefly; 24 | shipRef.type = vtest_IShip_Type_Firefly; 25 | 26 | return shipRef; 27 | } 28 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfaceimmreturnextern/test.vale: -------------------------------------------------------------------------------- 1 | exported sealed interface IShip imm { } 2 | abstract func getFuel(virtual ship &IShip) int; 3 | 4 | exported struct Firefly imm { fuel int; } 5 | impl IShip for Firefly; 6 | func getFuel(ship Firefly) int { ship.fuel } 7 | 8 | extern func cMakeShip() IShip; 9 | 10 | exported func main() int { 11 | x IShip = Firefly(7); // to force the above impl to happen 12 | res = cMakeShip(); 13 | return getFuel(&res); 14 | } 15 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfacemutparamexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "vtest/Spaceship.h" 6 | #include "vtest/Seaship.h" 7 | #include "vtest/IShip.h" 8 | #include "vtest/valeGetShipFuel.h" 9 | #include "vtest/cGetTripleShipFuel.h" 10 | 11 | ValeInt vtest_cGetTripleShipFuel(vtest_IShipRef s) { 12 | return vtest_valeGetShipFuel(s) * 3; 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfacemutparamexport/test.vale: -------------------------------------------------------------------------------- 1 | sealed exported interface IShip { } 2 | 3 | exported struct Spaceship { fuel int; } 4 | impl IShip for Spaceship; 5 | 6 | exported struct Seaship { leftFuel int; rightFuel int; } 7 | impl IShip for Seaship; 8 | 9 | abstract func getShipFuelInner(virtual s &IShip) int; 10 | func getShipFuelInner(s &Spaceship) int { s.fuel } 11 | func getShipFuelInner(s &Seaship) int { s.leftFuel + s.rightFuel } 12 | 13 | exported func valeGetShipFuel(s &IShip) int { 14 | getShipFuelInner(s) 15 | } 16 | 17 | extern func cGetTripleShipFuel(s &IShip) int; 18 | 19 | exported func main() int { 20 | cGetTripleShipFuel(&Seaship(9, 5)) 21 | } 22 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfacemutreturnexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "vtest/IShip.h" 6 | #include "vtest/runExtCommand.h" 7 | #include "vtest/makeFirefly.h" 8 | 9 | vtest_IShipRef vtest_runExtCommand() { 10 | return vtest_makeFirefly(42); 11 | } 12 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/interfacemutreturnexport/test.vale: -------------------------------------------------------------------------------- 1 | exported interface IShip { 2 | func getFuel(virtual ship &IShip) int; 3 | } 4 | exported struct Firefly { 5 | fuel int; 6 | } 7 | impl IShip for Firefly; 8 | func getFuel(ship &Firefly) int { ship.fuel } 9 | 10 | exported func makeFirefly(fuel int) IShip { 11 | Firefly(fuel) 12 | } 13 | 14 | extern func runExtCommand() IShip; 15 | 16 | exported func main() int { 17 | res = runExtCommand(); 18 | return getFuel(&res); 19 | } 20 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/replayprint/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "vtest/runExtCommand.h" 6 | 7 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 8 | int64_t incrementIntFile(const char* filename); 9 | 10 | ValeInt vtest_runExtCommand() { 11 | int runNumber = incrementIntFile("myfile.bin"); 12 | 13 | return 42 * runNumber; 14 | } 15 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/replayprint/test.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.print.*; 2 | 3 | extern func runExtCommand() int; 4 | 5 | exported func main() int { 6 | result = runExtCommand(); 7 | 8 | // The test should --replay_whitelist_extern=stdlib.printstr, which means this call will go 9 | // through even in replay mode. 10 | print("Howdy!\n"); 11 | 12 | return result; 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsaimmparamdeepexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "vtest/Spaceship.h" 6 | #include "vtest/ImmSpaceshipArray.h" 7 | #include "vtest/cSumFuel.h" 8 | #include "vtest/valeSumFuel.h" 9 | 10 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 11 | int64_t incrementIntFile(const char* filename); 12 | 13 | extern ValeInt vtest_cSumFuel(vtest_ImmSpaceshipArray* arr) { 14 | int runNumber = incrementIntFile("myfile.bin"); 15 | 16 | return vtest_valeSumFuel(arr) * runNumber; 17 | } 18 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsaimmparamdeepexport/test.vale: -------------------------------------------------------------------------------- 1 | exported struct Spaceship imm { 2 | fuel int; 3 | wings int; 4 | } 5 | 6 | export []Spaceship as ImmSpaceshipArray; 7 | 8 | exported func valeSumFuel(arr []Spaceship) int { 9 | total = 0; 10 | i = 0; 11 | while (i < arr.len()) { 12 | set total = total + arr[i].fuel; 13 | set i = i + 1; 14 | } 15 | return total; 16 | } 17 | 18 | extern func cSumFuel(arr []Spaceship) int; 19 | 20 | exported func main() int { 21 | a = #[]Spaceship(3, (i) => { Spaceship(13 + i, i * 2) }); 22 | return cSumFuel(a); 23 | } 24 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsaimmparamdeepextern/test.vale: -------------------------------------------------------------------------------- 1 | exported struct Spaceship imm { 2 | fuel int; 3 | wings int; 4 | } 5 | 6 | export []Spaceship as ImmSpaceshipArray; 7 | 8 | extern func cSumFuel_vasp(arr []Spaceship) int; 9 | 10 | exported func main() int { 11 | a = #[]Spaceship(5, (i) => { Spaceship(i * 2, 7) }); 12 | return cSumFuel_vasp(a); 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsaimmparamexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "vtest/ImmIntArray.h" 4 | #include "vtest/expSumBytes.h" 5 | 6 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 7 | int64_t incrementIntFile(const char* filename); 8 | 9 | ValeInt vtest_extSumBytes(vtest_ImmIntArray* arr) { 10 | int runNumber = incrementIntFile("myfile.bin"); 11 | 12 | return vtest_expSumBytes(arr) * runNumber; 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsaimmparamexport/test.vale: -------------------------------------------------------------------------------- 1 | export []int as ImmIntArray; 2 | 3 | func range(begin int, end int) IntRange { return IntRange(begin, end); } 4 | struct IntRange { begin int; end int; } 5 | func begin(self &IntRange) IntRangeIter { return IntRangeIter(&self, self.begin); } 6 | struct IntRangeIter { range &IntRange; i! int; } 7 | func next(self &IntRangeIter) Opt { 8 | if self.i < self.range.end { 9 | Some(set self.i = self.i + 1) 10 | } else { 11 | None() 12 | } 13 | } 14 | 15 | exported func expSumBytes(arr []int) int { 16 | sum = 0; 17 | l = len(arr); 18 | foreach i in 0..l { set sum = sum + arr[i]; } 19 | return sum; 20 | } 21 | 22 | extern func extSumBytes(arr []int) int; 23 | 24 | exported func main() int { 25 | a = #[]int(5, {_}); 26 | return extSumBytes(a); 27 | } 28 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsaimmparamextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "vtest/ImmIntArray.h" 4 | 5 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 6 | int64_t incrementIntFile(const char* filename); 7 | 8 | ValeInt vtest_sumBytes(vtest_ImmIntArray* arr) { 9 | int runNumber = incrementIntFile("myfile.bin"); 10 | 11 | ValeInt total = 0; 12 | for (int i = 0; i < arr->length; i++) { 13 | total += arr->elements[i]; 14 | } 15 | free(arr); 16 | return total * runNumber; 17 | } 18 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsaimmparamextern/test.vale: -------------------------------------------------------------------------------- 1 | export []int as ImmIntArray; 2 | 3 | extern func sumBytes(arr []int) int; 4 | 5 | exported func main() int { 6 | a = #[]int(5, {_}); 7 | return sumBytes(a); 8 | } 9 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsaimmreturnexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "vtest/ImmIntArray.h" 5 | #include "vtest/valeMakeRSA.h" 6 | #include "vtest/cMakeRSA.h" 7 | 8 | vtest_ImmIntArray* vtest_cMakeRSA() { 9 | return vtest_valeMakeRSA(); 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsaimmreturnexport/test.vale: -------------------------------------------------------------------------------- 1 | 2 | export []int as ImmIntArray; 3 | 4 | exported func valeMakeRSA() []int { 5 | ssa = #[#](5, 7, 9, 10, 11); 6 | return #[]int(ssa.len(), { ssa[_] }); 7 | } 8 | 9 | extern func cMakeRSA() []int; 10 | 11 | exported func main() int { 12 | arr = cMakeRSA(); 13 | i = 0; 14 | total = 0; 15 | while (i < arr.len()) { 16 | set total = total + arr[i]; 17 | set i = i + 1; 18 | } 19 | return total; 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsaimmreturnextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "vtest/ImmIntArray.h" 5 | #include "vtest/cMakeRSA.h" 6 | 7 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 8 | int64_t incrementIntFile(const char* filename); 9 | 10 | vtest_ImmIntArray* vtest_cMakeRSA() { 11 | int runNumber = incrementIntFile("myfile.bin"); 12 | 13 | vtest_ImmIntArray* arr = malloc(sizeof(vtest_ImmIntArray) + sizeof(ValeInt) * 5); 14 | arr->length = 5; 15 | arr->elements[0] = 5 * runNumber; 16 | arr->elements[1] = 7 * runNumber; 17 | arr->elements[2] = 9 * runNumber; 18 | arr->elements[3] = 10 * runNumber; 19 | arr->elements[4] = 11 * runNumber; 20 | return arr; 21 | } 22 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsaimmreturnextern/test.vale: -------------------------------------------------------------------------------- 1 | 2 | export []int as ImmIntArray; 3 | 4 | extern func cMakeRSA() []int; 5 | 6 | exported func main() int { 7 | arr = cMakeRSA(); 8 | i = 0; 9 | total = 0; 10 | while (i < arr.len()) { 11 | set total = total + arr[i]; 12 | set i = i + 1; 13 | } 14 | return total; 15 | } 16 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsamutparamexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "vtest/MutIntArray.h" 4 | #include "vtest/getMutIntArrayLen.h" 5 | #include "vtest/getMutIntArrayElem.h" 6 | 7 | ValeInt vtest_sumBytes(vtest_MutIntArrayRef arr) { 8 | ValeInt total = 0; 9 | ValeInt len = vtest_getMutIntArrayLen(arr); 10 | for (int i = 0; i < len; i++) { 11 | ValeInt elem = vtest_getMutIntArrayElem(arr, i); 12 | total += elem; 13 | } 14 | return total; 15 | } 16 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsamutparamexport/test.vale: -------------------------------------------------------------------------------- 1 | export []int as MutIntArray; 2 | 3 | extern func sumBytes(arr &[]int) int; 4 | exported func getMutIntArrayLen(arr &[]int) int { len(&arr) } 5 | exported func getMutIntArrayElem(arr &[]int, i int) int { arr[i] } 6 | 7 | exported func main() int { 8 | a = Array(5, {_}); 9 | return sumBytes(&a); 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsamutreturnexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "vtest/MutIntArray.h" 5 | #include "vtest/valeMakeRSA.h" 6 | #include "vtest/cMakeRSA.h" 7 | 8 | vtest_MutIntArrayRef vtest_cMakeRSA() { 9 | return vtest_valeMakeRSA(); 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/rsamutreturnexport/test.vale: -------------------------------------------------------------------------------- 1 | 2 | export []int as MutIntArray; 3 | 4 | exported func valeMakeRSA() []int { 5 | ssa = #[#](5, 7, 9, 10, 11); 6 | return Array(ssa.len(), { ssa[_] }); 7 | } 8 | 9 | extern func cMakeRSA() []int; 10 | 11 | exported func main() int { 12 | arr = cMakeRSA(); 13 | i = 0; 14 | total = 0; 15 | while (i < arr.len()) { 16 | set total = total + arr[i]; 17 | set i = i + 1; 18 | } 19 | return total; 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/simpleexternparam/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "vtest/myCFunc.h" 7 | 8 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 9 | int64_t incrementIntFile(const char* filename); 10 | 11 | extern ValeInt vtest_myCFunc(ValeInt x) { 12 | int runNumber = incrementIntFile("myfile.bin"); 13 | return x * runNumber; 14 | } 15 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/simpleexternparam/test.vale: -------------------------------------------------------------------------------- 1 | 2 | extern func myCFunc(x int) int; 3 | 4 | exported func main() int { 5 | return myCFunc(42); 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/simpleexternreturn/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "vtest/cMake42.h" 5 | 6 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 7 | int64_t incrementIntFile(const char* filename); 8 | 9 | extern ValeInt vtest_cMake42() { 10 | int runNumber = incrementIntFile("myfile.bin"); 11 | return 42 * runNumber; 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/simpleexternreturn/test.vale: -------------------------------------------------------------------------------- 1 | 2 | extern func cMake42() int; 3 | 4 | exported func main() int { 5 | cMake42() 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmparamdeepexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "vtest/Spaceship.h" 6 | #include "vtest/ImmSpaceshipArray.h" 7 | #include "vtest/cSumFuel.h" 8 | #include "vtest/valeSumFuel.h" 9 | 10 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 11 | int64_t incrementIntFile(const char* filename); 12 | 13 | extern ValeInt vtest_cSumFuel(vtest_ImmSpaceshipArray* arr) { 14 | int runNumber = incrementIntFile("myfile.bin"); 15 | 16 | return vtest_valeSumFuel(arr) * runNumber; 17 | } 18 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmparamdeepexport/test.vale: -------------------------------------------------------------------------------- 1 | exported struct Spaceship imm { 2 | fuel int; 3 | wings int; 4 | } 5 | 6 | export [#3]Spaceship as ImmSpaceshipArray; 7 | 8 | exported func valeSumFuel(arr [#3]Spaceship) int { 9 | total = 0; 10 | i = 0; 11 | while (i < arr.len()) { 12 | set total = total + arr[i].fuel; 13 | set i = i + 1; 14 | } 15 | return total; 16 | } 17 | 18 | extern func cSumFuel(arr [#3]Spaceship) int; 19 | 20 | exported func main() int { 21 | a = #[#3]((i) => { Spaceship(13 + i, i * 2) }); 22 | return cSumFuel(a); 23 | } 24 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmparamdeepextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "vtest/Spaceship.h" 6 | #include "vtest/ImmSpaceshipArray.h" 7 | #include "vtest/cSumFuel.h" 8 | 9 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 10 | int64_t incrementIntFile(const char* filename); 11 | 12 | extern ValeInt vtest_cSumFuel(vtest_ImmSpaceshipArray* arr) { 13 | int runNumber = incrementIntFile("myfile.bin"); 14 | 15 | ValeInt total = 0; 16 | for (int i = 0; i < vtest_ImmSpaceshipArray_SIZE; i++) { 17 | total += arr->elements[i]->fuel; 18 | } 19 | return total * runNumber; 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmparamdeepextern/test.vale: -------------------------------------------------------------------------------- 1 | exported struct Spaceship imm { 2 | fuel int; 3 | wings int; 4 | } 5 | 6 | export [#3]Spaceship as ImmSpaceshipArray; 7 | 8 | extern func cSumFuel(arr [#3]Spaceship) int; 9 | 10 | exported func main() int { 11 | a = #[#](Spaceship(13, 100), Spaceship(14, 100), Spaceship(15, 100)); 12 | return cSumFuel(a); 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmparamexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "vtest/ImmIntArray.h" 6 | #include "vtest/cSumFuel.h" 7 | #include "vtest/valeSumFuel.h" 8 | 9 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 10 | int64_t incrementIntFile(const char* filename); 11 | 12 | extern ValeInt vtest_cSumFuel(vtest_ImmIntArray* arr) { 13 | int runNumber = incrementIntFile("myfile.bin"); 14 | 15 | return vtest_valeSumFuel(arr) * runNumber; 16 | } 17 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmparamexport/test.vale: -------------------------------------------------------------------------------- 1 | export [#3]int as ImmIntArray; 2 | 3 | exported func valeSumFuel(arr [#3]int) int { 4 | total = 0; 5 | i = 0; 6 | while (i < arr.len()) { 7 | set total = total + arr[i]; 8 | set i = i + 1; 9 | } 10 | return total; 11 | } 12 | 13 | extern func cSumFuel(arr [#3]int) int; 14 | 15 | exported func main() int { 16 | a = #[#3]((i) => { 13 + i }); 17 | return cSumFuel(a); 18 | } 19 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmparamextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "vtest/ImmIntArray.h" 4 | #include "vtest/cSumBytes.h" 5 | 6 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 7 | int64_t incrementIntFile(const char* filename); 8 | 9 | ValeInt vtest_cSumBytes(vtest_ImmIntArray* arr) { 10 | int runNumber = incrementIntFile("myfile.bin"); 11 | 12 | ValeInt total = 0; 13 | for (int i = 0; i < vtest_ImmIntArray_SIZE; i++) { 14 | total += arr->elements[i]; 15 | } 16 | return total * runNumber; 17 | } 18 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmparamextern/test.vale: -------------------------------------------------------------------------------- 1 | export [#3]int as ImmIntArray; 2 | 3 | extern func cSumBytes(arr [#3]int) int; 4 | 5 | exported func main() int { 6 | a = #[#](13, 14, 15); 7 | return cSumBytes(a); 8 | } 9 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmreturnexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "vtest/ImmIntArray.h" 5 | #include "vtest/valeMakeSSA.h" 6 | #include "vtest/cMakeSSA.h" 7 | 8 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 9 | int64_t incrementIntFile(const char* filename); 10 | 11 | vtest_ImmIntArray* vtest_cMakeSSA() { 12 | int runNumber = incrementIntFile("myfile.bin"); 13 | 14 | vtest_ImmIntArray* arr = vtest_valeMakeSSA(); 15 | 16 | for (int i = 0; i < vtest_ImmIntArray_SIZE; i++) { 17 | arr->elements[i] *= runNumber; 18 | } 19 | 20 | return arr; 21 | } 22 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmreturnexport/test.vale: -------------------------------------------------------------------------------- 1 | 2 | export [#3]int as ImmIntArray; 3 | 4 | exported func valeMakeSSA() [#3]int { 5 | return #[#](13, 14, 15); 6 | } 7 | 8 | extern func cMakeSSA() [#3]int; 9 | 10 | exported func main() int { 11 | arr = cMakeSSA(); 12 | i = 0; 13 | total = 0; 14 | while (i < arr.len()) { 15 | set total = total + arr[i]; 16 | set i = i + 1; 17 | } 18 | return total; 19 | } 20 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmreturnextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "vtest/ImmIntArray.h" 6 | #include "vtest/cMakeSSA.h" 7 | 8 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 9 | int64_t incrementIntFile(const char* filename); 10 | 11 | vtest_ImmIntArray* vtest_cMakeSSA() { 12 | int runNumber = incrementIntFile("myfile.bin"); 13 | 14 | assert(vtest_ImmIntArray_SIZE == 3); 15 | vtest_ImmIntArray* arr = malloc(sizeof(vtest_ImmIntArray) + sizeof(ValeInt) * vtest_ImmIntArray_SIZE); 16 | arr->elements[0] = 13 * runNumber; 17 | arr->elements[1] = 14 * runNumber; 18 | arr->elements[2] = 15 * runNumber; 19 | return arr; 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssaimmreturnextern/test.vale: -------------------------------------------------------------------------------- 1 | 2 | export [#3]int as ImmIntArray; 3 | 4 | extern func cMakeSSA() [#3]int; 5 | 6 | exported func main() int { 7 | arr = cMakeSSA(); 8 | i = 0; 9 | total = 0; 10 | while (i < arr.len()) { 11 | set total = total + arr[i]; 12 | set i = i + 1; 13 | } 14 | return total; 15 | } 16 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssamutparamexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "vtest/MutIntArray.h" 4 | #include "vtest/getMutIntArrayLen.h" 5 | #include "vtest/getMutIntArrayElem.h" 6 | 7 | ValeInt vtest_sumBytes(vtest_MutIntArrayRef arr) { 8 | ValeInt total = 0; 9 | ValeInt len = vtest_getMutIntArrayLen(arr); 10 | for (int i = 0; i < len; i++) { 11 | ValeInt elem = vtest_getMutIntArrayElem(arr, i); 12 | total += elem; 13 | } 14 | return total; 15 | } 16 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssamutparamexport/test.vale: -------------------------------------------------------------------------------- 1 | export [#5]int as MutIntArray; 2 | 3 | extern func sumBytes(arr &[#5]int) int; 4 | exported func getMutIntArrayLen(arr &[#5]int) int { len(&arr) } 5 | exported func getMutIntArrayElem(arr &[#5]int, i int) int { arr[i] } 6 | 7 | exported func main() int { 8 | a = [#5]({_}); 9 | return sumBytes(&a); 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssamutreturnexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "vtest/MutIntArray.h" 5 | #include "vtest/valeMakeSSA.h" 6 | #include "vtest/cMakeSSA.h" 7 | 8 | vtest_MutIntArrayRef vtest_cMakeSSA() { 9 | return vtest_valeMakeSSA(); 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/ssamutreturnexport/test.vale: -------------------------------------------------------------------------------- 1 | 2 | export [#3]int as MutIntArray; 3 | 4 | exported func valeMakeSSA() [#3]int { 5 | return [#](13, 14, 15); 6 | } 7 | 8 | extern func cMakeSSA() [#3]int; 9 | 10 | exported func main() int { 11 | arr = cMakeSSA(); 12 | i = 0; 13 | total = 0; 14 | while (i < arr.len()) { 15 | set total = total + arr[i]; 16 | set i = i + 1; 17 | } 18 | return total; 19 | } 20 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/strlenextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include "ValeBuiltins.h" 2 | #include 3 | #include 4 | 5 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 6 | int64_t incrementIntFile(const char* filename); 7 | 8 | ValeInt vtest_extStrLen(ValeStr* haystackContainerStr) { 9 | int runNumber = incrementIntFile("myfile.bin"); 10 | 11 | printf("extstrlen run number %d\n", runNumber); 12 | 13 | char* haystackContainerChars = haystackContainerStr->chars; 14 | ValeInt result = strlen(haystackContainerChars); 15 | return result * runNumber; 16 | } 17 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/strlenextern/test.vale: -------------------------------------------------------------------------------- 1 | 2 | extern func extStrLen(haystackStr str) int; 3 | 4 | exported func main() int { 5 | len = extStrLen("sprogwoggle"); 6 | return len; 7 | } 8 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/strreturnexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "vtest/getAStr.h" 6 | 7 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 8 | int64_t incrementIntFile(const char* filename); 9 | 10 | ValeStr* vtest_runExtCommand() { 11 | int runNumber = incrementIntFile("myfile.bin"); 12 | 13 | ValeStr* str = vtest_getAStr(); 14 | 15 | assert(str->length == 6); 16 | int diff = strncmp(str->chars, "hello!", 6); 17 | assert(diff == 0); 18 | 19 | // "hello!", "hello!hello!", etc. 20 | ValeStr* result = ValeStrNew(str->length * runNumber); 21 | for (int i = 0; i < runNumber; i++) { 22 | strncpy(result->chars + strlen("hello!") * runNumber, "hello!", strlen("hello!")); 23 | } 24 | 25 | free(str); 26 | 27 | return result; 28 | } 29 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/strreturnexport/test.vale: -------------------------------------------------------------------------------- 1 | exported func getAStr() str { "hello!" } 2 | 3 | extern func runExtCommand() str; 4 | 5 | exported func main() int { 6 | result = runExtCommand(); 7 | return result.len(); 8 | } 9 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structimmparamdeepexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "vtest/Bogglewoggle.h" 8 | #include "vtest/Flamscrankle.h" 9 | 10 | extern ValeInt vtest_expFunc(vtest_Flamscrankle* flam); 11 | 12 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 13 | int64_t incrementIntFile(const char* filename); 14 | 15 | ValeInt vtest_extFunc(vtest_Flamscrankle* flam) { 16 | int runNumber = incrementIntFile("myfile.bin"); 17 | 18 | return vtest_expFunc(flam) * runNumber; 19 | } 20 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structimmparamdeepexport/test.vale: -------------------------------------------------------------------------------- 1 | 2 | exported struct Flamscrankle imm { 3 | a int; 4 | b Bogglewoggle; 5 | c int; 6 | } 7 | 8 | exported struct Bogglewoggle imm { 9 | a int; 10 | } 11 | 12 | extern func extFunc(flam Flamscrankle) int; 13 | 14 | exported func expFunc(flam Flamscrankle) int { 15 | flam.a + flam.b.a + flam.c 16 | } 17 | 18 | exported func main() int { 19 | return extFunc(Flamscrankle(7, Bogglewoggle(21), 14)); 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structimmparamdeepextern/test.vale: -------------------------------------------------------------------------------- 1 | 2 | exported struct Flamscrankle imm { 3 | x int; 4 | b Bogglewoggle; 5 | y int; 6 | } 7 | 8 | exported struct Bogglewoggle imm { 9 | s Spigglewigget; 10 | x int; 11 | } 12 | 13 | exported struct Spigglewigget imm { 14 | x int; 15 | y int; 16 | z int; 17 | } 18 | 19 | extern func extFunc_vasp(flam Flamscrankle) int; 20 | 21 | exported func main() int { 22 | return extFunc_vasp(Flamscrankle(7, Bogglewoggle(Spigglewigget(5, 7, 4), 5), 14)); 23 | } 24 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structimmparamexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "vtest/Flamscrankle.h" 7 | #include "vtest/expFunc.h" 8 | 9 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 10 | int64_t incrementIntFile(const char* filename); 11 | 12 | ValeInt vtest_extFunc(vtest_Flamscrankle* flam) { 13 | int runNumber = incrementIntFile("myfile.bin"); 14 | ValeInt result = vtest_expFunc(flam) * runNumber; 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structimmparamexport/test.vale: -------------------------------------------------------------------------------- 1 | 2 | exported struct Flamscrankle imm { 3 | a int; 4 | c int; 5 | } 6 | 7 | exported func expFunc(flam Flamscrankle) int { 8 | flam.a + flam.c 9 | } 10 | 11 | extern func extFunc(flam Flamscrankle) int; 12 | 13 | exported func main() int { 14 | return extFunc(Flamscrankle(7, 35)); 15 | } 16 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structimmparamextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "vtest/Flamscrankle.h" 7 | 8 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 9 | int64_t incrementIntFile(const char* filename); 10 | 11 | ValeInt vtest_extFunc(vtest_Flamscrankle* flam) { 12 | int runNumber = incrementIntFile("myfile.bin"); 13 | ValeInt result = (flam->a + flam->c) * runNumber; 14 | free(flam); 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structimmparamextern/test.vale: -------------------------------------------------------------------------------- 1 | 2 | exported struct Flamscrankle imm { 3 | a int; 4 | c int; 5 | } 6 | 7 | extern func extFunc(flam Flamscrankle) int; 8 | 9 | exported func main() int { 10 | return extFunc(Flamscrankle(7, 35)); 11 | } 12 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structimmreturnexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "vtest/Flamscrankle.h" 5 | #include "vtest/valeMakeStruct.h" 6 | #include "vtest/cMakeStruct.h" 7 | 8 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 9 | int64_t incrementIntFile(const char* filename); 10 | 11 | vtest_Flamscrankle* vtest_cMakeStruct() { 12 | int runNumber = incrementIntFile("myfile.bin"); 13 | 14 | vtest_Flamscrankle* x = vtest_valeMakeStruct(); 15 | x->a *= runNumber; 16 | x->c *= runNumber; 17 | return x; 18 | } 19 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structimmreturnexport/test.vale: -------------------------------------------------------------------------------- 1 | 2 | exported struct Flamscrankle imm { 3 | a int; 4 | c int; 5 | } 6 | 7 | exported func valeMakeStruct() Flamscrankle { 8 | return Flamscrankle(37, 5); 9 | } 10 | 11 | extern func cMakeStruct() Flamscrankle; 12 | 13 | exported func main() int { 14 | flam = cMakeStruct(); 15 | return flam.a + flam.c; 16 | } 17 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structimmreturnextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "vtest/Flamscrankle.h" 6 | #include "vtest/cMakeStruct.h" 7 | 8 | // We use incrementIntFile to get some side effects to test replayability, see AASETR. 9 | int64_t incrementIntFile(const char* filename); 10 | 11 | vtest_Flamscrankle* vtest_cMakeStruct() { 12 | int runNumber = incrementIntFile("myfile.bin"); 13 | 14 | printf("run number: %d\n", runNumber); 15 | vtest_Flamscrankle* flam = (vtest_Flamscrankle*)malloc(sizeof(vtest_Flamscrankle)); 16 | flam->a = 37 * runNumber; 17 | flam->c = 5 * runNumber; 18 | printf("returning a flam: %p, a: %p\n", flam, &flam->a); 19 | return flam; 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structimmreturnextern/test.vale: -------------------------------------------------------------------------------- 1 | 2 | exported struct Flamscrankle imm { 3 | a int; 4 | c int; 5 | } 6 | 7 | extern func cMakeStruct() Flamscrankle; 8 | 9 | exported func main() int { 10 | flam = cMakeStruct(); 11 | return flam.a + flam.c; 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structmutparamdeepexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "vtest/Spaceship.h" 5 | #include "vtest/cGetFuel.h" 6 | #include "vtest/valeGetFuel.h" 7 | 8 | extern ValeInt vtest_cGetFuel(vtest_SpaceshipRef s) { 9 | return vtest_valeGetFuel(s); 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structmutparamdeepexport/test.vale: -------------------------------------------------------------------------------- 1 | 2 | exported struct Spaceship { 3 | engine Engine; 4 | } 5 | // Not exported 6 | struct Engine { fuel int; } 7 | 8 | exported func valeGetFuel(s &Spaceship) int { s.engine.fuel } 9 | 10 | extern func cGetFuel(s &Spaceship) int; 11 | 12 | exported func main() int { 13 | return cGetFuel(&Spaceship(Engine(42))); 14 | } 15 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structmutparamexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "vtest/Spaceship.h" 5 | #include "vtest/spaceshipGetA.h" 6 | #include "vtest/spaceshipGetB.h" 7 | 8 | extern ValeInt vtest_sumSpaceshipFields(vtest_SpaceshipRef s) { 9 | return vtest_spaceshipGetA(s) + vtest_spaceshipGetB(s); 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structmutparamexport/test.vale: -------------------------------------------------------------------------------- 1 | exported struct Spaceship { 2 | a int; 3 | b int; 4 | } 5 | 6 | extern func sumSpaceshipFields(s &Spaceship) int; 7 | exported func spaceshipGetA(s &Spaceship) int { s.a } 8 | exported func spaceshipGetB(s &Spaceship) int { s.b } 9 | 10 | exported func main() int { 11 | return sumSpaceshipFields(&Spaceship(37, 5)); 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structmutreturnexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "vtest/Thing.h" 5 | #include "vtest/makeThing.h" 6 | #include "vtest/runExtCommand.h" 7 | 8 | vtest_ThingRef vtest_runExtCommand() { 9 | return vtest_makeThing(ValeStrFrom("hello"), 37); 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/structmutreturnexport/test.vale: -------------------------------------------------------------------------------- 1 | exported struct Thing { 2 | a str; 3 | b int; 4 | } 5 | exported func makeThing(a str, b int) Thing { 6 | Thing(a, b) 7 | } 8 | 9 | extern func runExtCommand() Thing; 10 | 11 | exported func main() int { 12 | res = runExtCommand(); 13 | return len(res.a) + res.b; 14 | } 15 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/tupleparamextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef struct vtest_TwoInts { 4 | ValeInt a; 5 | ValeInt b; 6 | } vtest_TwoInts; 7 | 8 | int vtest_extGetFromTuple(vtest_TwoInts ints) { 9 | return ints.b; 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/tupleparamextern/test.vale: -------------------------------------------------------------------------------- 1 | extern func extGetFromTuple(i (int, int)) int; 2 | 3 | exported func main() int { 4 | extGetFromTuple((73, 42)) 5 | } 6 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/tupleretextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef struct vtest_TwoInts { 4 | ValeInt a; 5 | ValeInt b; 6 | } vtest_TwoInts; 7 | 8 | TwoInts vtest_extMakeTuple(int i) { 9 | vtest_TwoInts result = { i * 2, i * 3 }; 10 | return result; 11 | } 12 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/tupleretextern/test.vale: -------------------------------------------------------------------------------- 1 | 2 | extern func extMakeTuple(i int) (int, int); 3 | 4 | exported func main() int { 5 | extMakeTuple(14).1 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/voidreturnexport/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "vtest/donothing.h" 3 | 4 | void vtest_runExtCommand() { 5 | vtest_donothing(); 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/voidreturnexport/test.vale: -------------------------------------------------------------------------------- 1 | exported func donothing() { } 2 | 3 | extern func runExtCommand(); 4 | 5 | exported func main() int { 6 | runExtCommand(); 7 | return 42; 8 | } 9 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/voidreturnextern/native/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "vtest/MyBox.h" 4 | #include "vtest/changeInBox.h" 5 | 6 | void vtest_runExtCommand(vtest_MyBoxRef b) { 7 | vtest_changeInBox(b); 8 | } 9 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/externs/voidreturnextern/test.vale: -------------------------------------------------------------------------------- 1 | exported struct MyBox { 2 | i! int; 3 | } 4 | 5 | exported func changeInBox(b &MyBox) { 6 | set b.i = 42; 7 | } 8 | 9 | extern func runExtCommand(b &MyBox); 10 | 11 | exported func main() int { 12 | b = MyBox(73); 13 | runExtCommand(&b); 14 | return b.i; 15 | } 16 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/floatarithmetic.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | return int(-((7.5 + 17.5 - 4.0) * 4.0 / -2.0)); 3 | } 4 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/floateq.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | x = 32.0 == 16.0 + 16.0; 3 | return if (x) { 42 } else { 73 }; 4 | } 5 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/functions/overloads.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.arith.*; 2 | import v.builtins.str.*; 3 | 4 | func bork(a int, b int) int { return +(a, b); } 5 | func bork(a str, b str) str { return +(a, b); } 6 | exported func main() int { return 3 bork 3; } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/functions/recursion.vale: -------------------------------------------------------------------------------- 1 | 2 | func factorial(x int) int { 3 | return if (x == 0) { 4 | 1 5 | } else { 6 | x * factorial(x - 1) 7 | }; 8 | } 9 | 10 | exported func main() int { 11 | return factorial(5); 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/genericvirtuals/callingAbstract.vale: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | sealed interface MyInterface where T Ref { 5 | func doThing(virtual x MyInterface) int; 6 | } 7 | 8 | struct MyStruct where T Ref { } 9 | impl MyInterface for MyStruct; 10 | func doThing(x MyStruct) int { return 4; } 11 | 12 | exported func main() int { 13 | x = MyStruct(); 14 | y = MyStruct(); 15 | doThing(x); 16 | return doThing(y); 17 | } 18 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/genericvirtuals/foreachlinkedlist.vale: -------------------------------------------------------------------------------- 1 | 2 | 3 | import v.builtins.opt.*; 4 | import v.builtins.logic.*; 5 | import v.builtins.drop.*; 6 | import printutils.*; 7 | 8 | struct MyList where func drop(T)void { 9 | value T; 10 | next ^Opt<^MyList>; 11 | } 12 | 13 | func forEach( 14 | opt &Opt>, 15 | func F) 16 | int 17 | where func drop(T)void, func(&F, &T)void, func drop(F)void { 18 | if not opt.isEmpty() { 19 | forEach(opt.get(), func); 20 | } else { 21 | (func); 22 | } 23 | return 0; 24 | } 25 | 26 | func forEach(list &MyList, func F) int 27 | where func drop(T)void, func(&F, &T)void, func drop(F)void 28 | { 29 | func(list.value); 30 | forEach(list.next, func); 31 | return 0; 32 | } 33 | 34 | exported func main() int { 35 | list = MyList(10, Some<^MyList>(MyList(20, Some<^MyList>(MyList(30, None<^MyList>()))))); 36 | forEach(&list, { print(_); }); 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/genericvirtuals/getOr.vale: -------------------------------------------------------------------------------- 1 | 2 | #!DeriveInterfaceDrop 3 | sealed interface XOpt { } 4 | 5 | #!DeriveStructDrop 6 | struct XSome { value T; } 7 | 8 | 9 | impl XOpt for XSome; 10 | 11 | abstract func drop(virtual opt XOpt) void 12 | where func drop(T)void; 13 | 14 | func drop(self XSome) void 15 | where func drop(T)void { 16 | [unused] = self; 17 | } 18 | 19 | abstract func getOr(virtual opt &XOpt, default &T) &T; 20 | func getOr(opt &XSome, default &T) &T { 21 | return opt.value; 22 | } 23 | 24 | exported func main() int { 25 | a XOpt = XSome(9); 26 | return a.getOr(12); 27 | } 28 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/genericvirtuals/mapFunc.vale: -------------------------------------------------------------------------------- 1 | 2 | import optutils.*; 3 | import ifunction.ifunction1.*; 4 | 5 | struct MyEquals9Functor { } 6 | impl IFunction1 for MyEquals9Functor; 7 | func __call(this &MyEquals9Functor, i int) bool { return i == 9; } 8 | 9 | exported func main() bool { 10 | a Opt = Some(9); 11 | f = MyEquals9Functor(); 12 | b Opt = a.map(&f); 13 | return b.getOr(false); 14 | } 15 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/genericvirtuals/specializeinterface.vale: -------------------------------------------------------------------------------- 1 | // This test is complex because it's a templated struct specializing a templated interface. 2 | 3 | import v.builtins.arith.*; 4 | import v.builtins.drop.*; 5 | import printutils.*; 6 | 7 | sealed interface MyIFunction1 { 8 | func myFunc(virtual this &MyIFunction1, param P1) R 9 | where func drop(P1)void; 10 | } 11 | 12 | struct MyToBool { } 13 | 14 | impl MyIFunction1 for MyToBool; 15 | 16 | func myFunc(this &MyToBool, param T) bool 17 | where func drop(T)void { 18 | return true; 19 | } 20 | 21 | exported func main() { 22 | m = MyToBool(); 23 | i &MyIFunction1 = &m; 24 | println(i.myFunc(3)); 25 | println(i.myFunc(7)); 26 | } 27 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/genericvirtuals/stampMultipleAncestors.vale: -------------------------------------------------------------------------------- 1 | 2 | interface I imm where T Ref { } 3 | 4 | interface J imm where T Ref { } 5 | impl I for J; 6 | 7 | interface K imm where T Ref { } 8 | impl J for K; 9 | 10 | struct L imm where T Ref { } 11 | impl K for L; 12 | 13 | exported func main() int { 14 | x = L(); 15 | return 4; 16 | } 17 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/genericvirtuals/templatedinterface.vale: -------------------------------------------------------------------------------- 1 | 2 | 3 | import v.builtins.arith.*; 4 | import printutils.*; 5 | 6 | sealed interface MyIFunction1 { 7 | func go(virtual this &MyIFunction1, param P1) R; 8 | } 9 | 10 | struct MyFunc { } 11 | impl MyIFunction1 for MyFunc; 12 | 13 | func go(this &MyFunc, param int) int { 14 | return param * 2; 15 | } 16 | 17 | exported func main() { 18 | m = MyFunc(); 19 | i &MyIFunction1 = &m; 20 | println(i.go(4)); 21 | println(i.go(6)); 22 | } 23 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/genericvirtuals/templatedlinkedlist.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.opt.*; 2 | import v.builtins.logic.*; 3 | import v.builtins.drop.*; 4 | import printutils.*; 5 | 6 | #!DeriveStructDrop 7 | struct MyList { 8 | value T; 9 | next Opt>; 10 | } 11 | 12 | func drop(this MyList) 13 | where func drop(T)void { 14 | [value, next] = this; 15 | } 16 | 17 | func printValues(list &MyList) void { 18 | print(list.value); 19 | printNextValue(list.next); 20 | } 21 | 22 | func printNextValue(opt &Opt>) void { 23 | if not opt.isEmpty() { 24 | printValues(opt.get()); 25 | } 26 | } 27 | 28 | 29 | exported func main() int { 30 | list = MyList(10, Some>(MyList(20, Some>(MyList(30, None>()))))); 31 | printValues(&list); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/genericvirtuals/templatedoption.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.drop.*; 2 | 3 | sealed interface MyOption { } 4 | 5 | struct MySome where func drop(T)void { 6 | value T; 7 | } 8 | impl MyOption for MySome; 9 | 10 | struct MyNone where T Ref { } 11 | impl MyOption for MyNone; 12 | 13 | abstract func len(virtual opt &MyOption) int; 14 | func len(opt &MyNone) int { return 0; } 15 | func len(opt &MySome) int { return 1; } 16 | 17 | exported func main() int { 18 | myOpt MyOption = MySome(4); 19 | return len(&myOpt); 20 | } 21 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/if/if.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | return if (true) { 3 | 42 4 | } else { 5 | 73 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/if/ifnevers.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | if (true) { 3 | return 42; 4 | } else { 5 | return 73; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/if/nestedif.vale: -------------------------------------------------------------------------------- 1 | // This is here because we had a bug where our LLVMBuildPhi area of code was 2 | // mistakenly trying to correctly pull a value from the then's final block but 3 | // incorrectly say it was from the then's starting block (same with else). 4 | 5 | exported func main() int { 6 | return if (false) { 73 } 7 | else if (true) { 42 } 8 | else { 62 }; 9 | } 10 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/if/neverif.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | if (true) { 3 | return 42; 4 | } else { 5 | return 73; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/if/upcastif.vale: -------------------------------------------------------------------------------- 1 | interface I { 2 | func moo(virtual this &I) int; 3 | } 4 | struct A {} 5 | impl I for A; 6 | struct B {} 7 | impl I for B; 8 | 9 | func moo(a &A) int { return 73; } 10 | func moo(b &B) int { return 42; } 11 | 12 | exported func main() int { 13 | myVar I = if (false) { A() } else { B() }; 14 | return moo(&myVar); 15 | } 16 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/invalidaccess.vale: -------------------------------------------------------------------------------- 1 | 2 | struct Marine { hp int; } 3 | 4 | exported func main() int { 5 | m = Marine(7); 6 | b = &m; 7 | drop(m); 8 | return b.hp; 9 | } 10 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/lambdas/doubleclosure.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { a = 7; return ({ ({ a })() })(); } 3 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/lambdas/lambda.vale: -------------------------------------------------------------------------------- 1 | 2 | func do(callable &F) int where func(&F)int { 3 | callable() 4 | } 5 | 6 | exported func main() int { 7 | do(&{ 42 }) 8 | } 9 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/lambdas/lambdamut.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | x = 10; 4 | ({ set x = 42; })(); 5 | return x; 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/lambdas/mutate.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | x = 4; 4 | { 5 | set x = x + 1; 6 | }(); 7 | x 8 | } 9 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/loop_restackify.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.arith.*; 2 | struct Spaceship { fuel! int; } 3 | func foo(ship Spaceship) Spaceship { 4 | set ship.fuel = ship.fuel + 5; 5 | return ship; 6 | } 7 | exported func main() int { 8 | ship = Spaceship(27); 9 | i = 0; 10 | while i < 3 { 11 | set ship = foo(ship); 12 | set i = i + 1; 13 | } 14 | [x] = ship; 15 | return x; 16 | } 17 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/multiUnstackify.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | playerRow = 137; 4 | 5 | if (false) { 6 | return 50; 7 | } else if (false) { 8 | return 50; 9 | } else if (true) { 10 | return 42; 11 | } 12 | return playerRow; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/mutlocal.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | x int = 73; 3 | set x = 42; 4 | return x; 5 | } 6 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/mutswaplocals.vale: -------------------------------------------------------------------------------- 1 | struct Ship { } 2 | 3 | exported func main() int { 4 | a = Ship(); 5 | b = Ship(); 6 | 7 | Ship[ ] = (set b = (set a = (set b = Ship()))); 8 | Ship[ ] = a; 9 | Ship[ ] = b; 10 | return 42; 11 | } 12 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/nestedblocks.vale: -------------------------------------------------------------------------------- 1 | 2 | struct Bork {} 3 | 4 | exported func main() int { 5 | originalIndex = 9; 6 | 7 | i = 1; 8 | block { 9 | neighborIndex = 10; 10 | bork = Bork(); 11 | block { 12 | drop(bork); 13 | } 14 | } 15 | 16 | return 42; 17 | } 18 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/panic.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | __vbi_panic(); 4 | return 73; 5 | } 6 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/panicnot.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | if (false) { 4 | __vbi_panic(); 5 | } 6 | return 42; 7 | } 8 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/printfloat.vale: -------------------------------------------------------------------------------- 1 | import printutils.*; 2 | 3 | exported func main() { 4 | a = 42.125; 5 | print(a); 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/pure/pure_block_produce_ssa.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | x = pure block { [#]([#](10, 20), [#](30, 40)) }; 3 | [[a1, a2], [a3, a4]] = x; 4 | a1 5 | } 6 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/pure/pure_block_read_ssa.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | s = [#]([#](10, 20), [#](30, 40)); 3 | res = 4 | pure block { 5 | x = s[0]; 6 | y = x[0]; 7 | y 8 | }; 9 | [[a1, a2], [a3, a4]] = s; 10 | res 11 | } 12 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/pure/pure_func_return_rsa.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.runtime_sized_array_mut_new.*; 2 | pure func makeArr() [][]int { 3 | return [][]int(0); 4 | } 5 | exported func main() int { 6 | x = makeArr(); 7 | [] = x; 8 | 42 9 | } 10 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/pure/pure_func_return_ssa.vale: -------------------------------------------------------------------------------- 1 | pure func makeArr() [#2][#2]int { 2 | return [#]([#](10, 20), [#](30, 40)); 3 | } 4 | exported func main() int { 5 | x = makeArr(); 6 | [[a1, a2], [a3, a4]] = x; 7 | a1 8 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/pure/pure_func_return_struct.vale: -------------------------------------------------------------------------------- 1 | struct Engine { fuel int; } 2 | struct Spaceship { engine Engine; } 3 | pure func makeSpaceship() Spaceship { 4 | Spaceship(Engine(10)) 5 | } 6 | exported func main() int { 7 | s = makeSpaceship(); 8 | pure block { 9 | x = s.engine; 10 | y = x.fuel; 11 | y 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/pure/pure_func_take_ssa.vale: -------------------------------------------------------------------------------- 1 | pure func Display(arr &r'[#2][#2]int) { 2 | // do nothing 3 | } 4 | exported func main() int { 5 | x = [#]([#](10, 20), [#](30, 40)); 6 | Display(&x); 7 | [[a1, a2], [a3, a4]] = x; 8 | a1 9 | } 10 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/readwriteufcs.vale: -------------------------------------------------------------------------------- 1 | 2 | struct Spaceship { 3 | fuel! int; 4 | } 5 | 6 | func getFuel(a &Spaceship) int { 7 | return a.fuel; 8 | } 9 | 10 | exported func main() int { 11 | ship = Spaceship(42); 12 | return (&ship).getFuel(); 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/regions/multi_region_extern.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.streq.*; 2 | pure func pureFunc(s r'str) bool { 3 | streq(s, 0, 3, "def", 0, 3) 4 | } 5 | 6 | exported func main() int { 7 | s = "abc"; 8 | if pureFunc(s) { 73 } else { 42 } 9 | } 10 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/restackify.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.arith.*; 2 | struct Spaceship { fuel int; } 3 | func foo(ship Spaceship) Spaceship { 4 | [oldFuel] = ship; 5 | return Spaceship(oldFuel + 7); 6 | } 7 | exported func main() int { 8 | ship = Spaceship(35); 9 | set ship = foo(ship); 10 | [x] = ship; 11 | return x; 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/strings/i64tostr.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | return len(str(1337i64)); 4 | } 5 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/strings/inttostr.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | return len(str(1337)); 4 | } 5 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/strings/smallstr.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | print("'"); 4 | return 42; 5 | } 6 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/strings/stradd.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | a = "Glory to the "; 4 | b = "Lizard People"; 5 | combined = a + b; 6 | 7 | other = "Glory to the Lizard People"; 8 | return if (streq(combined, 0, len(combined), other, 0, len(other))) { 9 | 42 10 | } else { 11 | 1 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/strings/strlen.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | // This tests string length, but also tests that special characters 4 | // made it all the way through all the stages of the compiler 5 | return len("sprog\u001bwoggle"); 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/strings/strneq.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.streq.*; 2 | 3 | exported func main() int { 4 | return if streq("abc", 0, 3, "def", 0, 3) { 5 | 73 6 | } else { 7 | 42 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/strings/strprint.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | print("Hello"); 4 | return 42; 5 | } 6 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/structs/bigstructimm.vale: -------------------------------------------------------------------------------- 1 | struct UnitSnapshot imm { 2 | hp int; 3 | mp int; 4 | armor int; 5 | strength int; 6 | agility int; 7 | intelligence int; 8 | } 9 | 10 | exported func main() int { 11 | return UnitSnapshot(4, 5, 6, 7, 42, 9).agility; 12 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/structs/constructor.vale: -------------------------------------------------------------------------------- 1 | 2 | struct Marine { 3 | hp int; 4 | cool bool; 5 | } 6 | func Marine() Marine { 7 | self.hp = 10; 8 | self.cool = true; 9 | } 10 | exported func main() int { 11 | return Marine().hp; 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/structs/deadmutstruct.vale: -------------------------------------------------------------------------------- 1 | struct Carrier { 2 | hp int; 3 | interceptors int; 4 | } 5 | 6 | exported func main() int { 7 | c = Carrier(73, 73); 8 | b = &c; 9 | drop(c); 10 | return b.interceptors; 11 | } 12 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/structs/getMember.vale: -------------------------------------------------------------------------------- 1 | 2 | struct Marine { hp int; } 3 | exported func main() int { 4 | m = Marine(9); 5 | return m.hp; 6 | } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/structs/memberrefcount.vale: -------------------------------------------------------------------------------- 1 | struct Thing { 2 | v! Vec3i; 3 | } 4 | 5 | struct Vec3i imm { 6 | x int; 7 | y int; 8 | z int; 9 | } 10 | 11 | func bork(thing &Thing, v Vec3i) void { 12 | set thing.v = v; 13 | } 14 | 15 | exported func main() int { 16 | thing = Thing(Vec3i(7, 8, 9)); 17 | bork(&thing, Vec3i(4, 5, 6)); 18 | return thing.v.y; 19 | } 20 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/structs/mutate.vale: -------------------------------------------------------------------------------- 1 | 2 | struct Marine { hp! int; } 3 | exported func main() int { 4 | m = Marine(9); 5 | set m.hp = 4; 6 | return m.hp; 7 | } 8 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/structs/structimm.vale: -------------------------------------------------------------------------------- 1 | struct Vec3i imm { 2 | x int; 3 | y int; 4 | z int; 5 | } 6 | 7 | exported func main() int { 8 | return Vec3i(4, 5, 6).y; 9 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/structs/structmut.vale: -------------------------------------------------------------------------------- 1 | struct Carrier { 2 | hp int; 3 | interceptors int; 4 | } 5 | 6 | exported func main() int { 7 | return Carrier(400, 8).interceptors; 8 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/structs/structmutstore.vale: -------------------------------------------------------------------------------- 1 | struct Carrier { 2 | hp int; 3 | interceptors! int; 4 | } 5 | 6 | exported func main() int { 7 | c = Carrier(400, 8); 8 | set c.interceptors = 42; 9 | return c.interceptors; 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/structs/structmutstoreinner.vale: -------------------------------------------------------------------------------- 1 | struct Outer { 2 | inner Inner; 3 | } 4 | 5 | struct Inner { 6 | x! int; 7 | } 8 | 9 | exported func main() int { 10 | o = Outer(Inner(73)); 11 | set o.inner.x = 42; 12 | return o.inner.x; 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/structs/structs.vale: -------------------------------------------------------------------------------- 1 | 2 | struct MyStruct { a int; } 3 | 4 | struct OtherStruct { b MyStruct; } 5 | 6 | exported func main() int { ms = OtherStruct(MyStruct(11)); ms.b.a } 7 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/truncate.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | x = TruncateI64ToI32(4300000000i64); 4 | return if (x == 5032704) { 42 } else { 73 }; 5 | } 6 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/tuples/immtupleaccess.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | t = (true, 42); 3 | return t.1; 4 | } 5 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/ufcs.vale: -------------------------------------------------------------------------------- 1 | 2 | struct Spaceship { 3 | fuel! int; 4 | } 5 | 6 | func getFuel(a &Spaceship) int { 7 | return a.fuel; 8 | } 9 | 10 | exported func main() int { 11 | ship = Spaceship(42); 12 | return (&ship).getFuel(); 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/unreachablemoot.vale: -------------------------------------------------------------------------------- 1 | 2 | exported func main() int { 3 | while (true) { 4 | if (true) { 5 | return 42; 6 | } 7 | // Continue 8 | } 9 | __vbi_panic(); 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/unstackifyret.vale: -------------------------------------------------------------------------------- 1 | // We can re-use locals' ID numbers. It's kind of like their "stack height" in 2 | // that way. The code below reuses local ID 1. 3 | // We had a bug where Unstackify wasnt unregistering the local in its local ID 4 | // to LLVMValueRef map. 5 | 6 | exported func main() int { 7 | playerRow = 4; 8 | 9 | if (false) { 10 | newPlayerRow = 0; 11 | } 12 | return 42; 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/virtuals/calling.vale: -------------------------------------------------------------------------------- 1 | 2 | sealed interface Car { 3 | func doCivicDance(virtual this Car) int; 4 | } 5 | 6 | struct Civic {} 7 | impl Car for Civic; 8 | func doCivicDance(civic Civic) int { 9 | return 4; 10 | } 11 | 12 | struct Toyota {} 13 | impl Car for Toyota; 14 | func doCivicDance(toyota Toyota) int { 15 | return 7; 16 | } 17 | 18 | exported func main() int { 19 | x Car = Toyota(); 20 | return doCivicDance(x); 21 | } 22 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/virtuals/callingThroughBorrow.vale: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | sealed interface Car { 5 | func doCivicDance(virtual this &Car) int; 6 | } 7 | 8 | struct Civic {} 9 | impl Car for Civic; 10 | func doCivicDance(civic &Civic) int { 11 | return 4; 12 | } 13 | 14 | struct Toyota {} 15 | impl Car for Toyota; 16 | func doCivicDance(toyota &Toyota) int { 17 | return 7; 18 | } 19 | 20 | exported func main() int { 21 | x Car = Toyota(); 22 | b = &x; 23 | return doCivicDance(b); 24 | } 25 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/virtuals/interfaceimm.vale: -------------------------------------------------------------------------------- 1 | 2 | sealed interface MyOption imm { } 3 | 4 | struct MySome imm { 5 | value @MyList; 6 | } 7 | impl MyOption for MySome; 8 | 9 | struct MyNone imm { } 10 | impl MyOption for MyNone; 11 | 12 | 13 | struct MyList imm { 14 | value @int; 15 | next @MyOption; 16 | } 17 | 18 | func sum(list @MyList) int { 19 | return list.value + sum(list.next); 20 | } 21 | 22 | abstract func sum(virtual opt @MyOption) int; 23 | func sum(opt @MyNone) int { return 0; } 24 | func sum(opt @MySome) int { 25 | return sum(opt.value); 26 | } 27 | 28 | 29 | exported func main() int { 30 | list = MyList(7, MySome(MyList(17, MySome(MyList(18, MyNone()))))); 31 | return sum(list); 32 | } 33 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/virtuals/interfacemut.vale: -------------------------------------------------------------------------------- 1 | 2 | sealed interface MyOption { } 3 | 4 | struct MySome { 5 | value MyList; 6 | } 7 | impl MyOption for MySome; 8 | 9 | struct MyNone { } 10 | impl MyOption for MyNone; 11 | 12 | 13 | struct MyList { 14 | value int; 15 | next MyOption; 16 | } 17 | 18 | func sum(list &MyList) int { 19 | list.value + sum(&list.next) 20 | } 21 | 22 | abstract func sum(virtual opt &MyOption) int; 23 | func sum(opt &MyNone) int { return 0; } 24 | func sum(opt &MySome) int { 25 | sum(&opt.value) 26 | } 27 | 28 | 29 | exported func main() int { 30 | list = MyList(7, MySome(MyList(17, MySome(MyList(18, MyNone()))))); 31 | return sum(&list); 32 | } 33 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/virtuals/ordinarylinkedlist.vale: -------------------------------------------------------------------------------- 1 | 2 | 3 | import printutils.*; 4 | 5 | sealed interface MyOption imm { } 6 | 7 | struct MySome imm { 8 | value @MyList; 9 | } 10 | impl MyOption for MySome; 11 | 12 | struct MyNone imm { } 13 | impl MyOption for MyNone; 14 | 15 | 16 | struct MyList imm { 17 | value int; 18 | next @MyOption; 19 | } 20 | 21 | func printValues(list @MyList) void { 22 | print(list.value); 23 | printNextValue(list.next); 24 | } 25 | 26 | func printNextValue(virtual opt @MyOption) void { } 27 | func printNextValue(opt @MyNone) void { } 28 | func printNextValue(opt @MySome) void { 29 | printValues(opt.value); 30 | } 31 | 32 | 33 | exported func main() int { 34 | list = MyList(10, MySome(MyList(20, MySome(MyList(30, MyNone()))))); 35 | printValues(list); 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/virtuals/retUpcast.vale: -------------------------------------------------------------------------------- 1 | 2 | interface XOpt { } 3 | struct XSome { value int; } 4 | impl XOpt for XSome; 5 | 6 | func doIt() XOpt { 7 | return XSome(9); 8 | } 9 | 10 | exported func main() int { 11 | a = doIt(); 12 | return 3; 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/virtuals/round.vale: -------------------------------------------------------------------------------- 1 | 2 | func round(num float) int { 3 | distanceToLower = num - float(int(num)); 4 | return int(num) + if (distanceToLower < 0.5) { 0 } else { 1 }; 5 | } 6 | 7 | exported func main() int { 8 | return round(7.9); 9 | } 10 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/virtuals/upcasting.vale: -------------------------------------------------------------------------------- 1 | 2 | 3 | interface MyInterface { } 4 | struct MyStruct { value int; } 5 | impl MyInterface for MyStruct; 6 | exported func main() { 7 | x MyInterface = MyStruct(9); 8 | } 9 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/callWeakSelfMethodAfterDrop.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | sealed weakable interface IUnit { func getHp(virtual self &&IUnit) int; } 4 | impl IUnit for Muta; 5 | func getHp(self &&Muta) int { 6 | maybeBorrowSelf = lock(self); 7 | return if (maybeBorrowSelf.isEmpty()) { 8 | drop(maybeBorrowSelf); 9 | 42 10 | } else { 11 | (maybeBorrowSelf).get().hp 12 | }; 13 | } 14 | 15 | exported func main() int { 16 | ownMuta = Muta(73); 17 | weakUnit &&IUnit = &&ownMuta; 18 | drop(ownMuta); 19 | return getHp(weakUnit); 20 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/callWeakSelfMethodWhileLive.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | sealed weakable interface IUnit { func getHp(virtual self &&IUnit) int; } 4 | impl IUnit for Muta; 5 | func getHp(self &&Muta) int { 6 | maybeBorrowSelf = lock(self); 7 | return if (maybeBorrowSelf.isEmpty()) { 8 | drop(maybeBorrowSelf); 9 | 0 10 | } else { 11 | drop(maybeBorrowSelf); 12 | 42 13 | }; 14 | } 15 | 16 | exported func main() int { 17 | ownMuta = Muta(73); 18 | weakUnit &&IUnit = &&ownMuta; 19 | return getHp(weakUnit); 20 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/dropThenLockInterface.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | sealed weakable interface IUnit { func getHp(virtual self &IUnit) int; } 4 | impl IUnit for Muta; 5 | func getHp(self &Muta) int { return self.hp; } 6 | 7 | exported func main() int { 8 | ownMuta = Muta(73); 9 | weakUnit &&IUnit = &&ownMuta; 10 | drop(ownMuta); 11 | maybeBorrowUnit = lock(weakUnit); 12 | return if (maybeBorrowUnit.isEmpty()) { 13 | 42 14 | } else { 15 | maybeBorrowUnit.get().getHp() 16 | }; 17 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/dropThenLockStruct.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | exported func main() int { 4 | ownMuta = Muta(73); 5 | weakMuta = &&ownMuta; 6 | drop(ownMuta); 7 | maybeBorrowMuta = lock(weakMuta); 8 | return if maybeBorrowMuta.isEmpty() { 9 | 42 10 | } else { 11 | maybeBorrowMuta.get().hp 12 | }; 13 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/dropWhileLockedInterface.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | sealed weakable interface IUnit { func getHp(virtual self &IUnit) int; } 4 | impl IUnit for Muta; 5 | func getHp(self &Muta) int { return self.hp; } 6 | 7 | exported func main() int { 8 | ownMuta = Muta(73); 9 | weakUnit &&IUnit = &&ownMuta; 10 | maybeBorrowUnit = lock(weakUnit); 11 | drop(ownMuta); 12 | return maybeBorrowUnit.get().getHp(); 13 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/dropWhileLockedStruct.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | exported func main() int { 4 | ownMuta = Muta(73); 5 | weakMuta = &&ownMuta; 6 | maybeBorrowMuta = lock(weakMuta); 7 | drop(ownMuta); 8 | return maybeBorrowMuta.get().hp; 9 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/loadFromWeakable.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | exported func main() int { 4 | return Muta(7).hp; 5 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/lockWhileLiveInterface.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | sealed weakable interface IUnit { func getHp(virtual self &IUnit) int; } 4 | impl IUnit for Muta; 5 | func getHp(self &Muta) int { return self.hp; } 6 | 7 | exported func main() int { 8 | ownMuta = Muta(7); 9 | weakUnit &&IUnit = &&ownMuta; 10 | maybeBorrowUnit = lock(weakUnit); 11 | return if (maybeBorrowUnit.isEmpty()) { 12 | 73 13 | } else { 14 | maybeBorrowUnit.get().getHp() 15 | }; 16 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/lockWhileLiveStruct.vale: -------------------------------------------------------------------------------- 1 | weakable struct Muta { hp int; } 2 | exported func main() int { 3 | ownMuta = Muta(7); 4 | weakMuta = &&ownMuta; 5 | maybeBorrowMuta = lock(weakMuta); 6 | return if maybeBorrowMuta.isEmpty() { 7 | 73 8 | } else { 9 | maybeBorrowMuta.get().hp 10 | }; 11 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/weakFromCRefInterface.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | sealed weakable interface IUnit { func getHp(virtual self &IUnit) int; } 4 | impl IUnit for Muta; 5 | func getHp(self &Muta) int { return self.hp; } 6 | 7 | exported func main() int { 8 | ownMuta = Muta(7); 9 | weakUnit &&IUnit = &&(&ownMuta); 10 | maybeBorrowUnit = lock(weakUnit); 11 | return maybeBorrowUnit.get().getHp(); 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/weakFromCRefStruct.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | exported func main() int { 4 | ownMuta = Muta(7); 5 | print(str(ownMuta.hp)); 6 | weakMuta = &&(&ownMuta); 7 | maybeBorrowMuta = lock(weakMuta); 8 | return maybeBorrowMuta.get().hp; 9 | } -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/weakFromLocalCRefInterface.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | sealed weakable interface IUnit { func getHp(virtual self &IUnit) int; } 4 | impl IUnit for Muta; 5 | func getHp(self &Muta) int { return self.hp; } 6 | 7 | exported func main() int { 8 | ownMuta = Muta(7); 9 | borrowUnit &IUnit = &ownMuta; 10 | weakUnit = &&borrowUnit; 11 | maybeBorrowUnit = lock(weakUnit); 12 | return maybeBorrowUnit.get().getHp(); 13 | } 14 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/weaks/weakFromLocalCRefStruct.vale: -------------------------------------------------------------------------------- 1 | 2 | weakable struct Muta { hp int; } 3 | exported func main() int { 4 | ownMuta = Muta(7); 5 | borrowMuta = &ownMuta; 6 | weakMuta = &&borrowMuta; 7 | maybeBorrowMuta = lock(weakMuta); 8 | maybeBorrowMuta.get().hp 9 | } 10 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/while/foreach.vale: -------------------------------------------------------------------------------- 1 | import v.builtins.opt.*; 2 | import v.builtins.arith.*; 3 | import stdlib.collections.list.*; 4 | 5 | exported func main() int { 6 | results = 7 | foreach i in range(0, 10) { 8 | i 9 | }; 10 | return results.len(); 11 | } 12 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/programs/while/while.vale: -------------------------------------------------------------------------------- 1 | exported func main() int { 2 | a int = 1; 3 | while a < 42 { 4 | set a = a + 1; 5 | } 6 | return a; 7 | } 8 | -------------------------------------------------------------------------------- /Frontend/Tests/test/main/resources/string/string.vale: -------------------------------------------------------------------------------- 1 | 2 | func ==(a str, b str) bool { 3 | streq(a, 0, a.len(), b, 0, b.len()) 4 | } 5 | -------------------------------------------------------------------------------- /Frontend/TypingPass/test/dev/vale/typing/CompilerTestCompilation.scala: -------------------------------------------------------------------------------- 1 | package dev.vale.typing 2 | 3 | import dev.vale.options.GlobalOptions 4 | import dev.vale.parsing.ast.FileP 5 | import dev.vale.{Builtins, FileCoordinateMap, Keywords, PackageCoordinate, Tests, _} 6 | import dev.vale.highertyping._ 7 | 8 | import scala.collection.immutable.{List, ListMap, Map, Set} 9 | import scala.collection.mutable 10 | 11 | object CompilerTestCompilation { 12 | def test(code: String, interner: Interner = new Interner()): TypingPassCompilation = { 13 | val keywords = new Keywords(interner) 14 | new TypingPassCompilation( 15 | interner, 16 | keywords, 17 | Vector(PackageCoordinate.TEST_TLD(interner, keywords)), 18 | Builtins.getModulizedCodeMap(interner, keywords) 19 | .or(FileCoordinateMap.test(interner, code)) 20 | .or(Tests.getPackageToResourceResolver), 21 | TypingPassOptions( 22 | GlobalOptions(true, true, true, true, true), 23 | x => println(x), 24 | false)) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Frontend/Utils/Utils.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Frontend/Utils/src/dev/vale/Profiler.scala: -------------------------------------------------------------------------------- 1 | package dev.vale 2 | 3 | import scala.collection.immutable.HashMap 4 | import scala.collection.mutable 5 | 6 | object Profiler { 7 | def frame[T](profilee: () => T): T = { 8 | profilee() 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Frontend/Utils/src/dev/vale/Timer.scala: -------------------------------------------------------------------------------- 1 | package dev.vale 2 | 3 | class Timer { 4 | var nanosecondsSoFar = 0L; 5 | var startTime = 0L; 6 | 7 | def start(): Unit = { 8 | vassert(startTime == 0) 9 | startTime = System.nanoTime(); 10 | } 11 | 12 | def stop(): Unit = { 13 | vassert(startTime != 0) 14 | nanosecondsSoFar += System.nanoTime() - startTime; 15 | startTime = 0 16 | } 17 | 18 | def getNanosecondsSoFar(): Long = { 19 | vassert(startTime == 0) 20 | nanosecondsSoFar 21 | } 22 | } -------------------------------------------------------------------------------- /Frontend/Utils/src/dev/vale/repeatStr.scala: -------------------------------------------------------------------------------- 1 | package dev.vale 2 | 3 | object repeatStr { 4 | def apply(str: String, n: Int): String = { 5 | var result = ""; 6 | (0 until n).foreach(i => { 7 | result = result + str 8 | }) 9 | result 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Frontend/Utils/src/dev/vale/vpass.scala: -------------------------------------------------------------------------------- 1 | package dev.vale 2 | 3 | // Just here so we have something to attach debug breakpoints to 4 | object vpass { 5 | def apply(): Unit = { } 6 | } 7 | object vbreak { 8 | def apply(): Unit = { 9 | // Put a breakpoint here 10 | vpass() 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Frontend/Vale.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Frontend/Von/Von.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Frontend/lib/commons-lang3-3.13.0.jar: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:82f528cf718c7a3c2f30fc5bc784e3c6a0a10b17605dadb9e16c82ede11e6064 3 | size 632267 4 | -------------------------------------------------------------------------------- /Frontend/lib/functions-framework-api-1.0.1.jar: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1b6bcb1b7c4d9deb3cdd7ddf819be2d71180a4582a8e01529ccccbda62c51ad8 3 | size 7726 4 | -------------------------------------------------------------------------------- /Frontend/lib/lift-json_2.12-3.5.0.jar: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6301a8bc3e1c1e5f50d331493d62fe478d4952afd627624fa2e5130e506441d8 3 | size 371592 4 | -------------------------------------------------------------------------------- /Frontend/lib/paranamer-2.8.jar: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:688cb118a6021d819138e855208c956031688be4b47a24bb615becc63acedf07 3 | size 34654 4 | -------------------------------------------------------------------------------- /Frontend/lib/scalactic_2.12-3.0.8.jar: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5f9ad122f54e9a0112ff4fcaadfb2802d8796f5dde021caa4c831067fca68469 3 | size 722114 4 | -------------------------------------------------------------------------------- /Frontend/lib/scalap-2.12.6.jar: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9132fd2606798b74be48138b596a9df0f7ac52c46c347bf2374942c92d450f97 3 | size 511486 4 | -------------------------------------------------------------------------------- /Frontend/lib/scalatest_2.12-3.0.8.jar: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a4045cea66f3eaab525696f3000d7d610593778bd070e98349a7066f872844cd 3 | size 7546277 4 | -------------------------------------------------------------------------------- /Frontend/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.6.2 2 | -------------------------------------------------------------------------------- /Frontend/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | 2 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") 3 | 4 | -------------------------------------------------------------------------------- /Tester/.gitignore: -------------------------------------------------------------------------------- 1 | testbuild 2 | build 3 | BuiltValeCompiler 4 | -------------------------------------------------------------------------------- /Tester/build.bat: -------------------------------------------------------------------------------- 1 | 2 | %1\valec.exe build tester=src valecutils=..\Utils\src --output_dir build -o testvalec 3 | -------------------------------------------------------------------------------- /Tester/build.sh: -------------------------------------------------------------------------------- 1 | BOOTSTRAPPING_VALEC_DIR="$1" 2 | if [ "$BOOTSTRAPPING_VALEC_DIR" == "" ]; then 3 | echo "Please supply the bootstrapping valec directory." 4 | echo "Example: ~/ValeCompiler-0.1.3.3-Ubuntu" 5 | exit 6 | fi 7 | 8 | 9 | $BOOTSTRAPPING_VALEC_DIR/valec build tester=src valecutils=../Utils/src --pic true --output_dir build -o testvalec || { echo 'build failed' ; exit 1; } 10 | -------------------------------------------------------------------------------- /Tester/exampleinvocation.txt: -------------------------------------------------------------------------------- 1 | ./build/testvalec --frontend_path ../Frontend/Frontend.jar --backend_path ../Backend/build/backend --builtins_dir ../Backend/builtins --valec_path ../Coordinator/build/valec --stdlib_dir ../stdlib --backend_tests_dir ../Backend/test --frontend_tests_dir ../Frontend add64ret 2 | -------------------------------------------------------------------------------- /Utils/.gitignore: -------------------------------------------------------------------------------- 1 | test_tmp 2 | build 3 | -------------------------------------------------------------------------------- /Utils/src/command2/test/test.vale: -------------------------------------------------------------------------------- 1 | import stdlib.testsuite.*; 2 | import stdlib.command.*; 3 | import stdlib.resultutils.*; 4 | 5 | exported func main() { 6 | suite = TestSuite(); 7 | 8 | suite.sub("subprocess", (sts) => { 9 | sts.test("basic", { 10 | if (IsWindows()) { 11 | panic("Implement for windows"); 12 | } 13 | 14 | cat_process = (Subprocess("/bin/cat")).expect("zork a"); 15 | cat_process.handle.write_stdin("hello\n"); 16 | run_result = (cat_process).capture_and_join(); 17 | run_result.stdout.trim() should_equal "hello".slice(); 18 | }); 19 | }); 20 | 21 | (suite).finish(); 22 | } 23 | -------------------------------------------------------------------------------- /Utils/src/listadditions.vale: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValeLang/Vale/6fb98324c0b919a55812376f4d74cfcbfc7f2db7/Utils/src/listadditions.vale -------------------------------------------------------------------------------- /Utils/src/stdlibfixes.vale: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValeLang/Vale/6fb98324c0b919a55812376f4d74cfcbfc7f2db7/Utils/src/stdlibfixes.vale -------------------------------------------------------------------------------- /Utils/test.sh: -------------------------------------------------------------------------------- 1 | 2 | VALEC_DIR="$1" 3 | if [ "$VALEC_DIR" == "" ]; then 4 | echo "Please supply the valec directory." 5 | echo "Example: ~/TheValeCompiler" 6 | exit 7 | fi 8 | shift; 9 | 10 | echo "Building path test..." 11 | rm -rf build 12 | $VALEC_DIR/valec build stdlib=$VALEC_DIR/stdlib/src valecutils=src vtest=src/pathadditions/test || exit 1 13 | echo "Running path test..." 14 | build/main || exit 1 15 | echo "Done testing!" 16 | -------------------------------------------------------------------------------- /docs/Environments, Templatas, and Parent Entries.md: -------------------------------------------------------------------------------- 1 | 2 | # Unstackifieds Can Refer To Variables in Parent Environments (UCRTVPE) 3 | 4 | We need to keep track of what variables have been unstackified. Theres two choices: 5 | 6 | * In the (possibly parent) environment where the local lives, we can have an unstackifieds list 7 | * Put it in the current environment 8 | 9 | The first one doesnt work well, because if we unstackify from within an if-statement like so: 10 | 11 | ``` 12 | m = Marine(10); 13 | if (something) { 14 | drop(m); 15 | return 7; 16 | } 17 | ``` 18 | 19 | we don't want that unstackify to infect the parent environment. Really, we want the if-statement code to handle and propagate any relevant unstackifies. 20 | 21 | Same with restackifies. If there's an unstackified local outside, and an if-statement restackifies like: 22 | 23 | ``` 24 | m = Marine(10); 25 | [_] = m; 26 | if (something) { 27 | set m = Marine(40); 28 | return m.hp; 29 | } 30 | ``` 31 | 32 | then we don't want it to affect the parent environment. -------------------------------------------------------------------------------- /docs/GenerationalReferences.md: -------------------------------------------------------------------------------- 1 | 2 | # Restrict Ptr Param For Next Generation (RPPFNG) 3 | 4 | We *could* invoke a whole pseudo-random number generator every time we allocate an object. 5 | 6 | However, it could be a better compromise to just increment a central number. This central number could be global, or thread-local, or even live on the stack. 7 | 8 | Right now, it lives on the stack, and we pass a restrict pointer through to every call. This is why we do so many +1s when accessing arguments. 9 | 10 | Instead of simply incrementing it, we use an arbitrary prime number, see PRGNA. 11 | 12 | 13 | # Pseudo Random Generation Number Addends (PRGNA) 14 | 15 | Instead of incrementing the next generation number every time we use it, we add an arbitrary prime number to it. 16 | 17 | A given place in the code has that arbitrary number hard-coded. If that instruction is run twice, it'll add the same amount. In other words, the arbitrary number is chosen at compile time. 18 | 19 | These prime numbers are in a big table in the backend. 20 | -------------------------------------------------------------------------------- /docs/RegionBookkeeping.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValeLang/Vale/6fb98324c0b919a55812376f4d74cfcbfc7f2db7/docs/RegionBookkeeping.md -------------------------------------------------------------------------------- /docs/concurrency/ConcurrencyRegions.md: -------------------------------------------------------------------------------- 1 | 2 | ``` 3 | struct Future { 4 | x pthread_thread_t; 5 | } 6 | 7 | func launch(lambda &r'T) 8 | where pure func(&T)'R Futurex'{ 9 | 10 | } 11 | ``` 12 | 13 | imm'T means this coord's region must be immutable 14 | 15 | 16 | 17 | 18 | a future should be a builtin. should probably take in an imm&self for its launch, but not store it. itll contain a ptr to the thread stack block which contains the pthread_thread_t and the condition var at the top. 19 | 20 | the struct itself will be parameterized on that lambda, a pure call func bound, plus the current default region. the launch function wont be parameterized. 21 | 22 | the struct should take an imm region as a generic param. that can ensure it doesnt become mutable again. easy. 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/hgm/HGM Overhead Analysis.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValeLang/Vale/6fb98324c0b919a55812376f4d74cfcbfc7f2db7/docs/hgm/HGM Overhead Analysis.xlsx -------------------------------------------------------------------------------- /docs/notes/SeparatedFFINotes.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | How do we get a pointer to the right mutex to use for the region? I suppose every region metadata will have a pointer to the mutex it should use. If it's a function-bound region, itll point at the thread's mutex, and if it's a mutexed region, itll point at that mutex. 5 | 6 | 7 | -------------------------------------------------------------------------------- /docs/old/Agents.md: -------------------------------------------------------------------------------- 1 | what if a file is an agent? and stdin? that way, all the inputs/outputs 2 | can be recorded! 3 | -------------------------------------------------------------------------------- /docs/old/Async.md: -------------------------------------------------------------------------------- 1 | we probably have to think about async transforms sooner rather than 2 | later. luckily, it neednt be in superstructures (doublecheck that\...) 3 | 4 | how do we do mut across async await? 5 | 6 | probably just dont let it inline the box into the stack. 7 | 8 | can we have something like producer graphs? what theyre really trying to 9 | mimic is async await i think\... 10 | 11 | can we make or, and, +, -, etc and in fact any function take promises? 12 | 13 | isnt this what hyperlining is? but i want it outside ss! 14 | 15 | what is a future but a stream which guarantees only one thing coming in 16 | 17 | we should simplify agent, stream, futures, async, superstructure 18 | together in some clever way. 19 | 20 | after all, a superstructure is identical to an agent\... and all its 21 | nodes\... hmm. 22 | -------------------------------------------------------------------------------- /docs/old/Comparisons _ Related Work.md: -------------------------------------------------------------------------------- 1 | **Swift** 2 | 3 | Definitely the closest, if they ever choose to cross-compile to JVM. 4 | 5 | - Their cross-compiled-to-JVM code will be slower. Because of unowned 6 | > and weak, they\'ll need a ref count in their objects, even in 7 | > production modes. Vale won\'t need it; it will only use it in 8 | > development, and then turn it off for production builds on the 9 | > JVM. These ref counts are atomic, so they\'re not only adding 10 | > refcount overhead, theyre adding **atomic** refcount overhead. 11 | 12 | **Xamarin** 13 | 14 | Xamarin is a framework, that takes control of your entire application. 15 | Vale is about being used alongside everything. One can gradually migrate 16 | to and from Vale. 17 | -------------------------------------------------------------------------------- /docs/old/Compiler/Expressions.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/old/Compiler/Macros.md: -------------------------------------------------------------------------------- 1 | Macros run in the pre stages of the compiler. We could run them in 2 | astronomer, but right now we run them in templar. 3 | 4 | Macros will mostly operate on astrouts, and produce more astrouts. They 5 | don\'t seem to be super aware of the surrounding environment yet, just 6 | producing stuff. 7 | 8 | They can be recursive, with macros causing other macros to be invoked. 9 | For example, there\'s a macro that runs for every interface which makes 10 | an anonymous substruct, and then when we add that struct, a macro is 11 | invoked which generates a constructor for that struct. 12 | 13 | Right now some produce temputs, lets move away from that. 14 | -------------------------------------------------------------------------------- /docs/old/Compiler/Optimization.md: -------------------------------------------------------------------------------- 1 | # Equals and Hash Code Forbidden By Default (EHCFBD) 2 | 3 | We often accidentally use them, and their default implementations are 4 | *very* expensive. 5 | -------------------------------------------------------------------------------- /docs/old/Compiler/Scout.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/old/Compiler/Templar/Patterns.md: -------------------------------------------------------------------------------- 1 | **Destructuring Shared Doesnt Compile To Destroy** (DSDCTD) 2 | 3 | We also destroy shared things. 4 | 5 | Anti-example: \`(x, y, z) = Vec3(3, 4, 5)\` will \*not\* evaluate to a 6 | Destroy, it will evaluate to a bunch of aliasing. However, we \*do\* 7 | have a Destroy2 instruction in every imm struct\'s destructor. That 8 | asserts that there are no more references, and then deallocates it. 9 | -------------------------------------------------------------------------------- /docs/old/Compiler/Vivem.md: -------------------------------------------------------------------------------- 1 | **Vivem Weaks Keep Objects Allocated** (VWKOA) 2 | 3 | In Vivem, a weak reference will keep an object allocated, even though it 4 | might already have been killed by its main owning reference. Itll be in 5 | an undead state where all its members are dead. 6 | 7 | Similar to how Resilient Mode\'s constraint refs work. 8 | -------------------------------------------------------------------------------- /docs/old/Custom Backend.md: -------------------------------------------------------------------------------- 1 | If we had a custom x86 or ARM backend, we could do some crazy stuff. 2 | 3 | We could assume that pointers are 48 bits. 4 | 5 | We could assume that itable pointers are 32 bits (or even 24?), because 6 | theyre in the top global section of memory (at least on linux). 7 | 8 | We could jam all sorts of stuff in those pointers. 9 | 10 | Each region could be 32 bit pointers, if we know it wont exceed 4gb. 11 | -------------------------------------------------------------------------------- /docs/old/Destructors.md: -------------------------------------------------------------------------------- 1 | what makes destructors: 2 | 3 | - generateArraySequenceDestructor called by makeArraySequenceType and 4 | > put into the temputs 5 | 6 | - generateRuntimeSizedArrayDestructor called by 7 | > makeRuntimeSizedArrayType and put into the temputs 8 | 9 | - generateStructDestructor is the default implementation of 10 | > destructor:T, called when the destructor is called. 11 | 12 | what retrieves destructors: 13 | 14 | - getCitizenDestructor is only called by drop. drop produces an 15 | > expression. 16 | 17 | drop is called everywhere. 18 | 19 | So, the answer is that drop is the way to destroy things. 20 | 21 | When we try to drop a share, it only makes a Discard2. But it also puts 22 | a destructor into the temputs. Vivem and eventually Midas will rely on 23 | the fact that it\'s there so they can put it in the code. 24 | -------------------------------------------------------------------------------- /docs/old/Doc Template.md: -------------------------------------------------------------------------------- 1 | normal text 2 | 3 | Title 4 | 5 | # Header 1 6 | 7 | ## Header 2 8 | 9 | ### Header 3 10 | 11 | #### Header 4 12 | 13 | normal text with some code too 14 | 15 | > fn code() 16 | > 17 | > { \... } 18 | -------------------------------------------------------------------------------- /docs/old/Expressions/Implementations for if and match.md: -------------------------------------------------------------------------------- 1 | fn if {(condition: ()bool)(thenBody: ()#T1)Option:#T1 2 | 3 | switch(condition())( 4 | 5 | {(true) thenBody()}, 6 | 7 | {(false) None:T1()}) 8 | 9 | } 10 | 11 | fn else {(thing: Option:#T1, elseBody: ()#T2)(#T1\|#T2) 12 | 13 | switch(thing)( 14 | 15 | {(:Some:T1(inner)) inner}, 16 | 17 | {(:None:T1) elseBody()}) 18 | 19 | } 20 | 21 | fn elseif {(thing: Option:#T1, condition: ()bool)(thenBody: 22 | ()#T2)Option:#T2 23 | 24 | switch(thing)( 25 | 26 | {(:Some:T1(inner)) inner}, 27 | 28 | {(:None:T1) if condition thenBody}) 29 | 30 | } 31 | -------------------------------------------------------------------------------- /docs/old/HGM Overhead Analysis.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValeLang/Vale/6fb98324c0b919a55812376f4d74cfcbfc7f2db7/docs/old/HGM Overhead Analysis.xlsx -------------------------------------------------------------------------------- /docs/old/Interoperability/C++.md: -------------------------------------------------------------------------------- 1 | if we want c++ to call into vale code, we need to generate c functions 2 | that call into the vale code. \...and probably inline them. 3 | 4 | and the generated c++ classes can basically be non-virtual things which 5 | call the c functions which call the vale functions. 6 | 7 | in fact, we can just put non-virtual methods on the c++ classes. we can 8 | generate c++ wrappers for like everything. 9 | 10 | templates will be difficult though. 11 | -------------------------------------------------------------------------------- /docs/old/Loading, Permission, Ownership.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValeLang/Vale/6fb98324c0b919a55812376f4d74cfcbfc7f2db7/docs/old/Loading, Permission, Ownership.xlsx -------------------------------------------------------------------------------- /docs/old/Metaprogramming and Conditional Compilation.md: -------------------------------------------------------------------------------- 1 | Conditional compilation TL;DR: Vale will: 2 | 3 | - have module-level conditional compilation 4 | 5 | - inside a module, have debug-mode conditional compilation of pure 6 | > calls. 7 | 8 | Metaprogramming TL;DR: Vale won\'t have: 9 | 10 | - C preprocessor macros 11 | 12 | - Rust-style macros, where we assemble an AST 13 | 14 | It will have something spiritually similar to C++, but much simpler 15 | syntactically. 16 | -------------------------------------------------------------------------------- /docs/old/Names(1).md: -------------------------------------------------------------------------------- 1 | Give a warning if anyone makes a name starting with ? 2 | 3 | because we have a .? and .?? operator. 4 | 5 | invalid characters for variable names: 6 | 7 | - 8 | 9 | invalid characters to start variable names: 10 | 11 | - 12 | 13 | invalid characters for type names: 14 | 15 | - 16 | 17 | invalid characters to start type names: 18 | 19 | - 20 | -------------------------------------------------------------------------------- /docs/old/Null Mode.md: -------------------------------------------------------------------------------- 1 | in null mode, we can have a boolean alongside every stack variable 2 | saying whether it\'s null. if it is, then any function that uses it will 3 | evaluate to null. eventually it will be consumed and thrown away by a 4 | mut, supposedly\... or we return it from main, in which case it\'s an 5 | error. 6 | 7 | a null can never be stored inside a struct because of this. 8 | 9 | when we call a function, we && every argument together. 10 | 11 | we can do some clever things with bit vectors to know whether 12 | something\'s null. 0 means not null, 1 means null. lets say a function 13 | takes locals 4, 5, and 8. that\'s bits 0x8, 0x10, and 0x80. or them 14 | together to 0x98. & that with the null bit vector. if anything, then the 15 | function result is null. 16 | -------------------------------------------------------------------------------- /docs/old/Optimization/ML.md: -------------------------------------------------------------------------------- 1 | compiler-decided factors: 2 | 3 | \- whether certain fields in structs and functions should be inlined 4 | 5 | \- whether we use RC for all, some, or no immutables 6 | 7 | \- whether we parallelize certain concurrent operations 8 | 9 | \- how many pages per signal in the lightning thread\'s scheme 10 | 11 | we can run with a ton of different combinations of these things, and 12 | then plug the resulting runtimes into machine learning, i think. 13 | -------------------------------------------------------------------------------- /docs/old/Optimization/Optimization.md: -------------------------------------------------------------------------------- 1 | **AOSOA** 2 | 3 | See 4 | [[https://www.reddit.com/r/ProgrammingLanguages/comments/8ars0b/language_supported_aosoa/]{.underline}](https://www.reddit.com/r/ProgrammingLanguages/comments/8ars0b/language_supported_aosoa/) 5 | for how we can do AOSOA with especially the contiguous uniform pool. 6 | 7 | fat pointers with ref count diffs? and theyre committed to the actual 8 | ref count when we point at a different object or the ref goes out of 9 | scope or something. that might be faster because it\'s operating on 10 | registers and stack instead of going into memory to read the object? 11 | 12 | if im the only one with a reference to this immutable data structure, 13 | and i want to modify it, then i\... can. 14 | 15 | if we have reference counting, we can check this, unless we do 16 | optimizations. i think. 17 | 18 | if something is shallowly uniquely referenced, then we can definitely 19 | modify it. thats annotations thats easy to produce, too. 20 | -------------------------------------------------------------------------------- /docs/old/Structs/Structs.md: -------------------------------------------------------------------------------- 1 | ## Structs 2 | 3 | struct namehere:(template params here) { 4 | 5 | methodname:(template params here)(this: &!, a: int) { ... } 6 | 7 | } 8 | 9 | interface IStrengthAffector { 10 | 11 | fn affectStrength(strength: Int): Int; 12 | 13 | } 14 | 15 | you can make an anonymous one like this: 16 | 17 | let affector = IStrengthAffector{\[\](str: Int) str + 3} 18 | 19 | its only argument is the lambda, which is why we can do braces like 20 | that, its a unary function thing 21 | 22 | or perhaps we wanna do it java style? 23 | 24 | let a: IStrengthAffector = {\[\](str: Int) str + 3} 25 | 26 | automatically makes a 27 | 28 | let a: IStrengthAffector = StrengthAffector{ 29 | 30 | override fn calculateStrength(this, strength: Int): Int = str + 3; 31 | 32 | }; 33 | -------------------------------------------------------------------------------- /docs/old/Subprojects/Parser.md: -------------------------------------------------------------------------------- 1 | Right now we have a terrible parser that doesn't do any error checking. 2 | 3 | We should make a hand-rolled parser. 4 | 5 | Can make it in Valence once Scalence is powerful enough... 6 | 7 | \...or can make it in C++ and slowly port it to Valence as time goes on. 8 | -------------------------------------------------------------------------------- /docs/old/Subprojects/Ref Count Improvements.md: -------------------------------------------------------------------------------- 1 | Valence has the potential to be the fastest RC'd language ever (erlang 2 | could have, but it went the GC route instead, boo). 3 | 4 | There was a paper a while ago that talked about ref count coalescing, 5 | which removed 99% of ref count changes. 6 | 7 | Maybe we can do it across function boundaries too, kind of like we 8 | planned with the sidekick thread. 9 | 10 | When moving, we shouldnt increment or decrement. 11 | 12 | We can also track unique references. These, we can increment/decrement 13 | atomically. 14 | 15 | We can track that things have come from arguments, and not 16 | increment/decrement them until they escape the known lifetime of those 17 | arguments. 18 | -------------------------------------------------------------------------------- /docs/old/Superstructure/Querying.md: -------------------------------------------------------------------------------- 1 | Can query an ivytree. 2 | 3 | /games/(\*)/players/(\*)/\[name='Verdagon'\] 4 | 5 | (//Function2).0 6 | -------------------------------------------------------------------------------- /docs/old/Superstructure/Untitled document.md: -------------------------------------------------------------------------------- 1 | Snapshot is a templated structure, which is built in to the compiler. 2 | 3 | On the left is Astronaut, on the right is Snapshot:Astronaut. 4 | 5 | struct Astronaut { 6 | 7 | (v.id): I32; 8 | 9 | name: Str; 10 | 11 | planet: &Planet; 12 | 13 | } 14 | 15 | struct Snapshot:Astronaut { 16 | 17 | (v.id): I32; 18 | 19 | name: Str; 20 | 21 | planet: I32; 22 | 23 | } 24 | 25 | Note that \"planet\" is an \"I32\" in the snapshot. 26 | -------------------------------------------------------------------------------- /docs/old/Templates/Solver.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/old/Threading.md: -------------------------------------------------------------------------------- 1 | we might need to send a cluster of mutables at the same time from one 2 | thread to another, in case they\'re heavily interconnected. that way 3 | debug mode can trace through them to make sure theyre a complete clique 4 | and nothing outside references any of them. 5 | 6 | for threads, tracer is only invoked on mutables when we send them across 7 | thread boundaries. 8 | 9 | thread tracers are given a pointer to a struct containing: 10 | 11 | \- hash set of owning pointers 12 | 13 | \- hash map of borrow pointers to int count. 14 | 15 | \- hash set of immutable things 16 | 17 | when we send something, we\'ll trace it to establish those maps. 18 | 19 | checks: 20 | 21 | \- borrows is a subset of ownings 22 | 23 | \- ownings\' borrow count is equal to whats in that borrow count map. 24 | 25 | it will increment the orca counts of all the immutables that we\'re 26 | sending across. 27 | -------------------------------------------------------------------------------- /docs/old/Troubleshooting.md: -------------------------------------------------------------------------------- 1 | \[100%\] Linking CXX executable valec 2 | 3 | /usr/bin/ld: cannot find -lz 4 | 5 | collect2: error: ld returned 1 exit status 6 | 7 | make\[2\]: \*\*\* \[CMakeFiles/valec.dir/build.make:574: valec\] Error 1 8 | 9 | make\[1\]: \*\*\* \[CMakeFiles/Makefile2:73: CMakeFiles/valec.dir/all\] 10 | Error 2 11 | 12 | make: \*\*\* \[Makefile:130: all\] Error 2 13 | 14 | sudo apt-get install zlib1g-dev 15 | 16 | FileNotFoundError: \[Errno 2\] No such file or directory: \'java\': 17 | \'java\' 18 | 19 | sudo apt-get install default-jre 20 | 21 | FileNotFoundError: \[Errno 2\] No such file or directory: \'clang\': 22 | \'clang\' 23 | 24 | sudo apt-get install clang-7 25 | -------------------------------------------------------------------------------- /docs/old/Vale FAQ.md: -------------------------------------------------------------------------------- 1 | **So they\'re basically like borrow references but checked at run 2 | time?** 3 | 4 | Yep, you got it! It\'s nice because it\'s easier than borrow references, 5 | and allows aliasing. 6 | 7 | And, since 95% of them are elided at run-time and Vale\'s ownership 8 | semantics give them perfect branch prediction, the run-time cost should 9 | be negligible. If that\'s still too much, we can use region borrow 10 | checking to opt-in to zero-cost references where we want (preferably 11 | once we\'ve profiled and identified the hotspots!) 12 | 13 | And then if that\'s not enough, one might also use bump-calling (and 14 | maybe arena-calling if we decide to add that in), which give us 15 | zero-cost references while keeping our safety. 16 | 17 | For everywhere else, we stick with the easy approach for faster 18 | development ;) 19 | -------------------------------------------------------------------------------- /docs/old/Voids and Discarding.md: -------------------------------------------------------------------------------- 1 | ## Voids Dont Need Discarding 2 | 3 | (VDND) 4 | 5 | The templar Discards anything when the reference goes away, even Void. 6 | 7 | (We don\'t say \"it has to discard everything except for primitives\" 8 | because strings can be rather large and probably refcounted) 9 | 10 | Just for simplicity, the templar will actually discard anything even if 11 | it knows it\'s void, because it prefers to be consistent and not 12 | special-case void (which would lead to templating problems). 13 | 14 | Even hammer does have voids flying around, as zero byte objects. 15 | However, when they get to the end of their life, they just disappear, 16 | rather than being Discarded. 17 | 18 | In other words, hammer turns Discard2 into DiscardH for everything but 19 | void. 20 | 21 | The hammer has two instructions that return nothing (as opposed to 22 | Void): 23 | 24 | - ~~Return~~ Made return return a Never. 25 | 26 | - Discard 27 | -------------------------------------------------------------------------------- /docs/old/superstructures1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValeLang/Vale/6fb98324c0b919a55812376f4d74cfcbfc7f2db7/docs/old/superstructures1.jpg -------------------------------------------------------------------------------- /docs/old/superstructures2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValeLang/Vale/6fb98324c0b919a55812376f4d74cfcbfc7f2db7/docs/old/superstructures2.jpg -------------------------------------------------------------------------------- /docs/old/superstructures2b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ValeLang/Vale/6fb98324c0b919a55812376f4d74cfcbfc7f2db7/docs/old/superstructures2b.jpg -------------------------------------------------------------------------------- /docs/regions/RegionsLayout.md: -------------------------------------------------------------------------------- 1 | 2 | # Regions Must Be 16 Byte Aligned (RMB16BA) 3 | 4 | See URSL, it requires regions to be at a 16 byte alignment so that we can pack it into 32B universal refs. 5 | -------------------------------------------------------------------------------- /scripts/VERSION: -------------------------------------------------------------------------------- 1 | 0.2.1.0 -------------------------------------------------------------------------------- /scripts/all/README: -------------------------------------------------------------------------------- 1 | Vale Compiler, version {valec_version} 2 | http://vale.dev/ 3 | 4 | To run a program: 5 | {valec_exe} build [options] [module directory mappings] 6 | 7 | Run `{valec_exe} help build` for more. 8 | 9 | Example: 10 | {valec_exe} build --output_dir target hello=.{sep}samples{sep}helloworld 11 | target{sep}main 12 | -------------------------------------------------------------------------------- /scripts/all/helloworld/main.vale: -------------------------------------------------------------------------------- 1 | import stdlib.*; 2 | 3 | exported func main() { 4 | println("Hello world!"); 5 | } 6 | -------------------------------------------------------------------------------- /scripts/all/valec-help.txt: -------------------------------------------------------------------------------- 1 | Vale Compiler, version {valec_version} 2 | http://vale.dev/ 3 | 4 | USAGE: 5 | {valec_exe} [subcommand] 6 | 7 | SUBCOMMANDS: 8 | help Print this help. 9 | build Compile Vale source files. 10 | 11 | Run `{valec_exe} help [subcommand]` for help on a specific subcommand. 12 | -------------------------------------------------------------------------------- /scripts/all/valec-version.txt: -------------------------------------------------------------------------------- 1 | Vale Compiler, version {valec_version} 2 | http://vale.dev/ 3 | -------------------------------------------------------------------------------- /scripts/ubuntu/README: -------------------------------------------------------------------------------- 1 | Vale Compiler, version 0.2 2 | http://vale.dev/ 3 | 4 | To run a program: 5 | valec.exe build [options] [module directory mappings] 6 | 7 | Run `./valec help build` for more. 8 | 9 | Example: 10 | ./valec build --output_dir target hello=./samples/helloworld 11 | target/main 12 | -------------------------------------------------------------------------------- /scripts/windows/README.txt: -------------------------------------------------------------------------------- 1 | Vale Compiler, version 0.2 2 | http://vale.dev/ 3 | 4 | To run a program: 5 | valec.exe build [options] [module directory mappings] 6 | 7 | Run `valec.exe help build` for more. 8 | 9 | Example: 10 | valec.exe build --output_dir target hello=./samples/helloworld 11 | target\main.exe 12 | -------------------------------------------------------------------------------- /scripts/windows/install-compiler-prereqs.bat: -------------------------------------------------------------------------------- 1 | 2 | echo Downloading minimal LLVM... 3 | 4 | powershell -c "$ProgressPreference = 'SilentlyContinue' ; Invoke-WebRequest -Uri 'https://github.com/Verdagon/LLVMWinMinimal/releases/download/v1.3/LLVM16.zip' -OutFile '%temp%\LLVM16.zip'" 5 | mkdir %1 6 | tar xf "%temp%\LLVM16.zip" -C %1 7 | dir %1 8 | 9 | echo Downloading bootstrapping Vale compiler... 10 | 11 | powershell -c "$ProgressPreference = 'SilentlyContinue' ; Invoke-WebRequest -Uri 'https://github.com/ValeLang/Vale/releases/download/v0.2.0/Vale-Windows-0.2.0.27.zip' -OutFile '%temp%\BootstrappingValeCompiler.zip'" 12 | mkdir %2 13 | tar xf "%temp%\BootstrappingValeCompiler.zip" -C %2 14 | -------------------------------------------------------------------------------- /stdlib/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /src/main.vale 3 | test_tmp 4 | -------------------------------------------------------------------------------- /stdlib/src/cast.vale: -------------------------------------------------------------------------------- 1 | 2 | func void() { } 3 | 4 | func str(b bool) str { 5 | if (b) { "true" } else { "false" } 6 | } 7 | 8 | func +(i int, s str) str { 9 | i.str() + s 10 | } 11 | 12 | func +(i int, s StrSlice) str { 13 | i.str() + s.str() 14 | } 15 | 16 | func +(s str, i int) str { 17 | s + i.str() 18 | } 19 | 20 | func +(s str, i i64) str { 21 | s + i.str() 22 | } 23 | func +(i i64, s str) str { 24 | i.str() + s 25 | } 26 | 27 | func +(s str, b bool) str { 28 | s + str(b) 29 | } 30 | 31 | func +(b bool, s str) str { 32 | str(b) + s 33 | } 34 | 35 | func +(f float, s str) str { 36 | str(f) + s 37 | } 38 | 39 | func +(s str, f float) str { 40 | s + str(f) 41 | } 42 | -------------------------------------------------------------------------------- /stdlib/src/collections/hashset/hash_set_iter.vale: -------------------------------------------------------------------------------- 1 | 2 | 3 | struct HashSetIter { 4 | table &Array>; 5 | pos! int; 6 | } 7 | 8 | func begin(map &HashSet) HashSetIter { 9 | HashSetIter(&map.table, 0) 10 | } 11 | 12 | func next(iter &HashSetIter) Opt<&K> { 13 | while iter.pos < iter.table.len() { 14 | this_pos = set iter.pos = iter.pos + 1; 15 | if not iter.table[this_pos].isEmpty() { 16 | node = &iter.table[this_pos].get(); 17 | return Some<&K>(node); 18 | } 19 | } 20 | return None<&K>(); 21 | } 22 | 23 | 24 | 25 | func each( 26 | self &HashSet, 27 | func F) 28 | void 29 | where func drop(F)void, func(&F, &K)void { 30 | index = 0; 31 | while (index < self.table.len()) { 32 | maybeNode = self.table[index]; 33 | if not(maybeNode.isEmpty()) { 34 | func(maybeNode.get()); 35 | } 36 | set index = index + 1; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /stdlib/src/collections/list/list_iter.vale: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | struct ListIter where E Ref { 5 | list_array &Array; 6 | pos! int; 7 | } 8 | 9 | func begin(list &List) ListIter { 10 | ListIter(list.array, 0) 11 | } 12 | 13 | func next(iter &ListIter) Opt<&E> { 14 | if iter.pos < iter.list_array.len() { 15 | Some<&E>(iter.list_array[set iter.pos = iter.pos + 1]) 16 | } else { 17 | None<&E>() 18 | } 19 | } 20 | 21 | 22 | 23 | struct ListEntriesIter where E Ref { 24 | list_array &Array; 25 | pos! int; 26 | } 27 | func entries(list &List) ListEntriesIter { 28 | ListEntriesIter(&list.array, 0) 29 | } 30 | func begin(iter &ListEntriesIter) ListEntriesIter { 31 | ListEntriesIter(iter.list_array, iter.pos) 32 | } 33 | func next(iter &ListEntriesIter) Opt<(int, &E)> { 34 | if iter.pos < iter.list_array.len() { 35 | Some<(int, &E)>((iter.pos, iter.list_array[set iter.pos = iter.pos + 1])) 36 | } else { 37 | None<(int, &E)>() 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /stdlib/src/command/test/test.vale: -------------------------------------------------------------------------------- 1 | import stdlib.testsuite.*; 2 | import stdlib.command.*; 3 | import stdlib.resultutils.*; 4 | 5 | exported func main() { 6 | suite = TestSuite(); 7 | 8 | suite.sub("subprocess", (sts) => { 9 | sts.test("basic", { 10 | if (IsWindows()) { 11 | panic("Implement for windows"); 12 | } 13 | 14 | cat_process = (Subprocess("/bin/cat")).expect("zork a"); 15 | cat_process.handle.write_stdin("hello\n"); 16 | run_result = (cat_process).capture_and_join(); 17 | run_result.stdout.trim() should_equal "hello".slice(); 18 | }); 19 | }); 20 | 21 | (suite).finish(); 22 | } 23 | -------------------------------------------------------------------------------- /stdlib/src/date/date.vale: -------------------------------------------------------------------------------- 1 | 2 | extern func UnixTimestamp() i64; 3 | -------------------------------------------------------------------------------- /stdlib/src/date/native/date.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "stdlib/UnixTimestamp.h" 4 | 5 | extern int64_t stdlib_UnixTimestamp() { 6 | return (unsigned long)time(NULL); 7 | } 8 | -------------------------------------------------------------------------------- /stdlib/src/error/error.vale: -------------------------------------------------------------------------------- 1 | struct Call { 2 | name str; 3 | } 4 | 5 | interface Error { 6 | func description(virtual self &Error) str; 7 | func trace(virtual self &Error) List; 8 | } 9 | -------------------------------------------------------------------------------- /stdlib/src/ifunction/ifunction1.vale: -------------------------------------------------------------------------------- 1 | 2 | interface IFunction1 M { 3 | func __call(virtual self &IFunction1, p1 P1) R; 4 | } 5 | -------------------------------------------------------------------------------- /stdlib/src/logic.vale: -------------------------------------------------------------------------------- 1 | 2 | func !=(a &T, b &T) bool 3 | where func ==(&T, &T)bool { 4 | not (a == b) 5 | } 6 | 7 | func and(a bool, b bool) bool { a and b } 8 | func or(a bool, b bool) bool { a or b } -------------------------------------------------------------------------------- /stdlib/src/math/native/mathnative.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "stdlib/fsqrt.h" 4 | #include "stdlib/lshift.h" 5 | #include "stdlib/rshift.h" 6 | #include "stdlib/xor.h" 7 | 8 | extern double stdlib_fsqrt(double x) { 9 | return sqrt(x); 10 | } 11 | 12 | extern int64_t stdlib_lshift(int64_t x, int32_t by) { 13 | return x << by; 14 | } 15 | extern int64_t stdlib_rshift(int64_t x, int32_t by) { 16 | return x >> by; 17 | } 18 | extern int64_t stdlib_xor(int64_t a, int64_t b) { 19 | return a ^ b; 20 | } 21 | extern int64_t stdlib_i64(int32_t x) { 22 | return x; 23 | } 24 | -------------------------------------------------------------------------------- /stdlib/src/mtpid/mtpid.vale: -------------------------------------------------------------------------------- 1 | // MTPID stands for Micro Time Process ID 2 | // It's basically a u64 with both the process ID and microsecond timestamp in it 3 | 4 | func MtpId() i64 { 5 | MtpIdExtern() 6 | } 7 | 8 | extern func MtpIdExtern() i64; 9 | -------------------------------------------------------------------------------- /stdlib/src/os/native/os.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stdlib/IsWindows.h" 3 | 4 | int8_t stdlib_IsWindows(void) { 5 | #ifdef _WIN32 6 | return 1; 7 | #else 8 | return 0; 9 | #endif 10 | } 11 | -------------------------------------------------------------------------------- /stdlib/src/os/os.vale: -------------------------------------------------------------------------------- 1 | 2 | extern func IsWindows() bool; -------------------------------------------------------------------------------- /stdlib/src/panic.vale: -------------------------------------------------------------------------------- 1 | 2 | func __pretend() T { __vbi_panic() } 3 | 4 | func vassert(cond bool) { 5 | vassert(cond, "Assertion failed!"); 6 | } 7 | 8 | func vassert(cond bool, msg str) { 9 | if (cond == false) { 10 | println(msg); 11 | __vbi_panic(); 12 | } 13 | } 14 | 15 | func vassertEq(a &T, b &T) void 16 | where func ==(&T, &T)bool { 17 | vassert(a == b, "Assertion failed, not equal!"); 18 | } 19 | 20 | func vassertEq(a &T, b &T, msg str) void 21 | where func ==(&T, &T)bool { 22 | vassert(a == b, msg); 23 | } 24 | -------------------------------------------------------------------------------- /stdlib/src/print.vale: -------------------------------------------------------------------------------- 1 | 2 | func println(s str) void { 3 | print(s + "\n"); 4 | } 5 | 6 | func println(i int) void { 7 | print(str(i) + "\n"); 8 | } 9 | 10 | func println(b bool) void { 11 | print(str(b) + "\n"); 12 | } 13 | 14 | func print(i int) void { 15 | print(str(i)); 16 | } 17 | 18 | func print(b bool) void { 19 | print(str(b)); 20 | } 21 | -------------------------------------------------------------------------------- /stdlib/src/resultutils/resultutils.vale: -------------------------------------------------------------------------------- 1 | 2 | func get_or(result &Result, default &OkType) &OkType { 3 | if result.is_ok() { 4 | (result).expect("yikes") 5 | } else { 6 | default 7 | } 8 | } 9 | 10 | func get_or(result Result, func &F) 11 | OkType 12 | where func(&F, ErrType)OkType 13 | { 14 | if result.is_ok() { 15 | (result).expect("rubbish") 16 | } else { 17 | func((result).expect_err("holy smokes")) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /stdlib/src/stdin/stdin.vale: -------------------------------------------------------------------------------- 1 | 2 | extern func stdinReadInt() int; 3 | 4 | extern func getch() int; 5 | -------------------------------------------------------------------------------- /stdlib/src/test/stdlibtests.vale: -------------------------------------------------------------------------------- 1 | import stdlib.stringutils.*; 2 | import stdlib.*; 3 | import stdlib.testsuite.*; 4 | 5 | exported func main() { 6 | suite = TestSuite(); 7 | suite.test("Concat float and string", { 8 | vassert(len("moo" + 16.5) >= len("moo16")); 9 | }); 10 | suite.test("Array iter entries", { 11 | arr = [](5, {_ * 2}); 12 | sum = 0; 13 | foreach [i, x] in arr.entries() { 14 | set sum = sum + i + x; 15 | } 16 | vassert(sum == 30); 17 | }); 18 | (suite).finish(); 19 | } 20 | --------------------------------------------------------------------------------