Field name exporting
This commit is contained in:
+6
-1
@@ -17,6 +17,7 @@ pub enum TypeRef {
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct VarRef {
|
||||
pub export: bool,
|
||||
pub var_type: Arc<TypeRef>,
|
||||
pub name: String,
|
||||
}
|
||||
@@ -82,6 +83,7 @@ impl TopLevelHirScope {
|
||||
self.variables.insert(
|
||||
symbol.name.clone(),
|
||||
Arc::new(VarRef {
|
||||
export: false,
|
||||
name: name.clone(),
|
||||
var_type: Arc::new(TypeRef::Function(rf)),
|
||||
}),
|
||||
@@ -115,6 +117,7 @@ impl TopLevelHirScope {
|
||||
self.variables.insert(
|
||||
symbol.name.clone(),
|
||||
Arc::new(VarRef {
|
||||
export: symbol.export,
|
||||
name: name.clone(),
|
||||
var_type: rf.clone(),
|
||||
}),
|
||||
@@ -126,8 +129,9 @@ impl TopLevelHirScope {
|
||||
|
||||
pub fn var_ref(&mut self, tlss: &TopLevelSymbolScope, symbol: &VarSymbol) -> Arc<VarRef> {
|
||||
Arc::new(VarRef {
|
||||
export: symbol.export,
|
||||
var_type: self.type_ref(tlss, &symbol.var_type),
|
||||
name: self.get_name(true),
|
||||
name: self.get_name(symbol.export),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -141,6 +145,7 @@ impl TopLevelHirScope {
|
||||
match symbol.0.as_str() {
|
||||
"int" => {
|
||||
let var_ref = Arc::new(VarRef {
|
||||
export: false,
|
||||
name: symbol.0.clone(),
|
||||
var_type: Arc::new(TypeRef::Int),
|
||||
});
|
||||
|
||||
@@ -71,6 +71,7 @@ impl LocalScope {
|
||||
self.variables.lock().unwrap().insert(
|
||||
name.clone(),
|
||||
Arc::new(VarRef {
|
||||
export: false,
|
||||
name: name.to_string(),
|
||||
var_type,
|
||||
}),
|
||||
@@ -151,7 +152,7 @@ impl LocalScope {
|
||||
}
|
||||
|
||||
pub fn with_params(self: &Arc<Self>, param_list: &ParamList) {
|
||||
for (param_name, (_, type_expr)) in ¶m_list.0 {
|
||||
for (param_name, (export, type_expr)) in ¶m_list.0 {
|
||||
match type_expr {
|
||||
parser::ast::TypeExpr::Identifier(id) => {
|
||||
if let Some(var_type) =
|
||||
@@ -160,6 +161,7 @@ impl LocalScope {
|
||||
self.variables.lock().unwrap().insert(
|
||||
param_name.clone(),
|
||||
Arc::new(VarRef {
|
||||
export: *export,
|
||||
var_type,
|
||||
name: param_name.clone(),
|
||||
}),
|
||||
|
||||
@@ -9,6 +9,7 @@ pub struct TypeSymbol(pub String);
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct VarSymbol {
|
||||
pub export: bool,
|
||||
pub var_type: TypeSymbol,
|
||||
pub name: String,
|
||||
}
|
||||
@@ -50,10 +51,11 @@ impl FunctionSymbol {
|
||||
params: params
|
||||
.0
|
||||
.iter()
|
||||
.map(|(name, (_, v))| {
|
||||
.map(|(name, (export, v))| {
|
||||
(
|
||||
name.clone(),
|
||||
VarSymbol {
|
||||
export: *export,
|
||||
name: name.clone(),
|
||||
var_type: TypeSymbol(match v {
|
||||
TypeExpr::Identifier(i) => i.to_string(),
|
||||
@@ -75,10 +77,11 @@ impl StructSymbol {
|
||||
fields: fields
|
||||
.0
|
||||
.iter()
|
||||
.map(|(name, (_, v))| {
|
||||
.map(|(name, (export, v))| {
|
||||
(
|
||||
name.clone(),
|
||||
VarSymbol {
|
||||
export: *export,
|
||||
name: name.clone(),
|
||||
var_type: TypeSymbol(match v {
|
||||
TypeExpr::Identifier(i) => i.to_string(),
|
||||
|
||||
Reference in New Issue
Block a user