From 56fdc0e549935d454e5a59e7608645738fd2a942 Mon Sep 17 00:00:00 2001 From: Robert Borghese <28355157+SomeRanDev@users.noreply.github.com> Date: Thu, 30 Nov 2023 21:36:47 -0500 Subject: [PATCH] Fix reserved names to use keywords --- src/gdcompiler/GDCompilerInit.hx | 41 ++++++++++---------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/src/gdcompiler/GDCompilerInit.hx b/src/gdcompiler/GDCompilerInit.hx index 8f548b1..b597206 100644 --- a/src/gdcompiler/GDCompilerInit.hx +++ b/src/gdcompiler/GDCompilerInit.hx @@ -76,37 +76,20 @@ class GDCompilerInit { return ["reflaxe.gdscript", "gdscript"].contains((Sys.getEnv("HAXELIB_RUN_NAME") ?? "").toLowerCase()); } - static function reservedNames() { - return gdKeywords().concat(gdUtilityFuncs()); - } - - static function gdKeywords(): Array { - return [ - "func", "assert" - ]; - } - /** - the "utility_functions" from the Godot `extension_api.json`. + List of reserved words found here: + https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html + + Added "load" manually? Maybe should remove? **/ - static function gdUtilityFuncs(): Array { - return [ - "sin","cos","tan","sinh","cosh","tanh","asin","acos","atan","atan2","sqrt","fmod", - "fposmod","posmod","floor","floorf","floori","ceil","ceilf","ceili","round","roundf", - "roundi","abs","absf","absi","sign","signf","signi","snapped","snappedf","snappedi", - "pow","log","exp","is_nan","is_inf","is_equal_approx","is_zero_approx","is_finite", - "ease","step_decimals","lerp","lerpf","cubic_interpolate","cubic_interpolate_angle", - "cubic_interpolate_in_time","cubic_interpolate_angle_in_time","bezier_interpolate", - "bezier_derivative","lerp_angle","inverse_lerp","remap","smoothstep","move_toward", - "deg_to_rad","rad_to_deg","linear_to_db","db_to_linear","wrap","wrapi","wrapf", - "max","maxi","maxf","min","mini","minf","clamp","clampi","clampf","nearest_po2", - "pingpong","randomize","randi","randf","randi_range","randf_range","randfn","seed", - "rand_from_seed","weakref","typeof","str","error_string","print","print_rich", - "printerr","printt","prints","printraw","print_verbose","push_error","push_warning", - "var_to_str","str_to_var","var_to_bytes","bytes_to_var","var_to_bytes_with_objects", - "bytes_to_var_with_objects","hash","instance_from_id","is_instance_id_valid", - "is_instance_valid","rid_allocate_id","rid_from_int64" - ]; + static var _reservedNames = [ + "if", "elif", "else", "for", "while", "match", "break", "continue", "pass", + "return", "class", "class_name", "extends", "is", "in", "as", "self", "signal", + "func", "static", "const", "enum", "var", "breakpoint", "load", "preload", + "await", "yield", "assert", "void", "PI", "TAU", "INF", "NAN" + ]; + static function reservedNames() { + return _reservedNames; } }