Commit Graph

489 Commits

Author SHA1 Message Date
45af29da80 Add a new HashSet template
* Intended to replace RBSet in most cases.
* Optimized for iteration speed
2022-05-20 22:40:38 +02:00
746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
8b7c7f5a75 Add a new HashMap implementation
Adds a new, cleaned up, HashMap implementation.

* Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing).
* Keeps elements in a double linked list for simpler, ordered, iteration.
* Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much
  for performance vs keeping the key, but helps replace old code).
* Uses a more modern C++ iterator API, deprecates the old one.
* Supports custom allocator (in case there is a wish to use a paged one).

This class aims to unify all the associative template usage and replace it by this one:
* Map<> (whereas key order does not matter, which is 99% of cases)
* HashMap<>
* OrderedHashMap<>
* OAHashMap<>
2022-05-12 11:21:29 +02:00
f626e8ef91 Merge pull request #60396 from vnen/gdscript-self-lambda 2022-04-27 13:11:24 +02:00
01d13ab2c1 GDScript: Allow using self in lambdas 2022-04-24 21:49:02 -03:00
b3704e664d Fixes GDScript define nested dictionary and array as constants #50285 2022-04-19 08:57:23 -04:00
4710e2b278 GDScript: Add support for static method calls in native types 2022-04-06 14:14:38 -03:00
a647fb3e62 Fix typos with codespell
Using codespell 2.2-dev from current git.

Fix a couple incorrect uses of gendered pronouns.
2022-03-31 14:07:29 +02:00
be718285f7 GDScript: Fix issues with completion and super calls
- Make call errors use the call node instead of the calle, which will be
  empty on super calls.
- Don't allow `super()` to be used within lambdas.
2022-03-30 11:58:29 -03:00
c14043b166 Prevent NARROWING_CONVERSION warning for int(float) function in GDScript 2022-03-22 09:17:00 +03:00
6cba2143de Merge pull request #59056 from Chaosus/gds_fix_extends_crash 2022-03-22 08:27:03 +03:00
5a99aa3b3a Fix default value count checking for inherited function 2022-03-14 18:00:42 +03:00
d009d96a92 Prevent crash due to empty error message on empty extends in GDScript 2022-03-12 09:46:51 +03:00
2eaadb1b52 Restore building web platform by enclosing resolve_function_signature. 2022-03-07 00:35:11 -08:00
1ebcb58e69 GDScript: Check if method signature matches the parent
To guarantee polymorphism, a method signature must be compatible with
the parent. This checks if:

1. Return type is the same.
2. The subclass method takes at least the same amount of parameters.
3. The matching parameters have the same type.
4. If the subclass takes more parameters, all of the extra ones have a
default value.
5. If the superclass has default values, so must have the subclass.

There's a few test cases to ensure this holds up.
2022-03-06 11:16:20 -03:00
bb8c4acdc9 Merge pull request #58185 from V-Sekai/explicit_variant_assignment_fix 2022-03-04 14:56:38 +01:00
d31aaed172 Merge pull request #58626 from groud/fix_gdscript_analyser_crash 2022-03-04 14:15:59 +01:00
57838fc0ee Merge pull request #58262 from Sauermann/fix-range-doc
Describe usage of float in range documentation
2022-03-03 13:12:29 +01:00
7ae988ce5e Fix a crash in GDScriptAnalyzer when a script class's file is not found 2022-02-28 12:20:00 +01:00
b6aa4ed55d Fixes cyclic detection from variables assigning themselves to themselves in autocomplete, and restricts initialization of variables from other variables which have not been declared above it in class body 2022-02-22 01:21:21 +00:00
bac8e451c0 Describe usage of float in range documentation 2022-02-18 00:59:22 +01:00
d45c3cdd1d Fix error when assigning to an explicitly annotated variant from an ambiguous source 2022-02-16 13:25:27 +00:00
317cd0b19a Refactor some object type checking code with cast_to
Less stringly typed logic, and less String allocations and comparisons.
2022-02-08 10:08:34 +01:00
89eb6d372d Merge pull request #57591 from vnen/gdscript-enum-fixes 2022-02-04 13:49:15 +01:00
ceafdf347e GDScript: Treat enum values as int and enum types as dictionary
Since enums resolve to a dictionary at runtime, calling dictionary
methods on an enum type is a valid use case. This ensures this is true
by adding test cases. This also makes enum values be treated as ints
when used in operations.
2022-02-03 13:32:34 -03:00
ad6e2e82a9 GDScript: Consolidate behavior for assigning enum types
This makes sure that assigning values to enum-typed variables are
consistent. Same enum is always valid, different enum is always
invalid (without casting) and assigning `int` creates a warning
if there is no casting.

There are new test cases to ensure this behavior doesn't break in
the future.
2022-02-03 13:32:16 -03:00
28ac4d8b7d Fix crash with non-constant keys in match statement Dictionary pattern 2022-01-26 04:10:07 +08:00
4cfade6212 Merge pull request #55995 from Xwdit/enum_fix
Fix enum int comparison
2022-01-17 20:20:16 +01:00
1989120d3f Merge pull request #56194 from cdemirer/fix-operation-result-type-inference 2022-01-10 17:18:32 +01:00
4acc819f9b Merge pull request #56232 from V-Sekai/invalid_explicit_variant_assign_fix 2022-01-10 17:12:56 +01:00
cc7f634066 Merge pull request #56260 from cdemirer/fix-type-mutation-upon-assignment-with-operation 2022-01-10 17:12:34 +01:00
6d4ed65f4c Merge pull request #56483 from vnen/gdscript-warning-annotation
Add annotation to ignore warnings
2022-01-05 09:05:56 +01:00
fd643c903d GDScript: Add annotation to ignore warnings 2022-01-04 09:32:43 -03:00
fe52458154 Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
067b4c8c07 Fix type mutation upon compound assignment 2021-12-27 03:32:22 +08:00
b22c805dbe Fix 'Compiler bug: unresolved assign' on explicitly annotated variants. 2021-12-25 00:53:57 +00:00
455cc07f90 Fix operation result type inference 2021-12-23 20:45:24 +08:00
0430e26e6d Fix enum int comparison
Fix enum int comparison
2021-12-16 16:14:14 +01:00
ab8119b5f6 Avoid a crash in the gdscript analyser 2021-12-14 15:54:25 +01:00
566895732c Fix shadowed global identifier warning duplication 2021-12-13 11:54:23 +03:00
4682f22293 Improve various texts 2021-11-23 12:20:57 +01:00
560d9a4cc0 Fix incorrect debug check for setters
the check read the return type of the setter, which doesn't exist and
lead to a segmentation fault. Now we check the first function parameter.
Probably a bad copy/paste of the getter case
2021-10-18 09:01:16 +02:00
3f888966c0 Merge pull request #53843 from vnen/gdscript-typed-array-subscript-constant
Fix inferred typed array marked as constant
2021-10-15 16:49:29 +02:00
540821a264 GDScript: Fix inferred typed array marked as constant 2021-10-15 10:40:50 -03:00
84abb9a76c GDScript: Fix typing for await expression
Don't grab the type of the awaited value unless it's constant (which
makes it synchronous) or call (which always use the proper return type).
2021-10-14 20:30:06 -03:00
749d89ae38 GDScript: Remove error when coroutine is called without await
In the case the call happens as a statement, since the return value
isn't used in this case.
2021-10-14 20:12:01 -03:00
bf322bacdd Merge pull request #53726 from briansemrau/gd-outer-class
GDScript 2.0: Access outer scope classes
2021-10-14 10:12:52 -03:00
0ff0f64cd4 GDScript: Access outer scope classes 2021-10-13 22:39:12 -04:00
e4288bf728 Merge pull request #53720 from vnen/gdscript-typed-array-custom-class 2021-10-12 16:51:50 +02:00
34288b24a6 GDScript: Fix typed array with custom classes 2021-10-12 10:41:04 -03:00