Skip to content

Commit 745a353

Browse files
committed
Finally support function pointers
1 parent 4a18a95 commit 745a353

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

cobalt-ast/src/ast/funcs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl AST for FnDefAST {
195195
cconv: cc,
196196
mt
197197
})),
198-
fty.clone(),
198+
Type::Reference(Box::new(fty.clone()))
199199
), VariableData {fwd: true, ..VariableData::with_vis(self.loc, vs)})));
200200
}
201201
}
@@ -229,7 +229,7 @@ impl AST for FnDefAST {
229229
cconv: cc,
230230
mt
231231
})),
232-
fty.clone(),
232+
Type::Reference(Box::new(fty.clone()))
233233
), VariableData {fwd: true, ..VariableData::with_vis(self.loc, vs)})));
234234
}
235235
}
@@ -648,7 +648,7 @@ impl AST for FnDefAST {
648648
cconv: cc,
649649
mt
650650
})),
651-
fty.clone(),
651+
Type::Reference(Box::new(fty.clone()))
652652
), VariableData::with_vis(self.loc, vs)))).clone();
653653
if is_extern.is_none() {
654654
let old_scope = ctx.push_scope(&self.name);
@@ -766,7 +766,7 @@ impl AST for FnDefAST {
766766
cconv: cc,
767767
mt
768768
})),
769-
fty.clone()
769+
Type::Reference(Box::new(fty.clone()))
770770
), VariableData::with_vis(self.loc, vs)))).clone();
771771
if is_extern.is_none() {
772772
let old_scope = ctx.push_scope(&self.name);

cobalt-ast/src/ops.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,6 +2366,10 @@ pub fn call<'ctx>(mut target: Value<'ctx>, loc: SourceSpan, cparen: Option<Sourc
23662366
_ => Err(err)
23672367
}
23682368
}
2369+
b @ Type::Function(..) => {
2370+
target.data_type = b;
2371+
call(target, loc, cparen, args, ctx)
2372+
}
23692373
b => {
23702374
if !ctx.is_const.get() {
23712375
if let Some(PointerValue(v)) = target.comp_val {

0 commit comments

Comments
 (0)