Make minor updates
This commit is contained in:
parent
b496ac1eb4
commit
206ec141a2
|
@ -93,7 +93,7 @@ impl ConditionalStatement {
|
|||
|
||||
assert!(
|
||||
bb_if_true_dangled.is_some(),
|
||||
"FIXME: json '{}'",
|
||||
"FIXME: CST node '{}'",
|
||||
json_if_body[0]
|
||||
);
|
||||
let bb_next = builder.block();
|
||||
|
@ -111,7 +111,7 @@ impl ConditionalStatement {
|
|||
if has_else_body {
|
||||
assert!(
|
||||
bb_if_false_dangled.is_some(),
|
||||
"FIXME: json '{}'",
|
||||
"FIXME: CST node '{}'",
|
||||
json_else_body[0]
|
||||
);
|
||||
merge_to_bb_next(bb_if_false_dangled.unwrap(), builder);
|
||||
|
@ -124,6 +124,11 @@ impl ConditionalStatement {
|
|||
unit_ctx.bb_head.push(bb_next); // maintain the head basic block
|
||||
|
||||
builder.append_to(bb_curr);
|
||||
assert!(
|
||||
expr_if_header.is_some(),
|
||||
"FIXME: CST node '{}'",
|
||||
json_if_header[0]
|
||||
);
|
||||
builder
|
||||
.ins()
|
||||
.br_cond(expr_if_header.unwrap(), bb_if_false, bb_if_true);
|
||||
|
@ -138,7 +143,7 @@ impl ConditionalStatement {
|
|||
let stmt = Statement::codegen(&json_child[0], context);
|
||||
|
||||
if context.unit_ctx.data.is_some() {
|
||||
assert!(stmt.is_some(), "FIXME: json '{}'", json_child[0]);
|
||||
assert!(stmt.is_some(), "FIXME: CST node '{}'", json_child[0]);
|
||||
|
||||
let unit_ctx = &mut context.unit_ctx;
|
||||
let mut builder = UnitContext::builder(&mut unit_ctx.data);
|
||||
|
|
|
@ -143,7 +143,7 @@ impl Expression {
|
|||
_ => panic!("unknown error at CST node '{}'", json),
|
||||
}
|
||||
|
||||
error!("FIXME: json '{}'", json);
|
||||
error!("FIXME: CST node '{}'", json);
|
||||
panic!()
|
||||
}
|
||||
_ => panic!("unknown error at CST node '{}'", json),
|
||||
|
@ -166,7 +166,7 @@ impl Expression {
|
|||
builder.append_to(bb_head);
|
||||
|
||||
if opt_opd_l.is_none() || opt_opd_r.is_none() {
|
||||
error!("FIXME: json '{}'", json);
|
||||
error!("FIXME: CST node '{}'", json);
|
||||
panic!();
|
||||
}
|
||||
let opd_l = opt_opd_l.unwrap();
|
||||
|
|
|
@ -53,7 +53,7 @@ impl NonblockingAssignmentStatement {
|
|||
let unit_ctx = &mut context.unit_ctx;
|
||||
if unit_ctx.data.is_some() {
|
||||
if opt_expr.is_none() {
|
||||
error!("FIXME: json '{}'", json_expression.to_string());
|
||||
error!("FIXME: CST node '{}'", json_expression.to_string());
|
||||
panic!();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use crate::cst::{ModuleContext, Statement, Tag, Tools};
|
||||
use json::JsonValue;
|
||||
use llhd::ir::Block;
|
||||
|
||||
pub struct SeqBlock {}
|
||||
|
||||
impl SeqBlock {
|
||||
pub fn codegen(json: &JsonValue, context: &mut ModuleContext) {
|
||||
pub fn codegen(json: &JsonValue, context: &mut ModuleContext) -> Option<Block> {
|
||||
let json_block_item_statement_list = {
|
||||
let json_vec = Tools::match_tags(
|
||||
vec![json],
|
||||
|
@ -13,8 +14,10 @@ impl SeqBlock {
|
|||
assert_eq!(json_vec.len(), 1);
|
||||
json_vec[0]["children"].members()
|
||||
};
|
||||
let mut ret = None;
|
||||
for json_statement in json_block_item_statement_list {
|
||||
Statement::codegen(json_statement, context);
|
||||
ret = Statement::codegen(json_statement, context);
|
||||
}
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,7 @@ pub struct Statement {}
|
|||
impl Statement {
|
||||
pub fn codegen(json: &JsonValue, context: &mut ModuleContext) -> Option<Block> {
|
||||
match json["tag"].as_str() {
|
||||
Some(Tag::SEQ_BLOCK) => {
|
||||
SeqBlock::codegen(json, context);
|
||||
None
|
||||
}
|
||||
Some(Tag::SEQ_BLOCK) => SeqBlock::codegen(json, context),
|
||||
Some(Tag::CONDITIONAL_STATEMENT) => ConditionalStatement::codegen(json, context),
|
||||
Some(Tag::CASE_STATEMENT) => {
|
||||
CaseStatement::codegen(json, context);
|
||||
|
|
Loading…
Reference in New Issue