// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)

@table(name  num_children  op_string)
// num_children  - # of children packed after this node kind
// op_string     - string for quick display of the operator
EVAL_ExprKindTable:
{
  { Nil                 0         ""             }
  
  { ArrayIndex          2         "[]"           }
  { MemberAccess        2         "."            }
  { Deref               1         "*"            }
  { Address             1         "&"            }
  
  { Cast                2         "cast"         }
  { Sizeof              1         "sizeof"       }
  
  { Neg                 1         "-"            }
  { LogNot              1         "!"            }
  { BitNot              1         "~"            }
  { Mul                 2         "*"            }
  { Div                 2         "/"            }
  { Mod                 2         "%"            }
  { Add                 2         "+"            }
  { Sub                 2         "-"            }
  { LShift              2         "<<"           }
  { RShift              2         ">>"           }
  { Less                2         "<"            }
  { LsEq                2         "<="           }
  { Grtr                2         ">"            }
  { GrEq                2         ">="           }
  { EqEq                2         "=="           }
  { NtEq                2         "!="           }
  
  { BitAnd              2         "&"            }
  { BitXor              2         "^"            }
  { BitOr               2         "|"            }
  { LogAnd              2         "&&"           }
  { LogOr               2         "||"           }
  
  { Ternary             3         "? "           }
  
  { LeafBytecode        0         "bytecode"     }
  { LeafMember          0         "member"       }
  { LeafU64             0         "U64"          }
  { LeafF64             0         "F64"          }
  { LeafF32             0         "F32"          }
  
  { TypeIdent           0         "type_ident"   }
  { Ptr                 1         "ptr"          }
  { Array               2         "array"        }
  { Func                1         "function"     }
  
  { Define              2         "="            }
  { LeafIdent           0         "leaf_ident"   }
}

@table(name display_string)
EVAL_ResultCodeTable:
{
  { Good                    "" }
  { DivideByZero            "Cannot divide by zero." }
  { BadOp                   "Invalid operation." }
  { BadOpTypes              "Invalid operation types." }
  { BadMemRead              "Failed memory read." }
  { BadRegRead              "Failed register read." }
  { BadFrameBase            "Invalid frame base address." }
  { BadModuleBase           "Invalid module base address." }
  { BadTLSBase              "Invalid thread-local storage base address." }
  { InsufficientStackSpace  "Insufficient evaluation machine stack space." }
  { MalformedBytecode       "Malformed bytecode." }
}

@enum(U32) EVAL_ExprKind:
{
  @expand(EVAL_ExprKindTable a) `$(a.name)`,
  COUNT,
}

@enum EVAL_ResultCode:
{
  @expand(EVAL_ResultCodeTable a) `$(a.name)`,
  COUNT,
}

@data(U8) eval_expr_kind_child_counts:
{
  @expand(EVAL_ExprKindTable a) `$(a.num_children)`
}

@data(String8)
eval_expr_kind_strings:
{
  @expand(EVAL_ExprKindTable a) `str8_lit_comp("$(a.name)")`
}

@data(String8) eval_result_code_display_strings:
{
  @expand(EVAL_ResultCodeTable a) `str8_lit_comp("$(a.display_string)")`
}

@data(String8) eval_expr_op_strings:
{
  @expand(EVAL_ExprKindTable a) `str8_lit_comp("$(a.op_string)")`
}
