Skip to content

Commit

Permalink
Fix reserved names to use keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeRanDev committed Dec 1, 2023
1 parent d6ffd6b commit 56fdc0e
Showing 1 changed file with 12 additions and 29 deletions.
41 changes: 12 additions & 29 deletions src/gdcompiler/GDCompilerInit.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
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<String> {
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;
}
}

Expand Down

0 comments on commit 56fdc0e

Please sign in to comment.