Make minor updates

This commit is contained in:
Guojie Luo 2022-02-24 10:07:54 +08:00
parent 975d44e212
commit 5284760090
3 changed files with 26 additions and 11 deletions

View File

@ -31,7 +31,10 @@ impl AlwaysStatement {
ProceduralTimingControlStatement::codegen(json_statement, context);
}
Some(Tag::ALWAYS_COMB) => {
panic!(); // FIXME
println!("TODO: implmenent AlwaysComb::codegen()");
}
Some(x) => {
println!("FIXME: missing {}", x);
}
_ => {
panic!();

View File

@ -1,4 +1,4 @@
use crate::cst::{Expression, ModuleContext, Tag, Tools};
use crate::cst::{Expression, ModuleContext, Statement, Tag, Tools};
use json::JsonValue;
pub struct ConditionalStatement {}
@ -35,11 +35,15 @@ impl ConditionalStatement {
}
}
fn visit_if_body(_json: &JsonValue, _context: &ModuleContext) {
println!("TODO: implement ConditionalStatement::visit_if_body()");
fn visit_if_body(json: &JsonValue, context: &ModuleContext) {
let json_nodes = &json["children"];
assert_eq!(json_nodes.len(), 1);
Statement::codegen(&json_nodes[0], context);
}
fn visit_else_body(_json: &JsonValue, _context: &ModuleContext) {
println!("TODO: implement ConditionalStatement::visit_else_body()");
fn visit_else_body(json: &JsonValue, context: &ModuleContext) {
let json_nodes = &json["children"];
assert_eq!(json_nodes.len(), 1);
Statement::codegen(&json_nodes[0], context);
}
}

View File

@ -5,6 +5,7 @@ impl Tag {
pub const MODULE_DECLARATION: &'static str = "kModuleDeclaration";
pub const MODULE_HEADER: &'static str = "kModuleHeader";
pub const MODULE_ITEM_LIST: &'static str = "kModuleItemList";
pub const MODULE_PORT_DECLARATION: &'static str = "kModulePortDeclaration";
pub const PORT_IDENTIFIER_LIST: &'static str = "kPortIdentifierList";
pub const PORT_IDENTIFIER: &'static str = "kPortIdentifier";
@ -16,19 +17,26 @@ impl Tag {
pub const PACKED_DIMENSIONS: &'static str = "kPackedDimensions";
pub const DECLARATION_DIMENSIONS: &'static str = "kDeclarationDimensions";
pub const DIMENSION_RANGE: &'static str = "kDimensionRange";
pub const SYMBOL_IDENTIFIER: &'static str = "SymbolIdentifier";
pub const EXPRESSION: &'static str = "kExpression";
pub const NUMBER: &'static str = "kNumber";
pub const DEC_NUMBER: &'static str = "TK_DecNumber";
pub const ALWAYS_STATEMENT: &'static str = "kAlwaysStatement";
pub const ALWAYS: &'static str = "always";
pub const ALWAYS_COMB: &'static str = "always_comb";
pub const PROCEDURAL_TIMING_CONTROL_STATEMENT: &'static str =
"kProceduralTimingControlStatement";
pub const EVENT_CONTROL: &'static str = "kEventControl";
pub const PAREN_GROUP: &'static str = "kParenGroup";
pub const EVENT_EXPRESSION_LIST: &'static str = "kEventExpressionList";
pub const SEQ_BLOCK: &'static str = "kSeqBlock";
pub const BLOCK_ITEM_STATEMENT_LIST: &'static str = "kBlockItemStatementList";
pub const NONBLOCKING_ASSIGNMENT_STATEMENT: &'static str = "kNonblockingAssignmentStatement";
pub const CONDITIONAL_STATEMENT: &'static str = "kConditionalStatement";
pub const IF_CLAUSE: &'static str = "kIfClause";
pub const IF_HEADER: &'static str = "kIfHeader";
@ -36,14 +44,14 @@ impl Tag {
pub const ELSE_CLAUSE: &'static str = "kElseClause";
pub const ELSE_BODY: &'static str = "kElseBody";
pub const NONBLOCKING_ASSIGNMENT_STATEMENT: &'static str = "kNonblockingAssignmentStatement";
pub const CASE_STATEMENT: &'static str = "kCaseStatement";
pub const SYMBOL_IDENTIFIER: &'static str = "SymbolIdentifier";
pub const DEC_NUMBER: &'static str = "TK_DecNumber";
/*
pub const DATA_DECLARATION: &'static str = "kDataDeclaration";
pub const NET_DECLARATION: &'static str = "kNetDeclaration";
pub const CONTINUOUS_ASSIGNMENT_STATEMENT: &'static str = "kContinuousAssignmentStatement";
*/
pub const INPUT: &'static str = "input";
pub const OUTPUT: &'static str = "output";
pub const ALWAYS: &'static str = "always";
pub const ALWAYS_COMB: &'static str = "always_comb";
}