forked from M-Labs/nac3
1
0
Fork 0

nac3core: removed legacy location definition

This commit is contained in:
pca006132 2022-02-13 22:39:24 +08:00
parent 21d9182ba2
commit 352831b2ca
8 changed files with 1 additions and 56 deletions

View File

@ -1,7 +1,6 @@
use inkwell::{types::BasicType, values::BasicValueEnum, AddressSpace}; use inkwell::{types::BasicType, values::BasicValueEnum, AddressSpace};
use nac3core::{ use nac3core::{
codegen::{CodeGenContext, CodeGenerator}, codegen::{CodeGenContext, CodeGenerator},
location::Location,
symbol_resolver::{StaticValue, SymbolResolver, SymbolValue, ValueEnum}, symbol_resolver::{StaticValue, SymbolResolver, SymbolValue, ValueEnum},
toplevel::{DefinitionId, TopLevelDef}, toplevel::{DefinitionId, TopLevelDef},
typecheck::{ typecheck::{
@ -989,10 +988,6 @@ impl SymbolResolver for Resolver {
}) })
} }
fn get_symbol_location(&self, _: StrRef) -> Option<Location> {
unimplemented!()
}
fn get_identifier_def(&self, id: StrRef) -> Option<DefinitionId> { fn get_identifier_def(&self, id: StrRef) -> Option<DefinitionId> {
{ {
let id_to_def = self.0.id_to_def.read(); let id_to_def = self.0.id_to_def.read();

View File

@ -3,7 +3,6 @@ use crate::{
concrete_type::ConcreteTypeStore, CodeGenContext, CodeGenTask, DefaultCodeGenerator, concrete_type::ConcreteTypeStore, CodeGenContext, CodeGenTask, DefaultCodeGenerator,
WithCall, WorkerRegistry, WithCall, WorkerRegistry,
}, },
location::Location,
symbol_resolver::{SymbolResolver, ValueEnum}, symbol_resolver::{SymbolResolver, ValueEnum},
toplevel::{ toplevel::{
composer::TopLevelComposer, DefinitionId, FunInstance, TopLevelContext, TopLevelDef, composer::TopLevelComposer, DefinitionId, FunInstance, TopLevelContext, TopLevelDef,
@ -58,10 +57,6 @@ impl SymbolResolver for Resolver {
unimplemented!() unimplemented!()
} }
fn get_symbol_location(&self, _: StrRef) -> Option<Location> {
unimplemented!()
}
fn get_identifier_def(&self, id: StrRef) -> Option<DefinitionId> { fn get_identifier_def(&self, id: StrRef) -> Option<DefinitionId> {
self.id_to_def.read().get(&id).cloned() self.id_to_def.read().get(&id).cloned()
} }

View File

@ -2,7 +2,6 @@
#![allow(dead_code)] #![allow(dead_code)]
pub mod codegen; pub mod codegen;
pub mod location;
pub mod symbol_resolver; pub mod symbol_resolver;
pub mod toplevel; pub mod toplevel;
pub mod typecheck; pub mod typecheck;

View File

@ -1,28 +0,0 @@
use nac3parser::ast;
use std::vec::Vec;
#[derive(Clone, Copy, PartialEq)]
pub struct FileID(u32);
#[derive(Clone, Copy, PartialEq)]
pub enum Location {
CodeRange(FileID, ast::Location),
Builtin,
}
#[derive(Default)]
pub struct FileRegistry {
files: Vec<String>,
}
impl FileRegistry {
pub fn add_file(&mut self, path: &str) -> FileID {
let index = self.files.len() as u32;
self.files.push(path.to_owned());
FileID(index)
}
pub fn query_file(&self, id: FileID) -> &str {
&self.files[id.0 as usize]
}
}

View File

@ -13,7 +13,7 @@ use crate::{
typedef::{Type, Unifier}, typedef::{Type, Unifier},
}, },
}; };
use crate::{location::Location, typecheck::typedef::TypeEnum}; use crate::typecheck::typedef::TypeEnum;
use inkwell::values::{BasicValueEnum, FloatValue, IntValue, PointerValue}; use inkwell::values::{BasicValueEnum, FloatValue, IntValue, PointerValue};
use itertools::{chain, izip}; use itertools::{chain, izip};
use nac3parser::ast::{Expr, StrRef}; use nac3parser::ast::{Expr, StrRef};
@ -113,7 +113,6 @@ pub trait SymbolResolver {
ctx: &mut CodeGenContext<'ctx, 'a>, ctx: &mut CodeGenContext<'ctx, 'a>,
) -> Option<ValueEnum<'ctx>>; ) -> Option<ValueEnum<'ctx>>;
fn get_symbol_location(&self, str: StrRef) -> Option<Location>;
fn get_default_param_value(&self, expr: &nac3parser::ast::Expr) -> Option<SymbolValue>; fn get_default_param_value(&self, expr: &nac3parser::ast::Expr) -> Option<SymbolValue>;
fn get_string_id(&self, s: &str) -> i32; fn get_string_id(&self, s: &str) -> i32;
// handle function call etc. // handle function call etc.

View File

@ -1,6 +1,5 @@
use crate::{ use crate::{
codegen::CodeGenContext, codegen::CodeGenContext,
location::Location,
symbol_resolver::{SymbolResolver, ValueEnum}, symbol_resolver::{SymbolResolver, ValueEnum},
toplevel::DefinitionId, toplevel::DefinitionId,
typecheck::{ typecheck::{
@ -62,10 +61,6 @@ impl SymbolResolver for Resolver {
unimplemented!() unimplemented!()
} }
fn get_symbol_location(&self, _: StrRef) -> Option<Location> {
unimplemented!()
}
fn get_identifier_def(&self, id: StrRef) -> Option<DefinitionId> { fn get_identifier_def(&self, id: StrRef) -> Option<DefinitionId> {
self.0.id_to_def.lock().get(&id).cloned() self.0.id_to_def.lock().get(&id).cloned()
} }

View File

@ -2,7 +2,6 @@ use super::super::typedef::*;
use super::*; use super::*;
use crate::{ use crate::{
codegen::CodeGenContext, codegen::CodeGenContext,
location::Location,
symbol_resolver::ValueEnum, symbol_resolver::ValueEnum,
toplevel::{DefinitionId, TopLevelDef}, toplevel::{DefinitionId, TopLevelDef},
}; };
@ -41,10 +40,6 @@ impl SymbolResolver for Resolver {
unimplemented!() unimplemented!()
} }
fn get_symbol_location(&self, _: StrRef) -> Option<Location> {
unimplemented!()
}
fn get_identifier_def(&self, id: StrRef) -> Option<DefinitionId> { fn get_identifier_def(&self, id: StrRef) -> Option<DefinitionId> {
self.id_to_def.get(&id).cloned() self.id_to_def.get(&id).cloned()
} }

View File

@ -1,6 +1,5 @@
use nac3core::{ use nac3core::{
codegen::CodeGenContext, codegen::CodeGenContext,
location::Location,
symbol_resolver::{SymbolResolver, SymbolValue, ValueEnum}, symbol_resolver::{SymbolResolver, SymbolValue, ValueEnum},
toplevel::{DefinitionId, TopLevelDef}, toplevel::{DefinitionId, TopLevelDef},
typecheck::{ typecheck::{
@ -64,10 +63,6 @@ impl SymbolResolver for Resolver {
unimplemented!() unimplemented!()
} }
fn get_symbol_location(&self, _: StrRef) -> Option<Location> {
unimplemented!()
}
fn get_identifier_def(&self, id: StrRef) -> Option<DefinitionId> { fn get_identifier_def(&self, id: StrRef) -> Option<DefinitionId> {
self.0.id_to_def.lock().get(&id).cloned() self.0.id_to_def.lock().get(&id).cloned()
} }