Skip to content

Commit 32df8bf

Browse files
committed
0.1.4 release!
Optimizations: * Eagerly calculated hashes, and switched from lists to vecs. 10-11x speedup! * Added Solver, the next generics solver. Uses normalized rules, much more optimizable. * New list uses the new arrays, should be much faster User-visible language changes: * Now two kinds of non-owning reference: borrow ref like `&Ship` and pointer ref like `*Ship`. Midas will soon treat these differently. * Added break * Added foreach * Added basic variadic members! * Added new functions: range(int, int), i64(i32), migrate for arrays * Now need `sealed` on the interface to define abstract functions outside an interface * All parameters need a type. `fn do(callable)` -> `fn do<F>(callable F)` * Destructors: * Now need #!DeriveStructDrop now to make custom destructors. * Custom destructors are now called `drop`, not `destructor`. * Syntax changes: * Changed pack destructures from `(...)` to `[...]` * Changed tuples from `[...]` to `(...)` * `fn` is now `func` * Changed lambda syntax: * (x){ x + 5 } is now x => x + 5 * (x, y){ moo(); foo(); } is now (x, y) => { moo(); foo(); } * Changed `rules(...)` to `where ...` * Moved struct's mutability specifier to before rules * `= 5;` is now just `5`, like Scala and Rust * Put attributes (pure, extern, export, abstract, etc) before fn. export is now exported. * Arrays: * Changed making syntax, [vary *](5, {_}) is now [](5, {_)} or Array(...) * We can now destroy an RSA with `() = arr;` to mirror structs. * Array semantics: * Array<M, V, E> is now Array<M, E>, all arrays are now varying. * Added push/pop support for arrays. * Added .capacity() for arrays, plus an instructino for it. * Extern boundary: * Obviated ValeReleaseMessage, added _vasp for getting message sizes * We no longer need artificial pointers on the extern boundary! * Misc: * Removed IFunction1 from builtins, its no longer needed by the compiler. * Added i64 to string * Made a functor struct, to give to the array instructions, since they need a 'this' object basically Tooling changes: * Changed how install scripts pull in stdlib project * Merged package-unix/windows scripts into others * Cleaned up Driver build process * Made a Utils module to use in Driver and Tester, and it has stdlib additions * Added census, asan, debug_output flags * Made it move the old build directory to a random /tmp subdir * New CI, thanks to kevin! * Using supplied bootstrapping valec+stdlib for Driver and Tester now * Cleaned out old scripts * Clarified flags for Driver * Made the scripts test the unzipped zip * Made the scripts return 1 if they fail * Removed valec.py from zip * Split windows script into an install and build script, like mac and linux * Added Driver, a.k.a. valec * Added Tester, which runs our Midas tests now Compiler changes: * Rewrote most of the parser to manual recursive descent * Added Void back in, no longer reusing empty tuples * Fixed some Never handling bugs * Things after Never aren't even evaluated, Hammer strips them out. * Made Midas BlockState a linked list, so we can jump to the end of nearest loop * Made Consecutor the only thing that could repeat expressions. Most blocks contain them now. * Moved drop_into into builtins * Made tuple an extern struct, using variadic members. * Removed RawArray, it doesn't fit anymore since all RSAs are varying. * Added an error for the rune type solver * Separated a GlobalOptions module * Removed astronomers specific rules * Removed types from the astronomer rules. * Learned: It's not always a great thing to denormalize data, it leads to inconsistency opportunities. An instance of premature optimization likely. Now I'm questioning why .ll does this. * Added better humanizing of errors * Added a MUCH better solver error printer * Brought back the distinction between declaration names and imprecise names * Made a better distinction between drop and free * Fixed build failure counting bug in Tester * Took out localRunes and knowableRunes from Astronomer, moved some of that logic back into astronomer. * Learned: It's not always a great thing to pull as much logic as possible out of Templar. In this case, reducing the amount of code in Templar actually increased its complexity, ironically. * Changed some astronomer tests into integration tests, feeding actual vale source code now. * Learned: Unit tests have a high cost in maintaining the inputs. Perhaps unit tests only make sense on very established chunks of code. * Moved a bunch of hardcoded functions (weaks, drop, free, array len, panic) to actual vale code. * Removed special PackTT type. * Added the "macro" concept, for any syntactical sugar features (or semantic sugar? like anonymous substructs, theyre kind of semantic sugar I guess?) * Moved drop functions into macros. * Moved anonymous substruct functionality into macros. * Better distinction between a template name and a stamped name, see CitizenNameT vs CitizenTemplateNameT. * Fixed types starting with _, like __Never * Added free() functions for interfaces, which then call virtualfree(). Now, there is a normal free() function for every immutable type. * Fixed printing exceptions twice in tests * Added a "Location In Function" notion, so places in the code are marked by tree-shaped paths * Made impl rules sane again, no more NMORFI! * Changed the default namespace to __vale, for Midas * Made the compiler spit out a different .vast per package * Put the generated files in include/ and abi/ * Put generated .vast files into vast/, and .vpst files into vpst/ * Fixed exported mutable refs, they no longer require their members be exported too * Using = instead of : for module mappings in the CLI * Updated build instructions * Added NodeEnvironment to templar for breaks too * Made most of the expressiontemplar and nearby templars use NodeEnvironmentBox * renamed constraint to borrow * cleaned up precise vs imprecise names * removed Maybe from variable uses * Replaced builtin functions with generators * Fixed kldc test
1 parent ffca9bd commit 32df8bf

File tree

448 files changed

+13911
-8332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

448 files changed

+13911
-8332
lines changed

.github/workflows/ci.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v2
1717
- name: install prereqs
18-
run: cmd /c '.\install-compiler-prereqs-windows.bat C:\llvm-install-minimum C:\ValeCompiler-0.1.3.4-Win'
18+
run: cmd /c '.\install-compiler-prereqs-windows.bat C:\llvm-install-minimum C:\ValeCompiler-0.1.3.4-Win C:\stdlib'
1919
- name: run vcvars and build-compiler-windows.bat
20-
run: cmd /c '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && .\build-compiler-windows.bat C:\llvm-install-minimum C:\ValeCompiler-0.1.3.4-Win'
20+
run: cmd /c '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && .\build-compiler-windows.bat C:\llvm-install-minimum C:\ValeCompiler-0.1.3.4-Win C:\stdlib'
2121

2222
build_and_test_ubuntu:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- uses: actions/checkout@v2
2626
- name: install prereqs
27-
run: ./install-compiler-prereqs-linux.sh ~/ValeLLVM ~/ValeCompiler-0.1.3.3-Ubuntu
27+
run: ./install-compiler-prereqs-linux.sh ~/ValeLLVM ~/ValeCompiler-0.1.3.3-Ubuntu ~/stdlib
2828
- name: build compiler
29-
run: ./build-compiler-linux.sh ~/ValeLLVM/clang+llvm-11.1.0-x86_64-linux-gnu-ubuntu-20.10 ~/ValeCompiler-0.1.3.3-Ubuntu
29+
run: ./build-compiler-linux.sh ~/ValeLLVM/clang+llvm-11.1.0-x86_64-linux-gnu-ubuntu-20.10 ~/ValeCompiler-0.1.3.3-Ubuntu ~/stdlib
3030

3131
build_and_test_mac:
3232
runs-on: macos-latest
3333
steps:
3434
- uses: actions/checkout@v2
3535
- name: install prereqs
36-
run: ./install-compiler-prereqs-mac.sh ~/ValeCompiler-0.1.3.3-Mac
36+
run: ./install-compiler-prereqs-mac.sh ~/ValeCompiler-0.1.3.3-Mac ~/stdlib
3737
- name: build compiler
38-
run: source ~/.zshrc && ./build-compiler-mac.sh ~/ValeCompiler-0.1.3.3-Mac
38+
run: source ~/.zshrc && ./build-compiler-mac.sh ~/ValeCompiler-0.1.3.3-Mac ~/stdlib

Driver/build-linux.sh

-4
This file was deleted.

Driver/build-mac.sh

-4
This file was deleted.

Driver/build.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
%1\valec.exe build driver=src stdlib=%1\stdlib\src --output_dir build -o valec
2+
%1\valec.exe build driver=src stdlib=%1\stdlib\src valecutils=../Utils/src --output_dir build -o valec

Driver/build.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ if [ "$BOOTSTRAPPING_VALEC_DIR" == "" ]; then
55
echo "Example: ~/TheValeCompiler"
66
exit
77
fi
8+
shift;
89

9-
$BOOTSTRAPPING_VALEC_DIR/valec build driver=src stdlib=$BOOTSTRAPPING_VALEC_DIR/stdlib/src --output_dir build -o valec
10+
$BOOTSTRAPPING_VALEC_DIR/valec build driver=src stdlib=$BOOTSTRAPPING_VALEC_DIR/stdlib/src valecutils=../Utils/src --output_dir build -o valec $@

Driver/src/build.vale

+41-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ import stdlib.command.*;
22
import stdlib.flagger.*;
33
import stdlib.path.*;
44

5+
//fn removeAllRecursively(path &Path) {
6+
// if (path.is_dir()) {
7+
// iterdir(path).each((entry){
8+
// removeAllRecursively(entry);
9+
// });
10+
// }
11+
// path.remove();
12+
//}
13+
514
struct ProjectDirectoryDeclaration {
615
project_name str;
716
path Path;
@@ -77,6 +86,24 @@ fn build_stuff(compiler_dir &Path, all_args &Array<imm, final, str>) {
7786
"Whether to print out more detailed errors.",
7887
"true",
7988
"Whether to print out more detailed errors."),
89+
Flag(
90+
"--census",
91+
FLAG_BOOL(),
92+
"Whether to add run-time checks to debug the compiler itself.",
93+
"true",
94+
"Whether to add run-time checks to debug the compiler itself."),
95+
Flag(
96+
"--asan",
97+
FLAG_BOOL(),
98+
"Whether to run with ASan.",
99+
"true",
100+
"Whether to run with ASan."),
101+
Flag(
102+
"--debug_output",
103+
FLAG_BOOL(),
104+
"Whether to print out more detailed errors.",
105+
"true",
106+
"Whether to print out more detailed errors."),
80107
Flag(
81108
"--output_vast",
82109
FLAG_BOOL(),
@@ -167,6 +194,7 @@ fn build_stuff(compiler_dir &Path, all_args &Array<imm, final, str>) {
167194

168195
benchmark = parsed_flags.get_bool_flag("--benchmark", false);
169196
verbose = parsed_flags.get_bool_flag("--verbose", false);
197+
debug_output = parsed_flags.get_bool_flag("--debug_output", false);
170198
include_builtins = parsed_flags.get_bool_flag("--include_builtins", true);
171199
output_vast = parsed_flags.get_bool_flag("--output_vast", true);
172200
reuse_vast = parsed_flags.get_bool_flag("--reuse_vast", false);
@@ -178,6 +206,7 @@ fn build_stuff(compiler_dir &Path, all_args &Array<imm, final, str>) {
178206
flares = parsed_flags.get_bool_flag("--flares", false);
179207
gen_heap = parsed_flags.get_bool_flag("--gen_heap", false);
180208
census = parsed_flags.get_bool_flag("--census", false);
209+
asan = parsed_flags.get_bool_flag("--asan", false);
181210
verify = parsed_flags.get_bool_flag("--verify", false);
182211
debug_symbols = parsed_flags.get_nothing_flag("-g");
183212
llvm_ir = parsed_flags.get_bool_flag("--llvm_ir", false);
@@ -240,6 +269,16 @@ fn build_stuff(compiler_dir &Path, all_args &Array<imm, final, str>) {
240269
panic("Error: --reuse_vast specified, but no .vast files found in " + output_dir.str() + ".");
241270
}
242271
} else {
272+
if (output_dir.exists()) {
273+
dest_dir = GetTempDir()./("old_output_dir_" + str(MtpId()));
274+
if (dest_dir.exists()) {
275+
println("Deleting existing {dest_dir.str()}.");
276+
dest_dir.RemoveDirAll().expect();
277+
vassert(not dest_dir.exists(), "Removing old dir {dest_dir.str()} failed!");
278+
}
279+
println("Moving existing output directory {output_dir.str()} to {dest_dir.str()}.");
280+
output_dir.Rename(&dest_dir).expect();
281+
}
243282
valestrom_process =
244283
invoke_valestrom(
245284
&valestrom_path,
@@ -248,6 +287,7 @@ fn build_stuff(compiler_dir &Path, all_args &Array<imm, final, str>) {
248287
&project_non_vale_input_declarations,
249288
benchmark,
250289
verbose,
290+
debug_output,
251291
include_builtins,
252292
output_vast,
253293
output_vpst,
@@ -400,7 +440,7 @@ fn build_stuff(compiler_dir &Path, all_args &Array<imm, final, str>) {
400440
windows,
401441
&clang_inputs,
402442
&executable_name,
403-
census,
443+
asan,
404444
debug_symbols,
405445
&output_dir);
406446
println("Running:\n" + clang_process.command);

Driver/src/clang.vale

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fn invoke_clang(
44
windows bool,
55
clang_inputs &List<Path>,
66
exe_name str,
7-
census bool,
7+
asan bool,
88
debug_symbols bool,
99
output_dir &Path)
1010
Subprocess {
@@ -51,7 +51,7 @@ Subprocess {
5151
args!.add("-g");
5252
}
5353

54-
if (census) {
54+
if (asan) {
5555
if (windows) {
5656
args!.add("/fsanitize=address");
5757
args!.add("clang_rt.asan_dynamic-x86_64.lib");

Driver/src/main.vale

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import stdlib.command.*;
22
import stdlib.flagger.*;
33
import stdlib.path.*;
4+
import valecutils.pathadditions.*;
5+
import valecutils.mtpid.*;
46

57

68
fn main() export {
@@ -14,6 +16,9 @@ fn main() export {
1416

1517

1618
driver_path = Path(all_args_list.get(0)).resolve();
19+
if (not driver_path.exists()) {
20+
panic("Path {driver_path.str()} does not exist!");
21+
}
1722
compiler_dir = driver_path.directory();
1823

1924
if (all_args_list.len() < 2) {

Driver/src/midas.vale

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Subprocess {
4848
command_line_args!.add("--verify");
4949
}
5050
if (llvm_ir) {
51-
command_line_args!.add("--llvmir");
51+
command_line_args!.add("--llvm_ir");
5252
}
5353
if (print_mem_overhead) {
5454
command_line_args!.add("--print_mem_overhead");

Driver/src/valestrom.vale

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ fn invoke_valestrom(
66
project_non_vale_inputs &List<ProjectNonValeInputDeclaration>,
77
benchmark bool,
88
verbose bool,
9+
debug_output bool,
910
include_builtins bool,
1011
output_vast bool,
1112
output_vpst bool,
@@ -32,6 +33,9 @@ Subprocess {
3233
if (verbose) {
3334
command_line_args!.add("--verbose");
3435
}
36+
if (debug_output) {
37+
command_line_args!.add("--debug_output");
38+
}
3539
if (not include_builtins) {
3640
command_line_args!.add("--include-builtins false");
3741
}

Midas/src/builtins/math.c

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ double __vale_castI64Float(int64_t i) {
1616
int64_t __vale_castFloatI64(double i) {
1717
return (int64_t)i;
1818
}
19+
20+
int32_t __vale_TruncateI64ToI32(int64_t i) {
21+
return (int32_t)i;
22+
}

Midas/src/c-compiler/function/expression.cpp

+75-9
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ Ref translateExpressionInner(
6262
Location::INLINE,
6363
globalState->metalCache->getInt(globalState->metalCache->rcImmRegionId, constantInt->bits));
6464
return wrap(globalState->getRegion(intRef), intRef, resultLE);
65+
} else if (auto constantVoid = dynamic_cast<ConstantVoid*>(expr)) {
66+
// See ULTMCIE for why we load and store here.
67+
auto resultRef = makeVoidRef(globalState);
68+
auto resultLE =
69+
globalState->getRegion(globalState->metalCache->voidRef)
70+
->checkValidReference(FL(), functionState, builder, globalState->metalCache->voidRef, resultRef);
71+
auto loadedLE = makeConstExpr(functionState, builder, resultLE);
72+
return wrap(globalState->getRegion(globalState->metalCache->voidRef), globalState->metalCache->voidRef, loadedLE);
6573
} else if (auto constantFloat = dynamic_cast<ConstantF64*>(expr)) {
6674
// See ULTMCIE for why we load and store here.
6775

@@ -94,6 +102,33 @@ Ref translateExpressionInner(
94102
LLVMBuildRet(builder, toReturnLE);
95103
return wrap(globalState->getRegion(globalState->metalCache->neverRef), globalState->metalCache->neverRef, globalState->neverPtr);
96104
}
105+
} else if (auto breeak = dynamic_cast<Break*>(expr)) {
106+
if (auto nearestLoopBlockStateAndEnd = blockState->getNearestLoopEnd()) {
107+
auto [nearestLoopBlockState, nearestLoopEnd] = *nearestLoopBlockStateAndEnd;
108+
109+
LLVMBuildBr(builder, nearestLoopEnd);
110+
111+
return wrap(
112+
globalState->getRegion(globalState->metalCache->neverRef), globalState->metalCache->neverRef,
113+
globalState->neverPtr);
114+
115+
// buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());
116+
// auto sourceRef = translateExpression(globalState, functionState, blockState, builder, ret->sourceExpr);
117+
// if (ret->sourceType->kind == globalState->metalCache->never) {
118+
// return sourceRef;
119+
// } else {
120+
// auto toReturnLE =
121+
// globalState->getRegion(ret->sourceType)
122+
// ->checkValidReference(FL(), functionState, builder, ret->sourceType, sourceRef);
123+
// LLVMBuildRet(builder, toReturnLE);
124+
// return wrap(
125+
// globalState->getRegion(globalState->metalCache->neverRef), globalState->metalCache->neverRef,
126+
// globalState->neverPtr);
127+
// }
128+
} else {
129+
std::cerr << "Error: found a break not inside a loop!" << std::endl;
130+
exit(1);
131+
}
97132
} else if (auto stackify = dynamic_cast<Stackify*>(expr)) {
98133
buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());
99134
auto refToStore =
@@ -103,7 +138,7 @@ Ref translateExpressionInner(
103138
->checkValidReference(FL(), functionState, builder, stackify->local->type, refToStore);
104139
makeHammerLocal(
105140
globalState, functionState, blockState, builder, stackify->local, refToStore, stackify->knownLive);
106-
return makeEmptyTupleRef(globalState);
141+
return makeVoidRef(globalState);
107142
} else if (auto localStore = dynamic_cast<LocalStore*>(expr)) {
108143
buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());
109144
// The purpose of LocalStore is to put a swap value into a local, and give
@@ -126,6 +161,18 @@ Ref translateExpressionInner(
126161
functionState, builder, localStore->local->type, refToStore);
127162
LLVMBuildStore(builder, toStoreLE, localAddr);
128163
return oldRef;
164+
} else if (auto pointerToBorrow = dynamic_cast<PointerToBorrow*>(expr)) {
165+
buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());
166+
auto sourceRef =
167+
translateExpression(
168+
globalState, functionState, blockState, builder, pointerToBorrow->sourceExpr);
169+
return sourceRef;
170+
} else if (auto borrowToPointer = dynamic_cast<BorrowToPointer*>(expr)) {
171+
buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());
172+
auto sourceRef =
173+
translateExpression(
174+
globalState, functionState, blockState, builder, borrowToPointer->sourceExpr);
175+
return sourceRef;
129176
} else if (auto weakAlias = dynamic_cast<WeakAlias*>(expr)) {
130177
buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());
131178

@@ -284,7 +331,7 @@ Ref translateExpressionInner(
284331
->dealias(
285332
AFL("DestroySSAIntoF"), functionState, builder, consumerType, consumerRef);
286333

287-
return makeEmptyTupleRef(globalState);
334+
return makeVoidRef(globalState);
288335
} else if (auto pushRuntimeSizedArray = dynamic_cast<PushRuntimeSizedArray*>(expr)) {
289336
buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());
290337
auto arrayExpr = pushRuntimeSizedArray->arrayExpr;
@@ -318,8 +365,8 @@ Ref translateExpressionInner(
318365
->checkValidReference(FL(),
319366
functionState, builder, globalState->metalCache->i32Ref, arrayCapacityRef);
320367

321-
auto hasSpaceLE = LLVMBuildICmp(builder, LLVMIntULT, arrayLenLE, arrayCapacityLE, "hasSpace");
322-
buildIf(globalState, functionState, builder, hasSpaceLE, [globalState](LLVMBuilderRef bodyBuilder) {
368+
auto arrayIsFullLE = LLVMBuildICmp(builder, LLVMIntUGE, arrayLenLE, arrayCapacityLE, "hasSpace");
369+
buildIf(globalState, functionState, builder, arrayIsFullLE, [globalState](LLVMBuilderRef bodyBuilder) {
323370
buildPrint(globalState, bodyBuilder, "Error: Runtime-sized array has no room for new element!");
324371
});
325372

@@ -334,7 +381,7 @@ Ref translateExpressionInner(
334381
->dealias(
335382
AFL("pushRuntimeSizedArrayNoBoundsCheck"), functionState, builder, arrayType, arrayRef);
336383

337-
return makeEmptyTupleRef(globalState);
384+
return makeVoidRef(globalState);
338385
} else if (auto popRuntimeSizedArray = dynamic_cast<PopRuntimeSizedArray*>(expr)) {
339386
buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());
340387
auto arrayExpr = popRuntimeSizedArray->arrayExpr;
@@ -363,8 +410,8 @@ Ref translateExpressionInner(
363410
auto indexRef =
364411
wrap(globalState->getRegion(globalState->metalCache->i32Ref), globalState->metalCache->i32Ref, indexLE);
365412

366-
auto hasElementsLE = LLVMBuildICmp(builder, LLVMIntNE, arrayLenLE, constI32LE(globalState, 0), "hasElements");
367-
buildIf(globalState, functionState, builder, hasElementsLE, [globalState](LLVMBuilderRef bodyBuilder) {
413+
auto arrayIsEmptyLE = LLVMBuildICmp(builder, LLVMIntEQ, arrayLenLE, constI32LE(globalState, 0), "hasElements");
414+
buildIf(globalState, functionState, builder, arrayIsEmptyLE, [globalState](LLVMBuilderRef bodyBuilder) {
368415
buildPrint(globalState, bodyBuilder, "Error: Cannot pop element from empty runtime-sized array!");
369416
});
370417

@@ -415,7 +462,7 @@ Ref translateExpressionInner(
415462
assert(false);
416463
}
417464

418-
return makeEmptyTupleRef(globalState);
465+
return makeVoidRef(globalState);
419466
} else if (auto dirsa = dynamic_cast<DestroyImmRuntimeSizedArray*>(expr)) {
420467
buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());
421468
auto consumerType = dirsa->consumerType;
@@ -485,7 +532,7 @@ Ref translateExpressionInner(
485532
->dealias(
486533
AFL("DestroyRSAIntoF"), functionState, builder, consumerType, consumerRef);
487534

488-
return makeEmptyTupleRef(globalState);
535+
return makeVoidRef(globalState);
489536
} else if (auto staticSizedArrayLoad = dynamic_cast<StaticSizedArrayLoad*>(expr)) {
490537
buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());
491538
auto arrayType = staticSizedArrayLoad->arrayType;
@@ -646,6 +693,25 @@ Ref translateExpressionInner(
646693
globalState->getRegion(arrayType)
647694
->dealias(AFL("RSALen"), functionState, builder, arrayType, arrayRefLE);
648695

696+
return sizeLE;
697+
} else if (auto arrayCapacity = dynamic_cast<ArrayCapacity*>(expr)) {
698+
buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());
699+
auto arrayType = arrayCapacity->sourceType;
700+
auto arrayExpr = arrayCapacity->sourceExpr;
701+
bool arrayKnownLive = arrayCapacity->sourceKnownLive || globalState->opt->overrideKnownLiveTrue;
702+
// auto indexExpr = arrayLength->indexExpr;
703+
704+
auto arrayRefLE = translateExpression(globalState, functionState, blockState, builder, arrayExpr);
705+
globalState->getRegion(arrayType)
706+
->checkValidReference(FL(), functionState, builder, arrayType, arrayRefLE);
707+
708+
auto sizeLE =
709+
globalState->getRegion(arrayType)
710+
->getRuntimeSizedArrayCapacity(
711+
functionState, builder, arrayType, arrayRefLE, arrayKnownLive);
712+
globalState->getRegion(arrayType)
713+
->dealias(AFL("RSACapacity"), functionState, builder, arrayType, arrayRefLE);
714+
649715
return sizeLE;
650716
} else if (auto narrowPermission = dynamic_cast<NarrowPermission*>(expr)) {
651717
buildFlare(FL(), globalState, functionState, builder, typeid(*expr).name());

Midas/src/c-compiler/function/expressions/block.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Ref translateBlock(
1414
LLVMBuilderRef builder,
1515
Block* block) {
1616

17-
BlockState childBlockState(globalState->addressNumberer, parentBlockState);
17+
BlockState childBlockState(globalState->addressNumberer, parentBlockState, std::nullopt);
1818

1919
auto resultLE =
2020
translateExpression(globalState, functionState, &childBlockState, builder, block->inner);

Midas/src/c-compiler/function/expressions/construct.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ Ref translateConstruct(
1818
const std::vector<Ref>& memberRefs) {
1919
return globalState->getRegion(desiredReference)
2020
->allocate(
21-
makeEmptyTupleRef(globalState), from, functionState, builder, desiredReference, memberRefs);
21+
makeVoidRef(globalState), from, functionState, builder, desiredReference, memberRefs);
2222
}

Midas/src/c-compiler/function/expressions/destructure.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ Ref translateDestructure(
6060

6161
buildFlare(FL(), globalState, functionState, builder);
6262

63-
return makeEmptyTupleRef(globalState);
63+
return makeVoidRef(globalState);
6464
}

0 commit comments

Comments
 (0)