Browse Source

Fix `foreign export` #294

gingerBill 6 years ago
parent
commit
13f084a219
2 changed files with 8 additions and 1 deletions
  1. 7 1
      examples/demo/demo.odin
  2. 1 0
      src/ir.cpp

+ 7 - 1
examples/demo/demo.odin

@@ -836,8 +836,14 @@ diverging_procedures :: proc() {
 	foo();
 	foo();
 }
 }
 
 
+foreign export {
+	bar :: proc "c" () -> i32 {
+		return 123;
+	}
+}
+
 main :: proc() {
 main :: proc() {
-	when true {
+	when false {
 		general_stuff();
 		general_stuff();
 		union_type();
 		union_type();
 		parametric_polymorphism();
 		parametric_polymorphism();

+ 1 - 0
src/ir.cpp

@@ -9744,6 +9744,7 @@ void ir_gen_tree(irGen *s) {
 			irValue *p = ir_value_procedure(m, e, e->type, type_expr, body, name);
 			irValue *p = ir_value_procedure(m, e, e->type, type_expr, body, name);
 			p->Proc.tags = pl->tags;
 			p->Proc.tags = pl->tags;
 			p->Proc.inlining = pl->inlining;
 			p->Proc.inlining = pl->inlining;
+			p->Proc.is_export = e->Procedure.is_export;
 
 
 			ir_module_add_value(m, e, p);
 			ir_module_add_value(m, e, p);
 			HashKey hash_name = hash_string(name);
 			HashKey hash_name = hash_string(name);