Skip to content

Commit ebe67c8

Browse files
author
playXE
committed
Update compiler
1 parent b415983 commit ebe67c8

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

src/gccjit.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl<'a> Codegen<'a>
276276
}
277277
let ty = if struct_.union
278278
{
279-
println!("UNION!");
279+
280280
self.ctx
281281
.new_union_type(None, &str(struct_.name).to_string(), &fields)
282282
}
@@ -1324,15 +1324,7 @@ impl<'a> Codegen<'a>
13241324
.map(|expr| self.get_id_type(expr.id).clone())
13251325
.collect::<Vec<_>>();
13261326

1327-
let var = if let Some(var) = self.variables.get(&name.name())
1328-
{
1329-
var.lval
1330-
}
1331-
else if let Some(var) = self.variables.get(&name.name())
1332-
{
1333-
var.lval
1334-
}
1335-
else if let Some(functions) = self.functions.get(&name.name())
1327+
let var = if let Some(functions) = self.functions.get(&name.name())
13361328
{
13371329
let functions = functions.clone();
13381330
let ty = if let Some(this) = this
@@ -1384,16 +1376,18 @@ impl<'a> Codegen<'a>
13841376

13851377
if this.is_some()
13861378
{
1379+
13871380
let expr = this.clone().unwrap().clone();
13881381
let ty = self.get_id_type(expr.id);
13891382
let val = if !ty.is_ptr()
13901383
{
1384+
let cty = self.ty_to_ctype(&ty).make_pointer();
13911385
let val = self.gen_expr(&Expr {
13921386
pos: expr.pos,
13931387
id: expr.id,
13941388
kind: ExprKind::AddressOf(expr),
13951389
});
1396-
1390+
let val = self.ctx.new_cast(None,val,cty);
13971391
val
13981392
}
13991393
else
@@ -1467,9 +1461,15 @@ impl<'a> Codegen<'a>
14671461
&params,
14681462
);
14691463
}
1464+
1465+
else if let Some(var) = self.variables.get(&name.name())
1466+
{
1467+
var.lval
1468+
}
1469+
14701470
else
14711471
{
1472-
panic!()
1472+
panic!();
14731473
};
14741474

14751475
let mut params = vec![];

src/semantic.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,8 +682,8 @@ impl<'a> SemCheck<'a>
682682
{
683683
let _id = stmt.id;
684684
match &stmt.kind
685+
685686
{
686-
StmtKind::CompTime(stmt) => self.tc_stmt(stmt),
687687
StmtKind::CFor(var, cond, then, body) =>
688688
{
689689
let prev;
@@ -830,15 +830,22 @@ impl<'a> SemCheck<'a>
830830
self.vars.pop();
831831
}
832832
StmtKind::Loop(stmt) => self.tc_stmt(stmt),
833+
_ => unimplemented!(),
833834
};
834835
}
835836

836837
pub fn tc_expr(&mut self, expr: &Expr) -> Type
837838
{
838839
match &expr.kind
839840
{
840-
ExprKind::MacroCall(_,_) => unreachable!(),
841-
ExprKind::CompTime(c) => self.tc_expr(c),
841+
ExprKind::CompTime(e) => {
842+
let ty = self.tc_expr(e);
843+
let ty = self.infer_type(&ty);
844+
self.types.insert(expr.id,ty.clone());
845+
846+
return ty;
847+
848+
}
842849
ExprKind::New(ty) =>
843850
{
844851
let infered = self.infer_type(ty);
@@ -1458,6 +1465,7 @@ impl<'a> SemCheck<'a>
14581465
result_type
14591466
}
14601467
ExprKind::Array(_, _) => unimplemented!(),
1468+
_ => unreachable!(),
14611469
}
14621470
}
14631471
}

0 commit comments

Comments
 (0)