2021-08-07 10:28:41 +08:00
|
|
|
use crate::location::Location;
|
2021-08-05 14:55:09 +08:00
|
|
|
use crate::top_level::DefinitionId;
|
2021-08-11 15:18:21 +08:00
|
|
|
use crate::typecheck::typedef::Type;
|
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-08-10 10:33:18 +08:00
|
|
|
fn get_symbol_type(&self, str: &str) -> Option<Type>;
|
|
|
|
fn parse_type_name(&self, expr: &Expr<()>) -> Option<Type>;
|
|
|
|
fn get_identifier_def(&self, str: &str) -> DefinitionId;
|
|
|
|
fn get_symbol_value(&self, str: &str) -> Option<SymbolValue>;
|
|
|
|
fn get_symbol_location(&self, str: &str) -> Option<Location>;
|
|
|
|
fn get_module_resolver(&self, module_name: &str) -> Option<&dyn SymbolResolver>; // NOTE: for getting imported modules' symbol resolver?
|
2021-08-11 15:18:21 +08:00
|
|
|
// handle function call etc.
|
2021-06-28 14:48:04 +08:00
|
|
|
}
|