nac3/nac3core/src/symbol_resolver.rs

25 lines
763 B
Rust
Raw Normal View History

use crate::location::Location;
use crate::typecheck::typedef::Type;
2021-08-05 14:55:09 +08:00
use crate::top_level::DefinitionId;
2021-07-20 16:13:43 +08:00
use rustpython_parser::ast::Expr;
2021-06-28 14:48:04 +08:00
2021-08-07 17:25:14 +08:00
#[derive(Clone, PartialEq)]
pub enum SymbolValue {
2021-06-28 14:48:04 +08:00
I32(i32),
I64(i64),
Double(f64),
Bool(bool),
2021-08-07 17:25:14 +08:00
Tuple(Vec<SymbolValue>),
// we should think about how to implement bytes later...
// Bytes(&'a [u8]),
2021-06-28 14:48:04 +08:00
}
pub trait SymbolResolver {
2021-07-20 16:13:43 +08:00
fn get_symbol_type(&mut self, str: &str) -> Option<Type>;
fn parse_type_name(&mut self, expr: &Expr<()>) -> Option<Type>;
2021-08-03 13:38:27 +08:00
fn get_function_def(&mut self, str: &str) -> DefinitionId;
2021-07-19 13:35:01 +08:00
fn get_symbol_value(&mut self, str: &str) -> Option<SymbolValue>;
fn get_symbol_location(&mut self, str: &str) -> Option<Location>;
2021-06-28 14:48:04 +08:00
// handle function call etc.
}