update escapedidentifier

This commit is contained in:
Yanting Zhang 2022-09-02 13:50:31 +08:00
parent aaf0ff373b
commit 03d6039783
3 changed files with 48 additions and 4 deletions

View File

@ -51,14 +51,14 @@ impl Expression {
Tag::REFERENCE, Tag::REFERENCE,
Tag::LOCAL_ROOT, Tag::LOCAL_ROOT,
Tag::UNQUALIFIED_ID, Tag::UNQUALIFIED_ID,
Tag::SYMBOL_IDENTIFIER, Tag::ESCAPEDIDENTIFIER,
], ],
vec![ vec![
Tag::REFERENCE_CALL_BASE, Tag::REFERENCE_CALL_BASE,
Tag::REFERENCE, Tag::REFERENCE,
Tag::LOCAL_ROOT, Tag::LOCAL_ROOT,
Tag::UNQUALIFIED_ID, Tag::UNQUALIFIED_ID,
Tag::ESCAPEDIDENTIFIER, Tag::SYMBOL_IDENTIFIER,
], ],
]; ];
@ -66,7 +66,7 @@ impl Expression {
.iter() .iter()
.flat_map(|x|Tools::match_tags(vec![json], x.to_vec())) .flat_map(|x|Tools::match_tags(vec![json], x.to_vec()))
.collect(); .collect();
assert_eq!(json_symbol_identifier.len(), 1,); assert_eq!(json_symbol_identifier.len(), 1);
let json_scalar = Tools::match_tags( let json_scalar = Tools::match_tags(
vec![json], vec![json],
@ -133,7 +133,9 @@ impl Expression {
None => builder.ins().prb(symbol_value), None => builder.ins().prb(symbol_value),
Some(s) => builder.ins().ld(s), Some(s) => builder.ins().ld(s),
} }
} else if context.symbol.contains_key(&symbol) { }
else if context.symbol.contains_key(&symbol)
{
let symbol_info = &context.symbol[&symbol]; let symbol_info = &context.symbol[&symbol];
assert_eq!(symbol_info.kind, SymbolKind::Param); assert_eq!(symbol_info.kind, SymbolKind::Param);
builder.ins().const_int(symbol_info.value.clone()) builder.ins().const_int(symbol_info.value.clone())

View File

@ -30,6 +30,7 @@ impl<'a> ModuleDeclaration {
SymbolDeclaration::declare_port(json, context); SymbolDeclaration::declare_port(json, context);
SymbolDeclaration::declare_reg(json, context); SymbolDeclaration::declare_reg(json, context);
SymbolDeclaration::declare_wire(json, context); SymbolDeclaration::declare_wire(json, context);
SymbolDeclaration::declare_wire1(json, context);
SymbolDeclaration::declare_param(json, context); SymbolDeclaration::declare_param(json, context);
Self::gen_entity_data(json, context); Self::gen_entity_data(json, context);

View File

@ -290,6 +290,47 @@ impl<'a> SymbolDeclaration {
); );
} }
pub fn declare_wire1(json: &'a JsonValue, context: &mut ModuleContext<'a>) {
let base_path = [
Tag::MODULE_DECLARATION,
Tag::MODULE_ITEM_LIST,
Tag::NET_DECLARATION,
];
let name_path = [
Tag::NET_DECLARATION,
Tag::NET_VARIABLE_DECLARATION_ASSIGN,
Tag::NET_VARIABLE,
Tag::ESCAPEDIDENTIFIER,
];
let dim_path = [
Tag::NET_DECLARATION,
Tag::DATA_TYPE_IMPLICIT_ID_DIMENSIONS,
Tag::DATA_TYPE,
Tag::PACKED_DIMENSIONS,
Tag::DECLARATION_DIMENSIONS,
Tag::DIMENSION_RANGE,
Tag::EXPRESSION,
Tag::NUMBER,
Tag::DEC_NUMBER,
];
let json_wires: Vec<&JsonValue> = Tools::match_tags(vec![json], base_path.to_vec())
.iter()
.filter(|&x| x["children"][0]["tag"] == Tag::WIRE)
.map(|&x| x)
.collect();
Self::gen_var_info(
json_wires,
name_path.to_vec(),
dim_path.to_vec(),
SymbolKind::Wire,
context,
);
}
fn gen_var_info( fn gen_var_info(
json_vec: Vec<&'a JsonValue>, json_vec: Vec<&'a JsonValue>,
name_path: Vec<&str>, name_path: Vec<&str>,