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