-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Toplevel rust translation #1905
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
951fb17
Add translate_rust_type so we can call the function from the command …
scuellar 3b67591
Last details to get rust translation working at the toplevel
scuellar 82d34dd
add example file
scuellar c9c88b4
Better descriptions
scuellar c7fe919
Remove comments
scuellar fb24c94
Improve description for heapster_parse_test
scuellar 2a79212
Description was on the wrong function
scuellar 72dbd3e
Deduplicating functions parseFunPermFromRust and parseSome3FunPermFro…
scuellar d204452
Fix the arguments
scuellar 8326fc7
Generalize un3SomeFunPerm
scuellar 453b05e
wrap line to 80 columns
scuellar 56bfeac
Simplify expression (and add alignment)
scuellar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// This file demonstrates how to use the `heapster_trans_rust_type` | ||
// command to translate rust signatures to heapster. | ||
enable_experimental; | ||
|
||
// Integer types This is wrong... we don't need an environment. | ||
env <- heapster_init_env_from_file "rust_data.sawcore" "rust_data.bc"; | ||
|
||
print "Define Rust types."; | ||
/*** | ||
*** Types | ||
***/ | ||
|
||
// Integer types | ||
heapster_define_perm env "int64" " " "llvmptr 64" "exists x:bv 64.eq(llvmword(x))"; | ||
heapster_define_perm env "int32" " " "llvmptr 32" "exists x:bv 32.eq(llvmword(x))"; | ||
heapster_define_perm env "int8" " " "llvmptr 8" "exists x:bv 8.eq(llvmword(x))"; | ||
heapster_define_perm env "int1" " " "llvmptr 1" "exists x:bv 1.eq(llvmword(x))"; | ||
|
||
heapster_define_llvmshape env "u64" 64 "" "fieldsh(int64<>)"; | ||
heapster_define_llvmshape env "u32" 64 "" "fieldsh(32,int32<>)"; | ||
heapster_define_llvmshape env "u8" 64 "" "fieldsh(8,int8<>)"; | ||
|
||
heapster_define_llvmshape env "usize" 64 "" "fieldsh(int64<>)"; | ||
heapster_define_llvmshape env "char" 64 "" "fieldsh(32,int32<>)"; | ||
|
||
// bool type | ||
heapster_define_llvmshape env "bool" 64 "" "fieldsh(1,int1<>)"; | ||
|
||
// Box type | ||
heapster_define_llvmshape env "Box" 64 "T:llvmshape 64" "ptrsh(T)"; | ||
|
||
// Result type | ||
heapster_define_rust_type env "pub enum Result<X,Y> { Ok (X), Err (Y) }"; | ||
|
||
// Infallable type | ||
heapster_define_llvmshape env "Infallible" 64 "" "falsesh"; | ||
|
||
// Sum type | ||
heapster_define_rust_type env "pub enum Sum<X,Y> { Left (X), Right (Y) }"; | ||
|
||
// The Option type | ||
heapster_define_rust_type env "pub enum Option<X> { None, Some (X) }"; | ||
|
||
|
||
print ""; | ||
print "-----------------------------------------------"; | ||
print "Translate 'unit'"; | ||
print "Rust: \n<> fn () -> ()"; | ||
print "Heapster:"; | ||
heapster_trans_rust_type env "<> fn () -> ()"; | ||
|
||
print ""; | ||
print "-----------------------------------------------"; | ||
print "Translate 'add'"; | ||
print "Rust: \n<> fn (x:u64, y:u64) -> u64"; | ||
print "Heapster:"; | ||
heapster_trans_rust_type env "<> fn (x:u64, y:u64) -> u64"; | ||
|
||
|
||
print ""; | ||
print "-----------------------------------------------"; | ||
print "Translate 'Ptr add'"; | ||
print "Rust: \n<'a,'b> fn (x:&'a u64, y:&'a u64) -> u64"; | ||
print "Heapster:"; | ||
heapster_trans_rust_type env "<'a,'b> fn (x:&'a u64, y:&'a u64) -> u64"; | ||
|
||
print ""; | ||
print "-----------------------------------------------"; | ||
print "Translate 'array length'"; | ||
print "Rust: \n<'a> fn (x:&'a [u64]) -> u64"; | ||
print "Heapster:"; | ||
heapster_trans_rust_type env "<'a> fn (x:&'a [u64]) -> u64"; | ||
|
||
|
||
print ""; | ||
print "-----------------------------------------------"; | ||
print "Translate 'add two array'"; | ||
print "Rust: \n<'a, 'b, 'c> fn (l1:&'a [u64], l2:&'b [u64]) -> &'c [u64]"; | ||
print "Heapster:"; | ||
heapster_trans_rust_type env "<'a, 'b, 'c> fn (l1:&'a [u64], l2:&'b [u64]) -> &'c [u64]"; | ||
|
||
print ""; | ||
print "-----------------------------------------------"; | ||
print "Translate 'add two array in place'"; | ||
print "Rust: \n<'a, 'b> fn (l1:&'a mut[u64], l2:&'b [u64]) -> ()"; | ||
print "Heapster:"; | ||
heapster_trans_rust_type env "<'a, 'b> fn (l1:&'a mut[u64], l2:&'b [u64]) -> ()"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
let ppInfo = emptyPPInfo in
instead of binding a return, which looks kind of weird to a Hasekll-er