Skip to content

Commit

Permalink
Only serialize outputs if required (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcauberer committed Mar 23, 2024
1 parent 5b17552 commit d3f2104
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .run/spice.run.xml
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="spice" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="run -O0 -d -ir ../../media/test-project/test.spice" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Spice" TARGET_NAME="spice" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Spice" RUN_TARGET_NAME="spice">
<configuration default="false" name="spice" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="build -O2 -d ../../media/test-project/test.spice" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Spice" TARGET_NAME="spice" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Spice" RUN_TARGET_NAME="spice">
<envs>
<env name="LLVM_ADDITIONAL_FLAGS" value="-lole32 -lws2_32" />
<env name="LLVM_BUILD_INCLUDE_DIR" value="$PROJECT_DIR$/../llvm-project-latest/build/include" />
Expand Down
2 changes: 1 addition & 1 deletion .run/spicetest.run.xml
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="spicetest" type="CMakeGoogleTestRunConfigurationType" factoryName="Google Test" PROGRAM_PARAMS="--update-refs=true" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Spice" TARGET_NAME="spicetest" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Spice" RUN_TARGET_NAME="spicetest" TEST_MODE="SUITE_TEST">
<configuration default="false" name="spicetest" type="CMakeGoogleTestRunConfigurationType" factoryName="Google Test" PROGRAM_PARAMS="--update-refs=false" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Spice" TARGET_NAME="spicetest" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Spice" RUN_TARGET_NAME="spicetest" TEST_MODE="SUITE_TEST">
<envs>
<env name="LLVM_ADDITIONAL_FLAGS" value="-lole32 -lws2_32" />
<env name="LLVM_BUILD_INCLUDE_DIR" value="$PROJECT_DIR$/../llvm-project-latest/build/include" />
Expand Down
52 changes: 12 additions & 40 deletions media/test-project/test.spice
@@ -1,45 +1,17 @@
import "std/data/unordered-map";
import "std/time/timer";
import "std/os/env";
import "bootstrap/lexer/lexer";

f<int> main() {
Timer timer = Timer();
timer.start();

UnorderedMap<int, string> map = UnorderedMap<int, string>(3l);
assert map.getSize() == 0;
assert map.isEmpty();
map.upsert(1, "one");
map.upsert(2, "two");
map.upsert(3, "three");
map.upsert(4, "four");
assert map.getSize() == 4;
assert !map.isEmpty();
assert map.contains(1);
assert map.contains(2);
assert map.contains(3);
assert map.contains(4);
assert !map.contains(5);
assert map.get(1) == "one";
assert map.get(2) == "two";
assert map.get(3) == "three";
assert map.get(4) == "four";
const Result<string> item5 = map.getSafe(5);
assert item5.isErr();
map.remove(2);
assert !map.contains(2);
assert map.getSize() == 3;
map.clear();
assert map.getSize() == 0;
assert map.isEmpty();
map.upsert(1, "one");
map.upsert(1, "one new");
assert map.getSize() == 1;
assert map.get(1) == "one new";
map.remove(1);
assert map.isEmpty();

timer.stop();
printf("All assertions passed in %d microseconds!\n", timer.getDurationInMicros());
String filePath = getEnv("SPICE_STD_DIR") + "/../test/test-files/bootstrap-compiler/standalone-lexer-test/test-file.spice";
Lexer lexer = Lexer(filePath.getRaw());
unsigned long tokenCount = 0l;
while (!lexer.isEOF()) {
Token token = lexer.getToken();
token.print();
lexer.advance();
tokenCount++;
}
printf("\nLexed tokens: %d\n", tokenCount);
}

/*import "bootstrap/util/block-allocator";
Expand Down

0 comments on commit d3f2104

Please sign in to comment.