-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
– Parse unary (no-argument) functions – Add functions for detecting the current os, arch, and os family, according to rustc's cfg attributes
- Loading branch information
Showing
15 changed files
with
277 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use common::*; | ||
use target; | ||
|
||
pub fn resolve_function<'a>(token: &Token<'a>) -> CompilationResult<'a, ()> { | ||
if !&["arch", "os", "os_family"].contains(&token.lexeme) { | ||
Err(token.error(CompilationErrorKind::UnknownFunction{function: token.lexeme})) | ||
} else { | ||
Ok(()) | ||
} | ||
} | ||
|
||
pub fn evaluate_function<'a>(name: &'a str) -> RunResult<'a, String> { | ||
match name { | ||
"arch" => Ok(arch().to_string()), | ||
"os" => Ok(os().to_string()), | ||
"os_family" => Ok(os_family().to_string()), | ||
_ => Err(RuntimeError::Internal { | ||
message: format!("attempted to evaluate unknown function: `{}`", name) | ||
}) | ||
} | ||
} | ||
|
||
pub fn arch() -> &'static str { | ||
target::arch() | ||
} | ||
|
||
pub fn os() -> &'static str { | ||
target::os() | ||
} | ||
|
||
pub fn os_family() -> &'static str { | ||
target::os_family() | ||
} |
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.