浏览代码

Handle TReturn null correctly

Hugh Sanderson 16 年之前
父节点
当前提交
0d8ebb4506
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      gencpp.ml

+ 7 - 4
gencpp.ml

@@ -819,19 +819,22 @@ let rec gen_expression ctx retval expression =
 			find_local_return_blocks false func_def.tf_expr;
 
 			(match func_def.tf_expr.eexpr with
-			| TReturn (Some return_expression) when (func_type = "Void") ->
+			| TReturn (Some return_expression) when (func_type<>"Void") ->
+				output_i "return ";
+				gen_expression ctx true return_expression;
+			| TReturn (Some return_expression) ->
 				output_i "";
-				gen_expression ctx false return_expression
+				gen_expression ctx false return_expression;
 			| _ ->
+				output_i "";
 				gen_expression ctx false func_def.tf_expr;
 			);
 			output ";\n";
-			output_i "return null();";
+			output_i "return null();\n";
 
 			ctx.ctx_static_id_used <- old_used;
 			ctx.ctx_static_id_curr <- old_curr;
 
-			output ";\n";
 			writer#end_block;
 		end;
 		pop_real_this_ptr();