Make Func more complex
This commit is contained in:
parent
9d9331f4b0
commit
0eccceabd9
@ -339,7 +339,7 @@ impl<'a, 'b> Reducer<'a, 'b> {
|
||||
|
||||
match symbol.spec() {
|
||||
Builtin(b) => Expression::Callable(Callable::Builtin(b)),
|
||||
Func => Expression::Lookup(Lookup::Function(def_id.unwrap())),
|
||||
Func { .. } => Expression::Lookup(Lookup::Function(def_id.unwrap())),
|
||||
GlobalBinding => Expression::Lookup(Lookup::GlobalVar(def_id.unwrap())),
|
||||
LocalVariable => Expression::Lookup(Lookup::LocalVar(def_id.unwrap())),
|
||||
FunctionParam(n) => Expression::Lookup(Lookup::Param(n)),
|
||||
|
@ -114,7 +114,7 @@ impl SymbolTable {
|
||||
) -> Result<(), Vec<SymbolError>> {
|
||||
let mut populator = SymbolTablePopulator { type_context, table: self };
|
||||
|
||||
let errs = populator.populate_name_tables(ast);
|
||||
let errs = populator.populate_definition_tables(ast);
|
||||
if !errs.is_empty() {
|
||||
return Err(errs);
|
||||
}
|
||||
@ -212,7 +212,7 @@ impl fmt::Display for Symbol {
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum SymbolSpec {
|
||||
Builtin(Builtin),
|
||||
Func,
|
||||
Func { method: Option<crate::ast::TypeSingletonName> },
|
||||
DataConstructor { tag: u32, type_id: TypeId },
|
||||
RecordConstructor { tag: u32, type_id: TypeId },
|
||||
GlobalBinding, //Only for global variables, not for function-local ones or ones within a `let` scope context
|
||||
@ -225,7 +225,7 @@ impl fmt::Display for SymbolSpec {
|
||||
use self::SymbolSpec::*;
|
||||
match self {
|
||||
Builtin(b) => write!(f, "Builtin: {:?}", b),
|
||||
Func => write!(f, "Func"),
|
||||
Func { .. } => write!(f, "Func"),
|
||||
DataConstructor { tag, type_id } => write!(f, "DataConstructor(tag: {}, type: {})", tag, type_id),
|
||||
RecordConstructor { type_id, tag, .. } =>
|
||||
write!(f, "RecordConstructor(tag: {})(<members> -> {})", tag, type_id),
|
||||
|
@ -32,7 +32,7 @@ impl<'a> SymbolTablePopulator<'a> {
|
||||
/// constants, functions, types, and modules defined within. This simultaneously
|
||||
/// checks for dupicate definitions (and returns errors if discovered), and sets
|
||||
/// up name tables that will be used by further parts of the compiler
|
||||
pub fn populate_name_tables(&mut self, ast: &AST) -> Vec<SymbolError> {
|
||||
pub fn populate_definition_tables(&mut self, ast: &AST) -> Vec<SymbolError> {
|
||||
let mut scope_stack = vec![];
|
||||
self.add_from_scope(ast.statements.as_ref(), &mut scope_stack, false)
|
||||
}
|
||||
@ -94,7 +94,7 @@ impl<'a> SymbolTablePopulator<'a> {
|
||||
.register(fq_function.clone(), NameSpec { location, kind: NameKind::Function })?;
|
||||
self.table.types.register(fq_function.clone(), NameSpec { location, kind: TypeKind })?;
|
||||
|
||||
self.add_symbol(id, fq_function, SymbolSpec::Func);
|
||||
self.add_symbol(id, fq_function, SymbolSpec::Func { method: None });
|
||||
}
|
||||
StatementKind::Declaration(Declaration::FuncDecl(signature, ..)) => {
|
||||
let fn_name = &signature.name;
|
||||
@ -104,7 +104,7 @@ impl<'a> SymbolTablePopulator<'a> {
|
||||
.register(fq_function.clone(), NameSpec { location, kind: NameKind::Function })?;
|
||||
self.table.types.register(fq_function.clone(), NameSpec { location, kind: TypeKind })?;
|
||||
|
||||
self.add_symbol(id, fq_function, SymbolSpec::Func);
|
||||
self.add_symbol(id, fq_function, SymbolSpec::Func { method: None });
|
||||
}
|
||||
StatementKind::Declaration(Declaration::TypeDecl { name, .. }) => {
|
||||
let fq_type = Fqsn::from_scope_stack(scope_stack, name.name.clone());
|
||||
|
Loading…
Reference in New Issue
Block a user