Skip to content
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

Type-conversion SYMs #366

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ impl<'i> CoreParser<'i> {

// Parses the symbol
let op = hvm::Numb::new_sym(match () {
_ if self.try_consume("SYM") => hvm::TY_SYM,
_ if self.try_consume("U24") => hvm::TY_U24,
_ if self.try_consume("I24") => hvm::TY_I24,
_ if self.try_consume("F24") => hvm::TY_F24,
_ if self.try_consume("+") => hvm::OP_ADD,
_ if self.try_consume("-") => hvm::OP_SUB,
_ if self.try_consume(":-") => hvm::FP_SUB,
Expand Down Expand Up @@ -224,6 +228,10 @@ impl Numb {
let numb = hvm::Numb(self.0);
match numb.get_typ() {
hvm::TY_SYM => match numb.get_sym() as hvm::Tag {
hvm::TY_SYM => "[SYM]".to_string(),
hvm::TY_U24 => "[U24]".to_string(),
hvm::TY_I24 => "[I24]".to_string(),
hvm::TY_F24 => "[F24]".to_string(),
hvm::OP_ADD => "[+]".to_string(),
hvm::OP_SUB => "[-]".to_string(),
hvm::FP_SUB => "[:-]".to_string(),
Expand Down
4 changes: 4 additions & 0 deletions src/hvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,10 @@ void pretty_print_numb(Numb word) {
switch (get_typ(word)) {
case TY_SYM: {
switch (get_sym(word)) {
case TY_SYM: printf("[SYM]"); break;
case TY_U24: printf("[U24]"); break;
case TY_I24: printf("[I24]"); break;
case TY_F24: printf("[F24]"); break;
case OP_ADD: printf("[+]"); break;
case OP_SUB: printf("[-]"); break;
case FP_SUB: printf("[:-]"); break;
Expand Down
4 changes: 4 additions & 0 deletions src/hvm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,10 @@ __device__ void pretty_print_numb(Numb word) {
switch (get_typ(word)) {
case TY_SYM: {
switch (get_sym(word)) {
case TY_SYM: printf("[SYM]"); break;
case TY_U24: printf("[U24]"); break;
case TY_I24: printf("[I24]"); break;
case TY_F24: printf("[F24]"); break;
case OP_ADD: printf("[+]"); break;
case OP_SUB: printf("[-]"); break;
case FP_SUB: printf("[:-]"); break;
Expand Down