From: Rico Tzschichholz Date: Tue, 6 Apr 2021 11:00:16 +0000 (+0200) Subject: codegen: Always use CCodeConstant for NULL X-Git-Tag: 0.52.1~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2edf1f3d4b4fa88b3cabf591b95cd077b5ce18c;p=thirdparty%2Fvala.git codegen: Always use CCodeConstant for NULL --- diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala index 8eb995f20..7d23b8143 100644 --- a/codegen/valaccodearraymodule.vala +++ b/codegen/valaccodearraymodule.vala @@ -606,7 +606,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule { ccode.add_return (new CCodeIdentifier ("result")); ccode.close (); - ccode.add_return (new CCodeIdentifier ("NULL")); + ccode.add_return (new CCodeConstant ("NULL")); } else { // only dup if length > 0, this deals with negative lengths and returns NULL var length_check = new CCodeBinaryExpression (CCodeBinaryOperator.GREATER_THAN, new CCodeIdentifier ("length"), new CCodeConstant ("0")); @@ -650,7 +650,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule { } ccode.close (); - ccode.add_return (new CCodeIdentifier ("NULL")); + ccode.add_return (new CCodeConstant ("NULL")); } // append to file diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 2df631adc..fc25b327f 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -785,7 +785,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { ccode.add_else (); - ccode.add_assignment (new CCodeIdentifier ("new_mem"), new CCodeIdentifier ("NULL")); + ccode.add_assignment (new CCodeIdentifier ("new_mem"), new CCodeConstant ("NULL")); ccode.close (); @@ -1283,7 +1283,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { ccode.add_assignment (get_delegate_target_cvalue (field_value), new CCodeIdentifier ("self")); if (delegate_type.is_disposable ()) { - ccode.add_assignment (get_delegate_target_destroy_notify_cvalue (field_value), new CCodeIdentifier ("NULL")); + ccode.add_assignment (get_delegate_target_destroy_notify_cvalue (field_value), new CCodeConstant ("NULL")); } } } @@ -6061,7 +6061,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { if (sink_func != "") { if (type.nullable) { - var is_not_null = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, result.cvalue, new CCodeIdentifier ("NULL")); + var is_not_null = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, result.cvalue, new CCodeConstant ("NULL")); ccode.open_if (is_not_null); } diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index dd8e149ae..d60fcf0a3 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -443,7 +443,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { closure_new.add_argument (new CCodeCastExpression (cexpr, "GCallback")); closure_new.add_argument (delegate_target); closure_new.add_argument (new CCodeCastExpression (delegate_target_destroy_notify, "GClosureNotify")); - cexpr = new CCodeConditionalExpression (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, cexpr, new CCodeIdentifier ("NULL")), new CCodeIdentifier ("NULL"), closure_new); + cexpr = new CCodeConditionalExpression (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, cexpr, new CCodeConstant ("NULL")), new CCodeConstant ("NULL"), closure_new); } else { carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), delegate_target); if (deleg_type.is_disposable ()) { diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index daab41f5d..1a0e0d1b3 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -1011,7 +1011,7 @@ public class Vala.GTypeModule : GErrorModule { var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_return_val_if_fail")); ccall.add_argument (subccall); - ccall.add_argument (new CCodeIdentifier ("NULL")); + ccall.add_argument (new CCodeConstant ("NULL")); ccode.add_expression (ccall); ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_param_spec_internal")); @@ -1190,7 +1190,7 @@ public class Vala.GTypeModule : GErrorModule { var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_return_val_if_fail")); ccall.add_argument (ccall_typecheck); - ccall.add_argument (new CCodeIdentifier ("NULL")); + ccall.add_argument (new CCodeConstant ("NULL")); ccode.add_expression (ccall); ccode.add_return (vpointer); @@ -2347,8 +2347,8 @@ public class Vala.GTypeModule : GErrorModule { get_value.add_argument ((CCodeExpression) get_ccodenode (((MemberAccess) expr.call).inner)); ccode.add_assignment (get_variable_cexpression (temp_var.name), get_value); - var is_null_value = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, get_variable_cexpression (temp_var.name), new CCodeIdentifier ("NULL")); - set_cvalue (expr, new CCodeConditionalExpression (is_null_value, new CCodeMemberAccess.pointer (get_variable_cexpression (temp_var.name), "value_name"), new CCodeIdentifier ("NULL"))); + var is_null_value = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, get_variable_cexpression (temp_var.name), new CCodeConstant ("NULL")); + set_cvalue (expr, new CCodeConditionalExpression (is_null_value, new CCodeMemberAccess.pointer (get_variable_cexpression (temp_var.name), "value_name"), new CCodeConstant ("NULL"))); } pop_line (); } diff --git a/codegen/valagvariantmodule.vala b/codegen/valagvariantmodule.vala index 91a66881a..2e4c4956e 100644 --- a/codegen/valagvariantmodule.vala +++ b/codegen/valagvariantmodule.vala @@ -345,7 +345,7 @@ public class Vala.GVariantModule : GValueModule { // NULL terminate array var length = new CCodeIdentifier (temp_name + "_length"); var element_access = new CCodeElementAccess (new CCodeIdentifier (temp_name), length); - ccode.add_assignment (element_access, new CCodeIdentifier ("NULL")); + ccode.add_assignment (element_access, new CCodeConstant ("NULL")); } return new CCodeIdentifier (temp_name); @@ -505,7 +505,7 @@ public class Vala.GVariantModule : GValueModule { } else if (key_type.type_symbol.get_full_name () == "GLib.HashTable") { hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_hash_table_unref"), "GDestroyNotify")); } else { - hash_table_new.add_argument (new CCodeIdentifier ("NULL")); + hash_table_new.add_argument (new CCodeConstant ("NULL")); } if (value_type.type_symbol.is_subtype_of (string_type.type_symbol)) { @@ -515,7 +515,7 @@ public class Vala.GVariantModule : GValueModule { } else if (value_type.type_symbol.get_full_name () == "GLib.HashTable") { hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_hash_table_unref"), "GDestroyNotify")); } else { - hash_table_new.add_argument (new CCodeIdentifier ("NULL")); + hash_table_new.add_argument (new CCodeConstant ("NULL")); } ccode.add_assignment (new CCodeIdentifier (temp_name), hash_table_new);