Ludovic 'Archivist' Lagouardette 1 year ago
parent
commit
3caa6e43a8
7 changed files with 50 additions and 5 deletions
  1. +3
    -2
      CMakeLists.txt
  2. +14
    -2
      src/molasses/generator_primitives_x86_64_linux.cpp
  3. +3
    -0
      tests/001.exp
  4. +3
    -0
      tests/002.exp
  5. +3
    -0
      tests/003.exp
  6. +7
    -0
      tests/005.exp
  7. +17
    -1
      tests/006.exp

+ 3
- 2
CMakeLists.txt View File

@ -1,8 +1,6 @@
cmake_minimum_required(VERSION 3.24) cmake_minimum_required(VERSION 3.24)
project(sugar) project(sugar)
# find_package(cppfront REQUIRED)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
enable_testing() enable_testing()
@ -33,3 +31,6 @@ add_expect_test(id003 ./tests/003.exp)
add_expect_test(id004 ./tests/004.exp) add_expect_test(id004 ./tests/004.exp)
add_expect_test(id005 ./tests/005.exp) add_expect_test(id005 ./tests/005.exp)
add_expect_test(id006 ./tests/006.exp) add_expect_test(id006 ./tests/006.exp)

+ 14
- 2
src/molasses/generator_primitives_x86_64_linux.cpp View File

@ -5,7 +5,7 @@ namespace molasses {
namespace unix_system { namespace unix_system {
#ifdef linux
struct syscall1 { struct syscall1 {
int64_t operator()(int64_t syscall_id, int64_t p1) const { int64_t operator()(int64_t syscall_id, int64_t p1) const {
int64_t ret; int64_t ret;
@ -71,6 +71,7 @@ namespace molasses {
return ret; return ret;
} }
}; };
#endif
} }
@ -317,7 +318,9 @@ namespace molasses {
) { ) {
// TODO: handle errors // TODO: handle errors
} }
#ifdef linux
unix_system::syscall1{}(get<int64_t>(value_0), get<int64_t>(value_1)); unix_system::syscall1{}(get<int64_t>(value_0), get<int64_t>(value_1));
#endif
} }
) )
); );
@ -344,7 +347,9 @@ namespace molasses {
) { ) {
// TODO: handle errors // TODO: handle errors
} }
#ifdef linux
unix_system::syscall2{}(get<int64_t>(value_0), get<int64_t>(value_1), get<int64_t>(value_2)); unix_system::syscall2{}(get<int64_t>(value_0), get<int64_t>(value_1), get<int64_t>(value_2));
#endif
} }
) )
); );
@ -374,7 +379,9 @@ namespace molasses {
) { ) {
// TODO: handle errors // TODO: handle errors
} }
#ifdef linux
unix_system::syscall3{}(get<int64_t>(value_0), get<int64_t>(value_1), get<int64_t>(value_2), get<int64_t>(value_3)); unix_system::syscall3{}(get<int64_t>(value_0), get<int64_t>(value_1), get<int64_t>(value_2), get<int64_t>(value_3));
#endif
} }
) )
); );
@ -407,7 +414,9 @@ namespace molasses {
) { ) {
// TODO: handle errors // TODO: handle errors
} }
#ifdef linux
unix_system::syscall4{}(get<int64_t>(value_0), get<int64_t>(value_1), get<int64_t>(value_2), get<int64_t>(value_3), get<int64_t>(value_4)); unix_system::syscall4{}(get<int64_t>(value_0), get<int64_t>(value_1), get<int64_t>(value_2), get<int64_t>(value_3), get<int64_t>(value_4));
#endif
} }
) )
); );
@ -443,7 +452,9 @@ namespace molasses {
) { ) {
// TODO: handle errors // TODO: handle errors
} }
#ifdef linux
unix_system::syscall5{}(get<int64_t>(value_0), get<int64_t>(value_1), get<int64_t>(value_2), get<int64_t>(value_3), get<int64_t>(value_4), get<int64_t>(value_5)); unix_system::syscall5{}(get<int64_t>(value_0), get<int64_t>(value_1), get<int64_t>(value_2), get<int64_t>(value_3), get<int64_t>(value_4), get<int64_t>(value_5));
#endif
} }
) )
); );
@ -482,6 +493,7 @@ namespace molasses {
) { ) {
// TODO: handle errors // TODO: handle errors
} }
#ifdef linux
unix_system::syscall6{}( unix_system::syscall6{}(
get<int64_t>(value_0), get<int64_t>(value_0),
get<int64_t>(value_1), get<int64_t>(value_1),
@ -491,7 +503,7 @@ namespace molasses {
get<int64_t>(value_5), get<int64_t>(value_5),
get<int64_t>(value_6) get<int64_t>(value_6)
); );
#endif
} }
) )
); );

+ 3
- 0
tests/001.exp View File

@ -20,6 +20,7 @@ if {$value != 0} {
abort "compiler crashed" abort "compiler crashed"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE tests/001/exit-with-1.mol lex parse "/tmp/sugar.generated.$BUILD_NAME" generate assemble spawn -noecho $SUGAR_EXECUTABLE tests/001/exit-with-1.mol lex parse "/tmp/sugar.generated.$BUILD_NAME" generate assemble
expect { expect {
@ -38,6 +39,8 @@ if {$value != 0} {
abort "compiler crashed" abort "compiler crashed"
} }
# -------------------------------------------------------------------
spawn -noecho /tmp/sugar.generated.$BUILD_NAME spawn -noecho /tmp/sugar.generated.$BUILD_NAME
expect eof expect eof
lassign [wait] pid spawnid os_error_flag value lassign [wait] pid spawnid os_error_flag value

+ 3
- 0
tests/002.exp View File

@ -20,6 +20,7 @@ if {$value != 0} {
abort "compiler crashed" abort "compiler crashed"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE tests/002/exit-with-1.mol lex parse /tmp/sugar.generated.$BUILD_NAME generate assemble spawn -noecho $SUGAR_EXECUTABLE tests/002/exit-with-1.mol lex parse /tmp/sugar.generated.$BUILD_NAME generate assemble
expect { expect {
@ -38,6 +39,8 @@ if {$value != 0} {
abort "compiler crashed" abort "compiler crashed"
} }
# -------------------------------------------------------------------
spawn -noecho /tmp/sugar.generated.$BUILD_NAME spawn -noecho /tmp/sugar.generated.$BUILD_NAME
expect eof expect eof
lassign [wait] pid spawnid os_error_flag value lassign [wait] pid spawnid os_error_flag value

+ 3
- 0
tests/003.exp View File

@ -25,6 +25,7 @@ if {$value != 0} {
abort "compiler crashed" abort "compiler crashed"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE tests/003/exit-with-1.mol lex tests/003/library.mol lex merge parse /tmp/sugar.generated.$BUILD_NAME generate assemble spawn -noecho $SUGAR_EXECUTABLE tests/003/exit-with-1.mol lex tests/003/library.mol lex merge parse /tmp/sugar.generated.$BUILD_NAME generate assemble
expect { expect {
@ -43,6 +44,8 @@ if {$value != 0} {
abort "compiler crashed" abort "compiler crashed"
} }
# -------------------------------------------------------------------
spawn -noecho /tmp/sugar.generated.$BUILD_NAME spawn -noecho /tmp/sugar.generated.$BUILD_NAME
expect { expect {
error { abort "failed to compile" } error { abort "failed to compile" }

+ 7
- 0
tests/005.exp View File

@ -20,6 +20,8 @@ if {$value != 0} {
abort "compiler crashed" abort "compiler crashed"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol tests/005/library.mol lex-all merge-all parse spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol tests/005/library.mol lex-all merge-all parse
expect { expect {
error { abort "failed to parse" } error { abort "failed to parse" }
@ -32,6 +34,8 @@ if {$value != 0} {
abort "compiler crashed" abort "compiler crashed"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol tests/005/library.mol lex-all merge-all parse spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol tests/005/library.mol lex-all merge-all parse
expect { expect {
error { abort "failed to parse" } error { abort "failed to parse" }
@ -44,6 +48,7 @@ if {$value != 0} {
abort "compiler crashed" abort "compiler crashed"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol lex tests/005/library.mol lex merge parse /tmp/sugar.generated.$BUILD_NAME generate assemble spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol lex tests/005/library.mol lex merge parse /tmp/sugar.generated.$BUILD_NAME generate assemble
expect { expect {
@ -62,6 +67,8 @@ if {$value != 0} {
abort "compiler crashed" abort "compiler crashed"
} }
# -------------------------------------------------------------------
spawn -noecho /tmp/sugar.generated.$BUILD_NAME spawn -noecho /tmp/sugar.generated.$BUILD_NAME
expect { expect {
error { abort "failed to compile" } error { abort "failed to compile" }

+ 17
- 1
tests/006.exp View File

@ -1,7 +1,7 @@
#!/usr/bin/expect #!/usr/bin/expect
set SUGAR_EXECUTABLE $::env(SUGAR_EXECUTABLE) set SUGAR_EXECUTABLE $::env(SUGAR_EXECUTABLE)
set BUILD_NAME 005.
set BUILD_NAME 006.
proc abort {reason} { proc abort {reason} {
puts "test failed $reason" puts "test failed $reason"
@ -20,6 +20,8 @@ if {$value == 0} {
abort "compiler didn't crash" abort "compiler didn't crash"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE "fake_01.006.not_a_file" lex spawn -noecho $SUGAR_EXECUTABLE "fake_01.006.not_a_file" lex
expect { expect {
error { abort "failed to parse" } error { abort "failed to parse" }
@ -32,6 +34,8 @@ if {$value == 0} {
abort "compiler didn't crash" abort "compiler didn't crash"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE "fake_01.006.not_a_file" lex-all spawn -noecho $SUGAR_EXECUTABLE "fake_01.006.not_a_file" lex-all
expect { expect {
error { abort "failed to parse" } error { abort "failed to parse" }
@ -44,6 +48,8 @@ if {$value == 0} {
abort "compiler didn't crash" abort "compiler didn't crash"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE "tests/005/library.mol" lex merge spawn -noecho $SUGAR_EXECUTABLE "tests/005/library.mol" lex merge
expect { expect {
error { abort "failed to parse" } error { abort "failed to parse" }
@ -56,6 +62,8 @@ if {$value == 0} {
abort "compiler didn't crash" abort "compiler didn't crash"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE merge spawn -noecho $SUGAR_EXECUTABLE merge
expect { expect {
error { abort "failed to parse" } error { abort "failed to parse" }
@ -68,6 +76,8 @@ if {$value == 0} {
abort "compiler didn't crash" abort "compiler didn't crash"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE parse spawn -noecho $SUGAR_EXECUTABLE parse
expect { expect {
error { abort "failed to parse" } error { abort "failed to parse" }
@ -109,6 +119,8 @@ if {[file exists "/tmp/006.fake_target"]} {
file delete "/tmp/006.fake_target" file delete "/tmp/006.fake_target"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE merge-all spawn -noecho $SUGAR_EXECUTABLE merge-all
expect { expect {
error { abort "failed to parse" } error { abort "failed to parse" }
@ -133,6 +145,8 @@ if {$value == 0} {
abort "compiler didn't crash" abort "compiler didn't crash"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE help spawn -noecho $SUGAR_EXECUTABLE help
expect { expect {
error { abort "failed to parse" } error { abort "failed to parse" }
@ -145,6 +159,8 @@ if {$value != 0} {
abort "compiler crashed displaying help" abort "compiler crashed displaying help"
} }
# -------------------------------------------------------------------
spawn -noecho $SUGAR_EXECUTABLE --help spawn -noecho $SUGAR_EXECUTABLE --help
expect { expect {
error { abort "failed to parse" } error { abort "failed to parse" }

Loading…
Cancel
Save