Commit graph

240 commits

Author SHA1 Message Date
Rémi Verschelde
a797fa3b3d
Merge pull request #70503 from rune-scape/inner-class-docs
Inner classes get their docs back
2023-01-03 12:15:44 +01:00
George Marques
0c15844551
GDScript: Error when assigning return value of void function
This also makes built-in method calls empty the return value when the
method is void, to avoid keeping returning a garbage value in such case.
2022-12-30 12:08:58 -03:00
Dmitrii Maganov
b6aa4840d8 Fix usage of Enum as constant 2022-12-28 23:04:40 +02:00
rune-scape
1b77993257 Inner classes get their docs back 2022-12-23 17:39:24 -05:00
Rémi Verschelde
ae4c025da9
Merge pull request #69991 from rune-scape/cast-type
GDScript: Fix cast producing null
2022-12-23 09:22:21 +01:00
rune-scape
e1c63fee86 GDScript: Fix built-in script and other find_class bugs 2022-12-15 14:56:23 -05:00
rune-scape
2dfc6d5b69 GDScript: Allow out of order member resolution 2022-12-14 21:44:05 -05:00
rune-scape
7d0d6aa16f GDScript: Fix cast producing null 2022-12-12 19:57:26 -05:00
ocean (they/them)
c8293a73b4 Add GDScript member initializer implicit type conversion 2022-12-11 16:55:02 -05:00
Rémi Verschelde
f6ea295bb1
Merge pull request #69467 from rune-scape/rune-subclass-script-path
GDScript: Fix subclass script path issues
2022-12-10 10:21:19 +01:00
Rémi Verschelde
907298d673
Merge pull request #68747 from rune-scape/rune-stringname-unification
GDScript: Unify StringName and String
2022-12-09 18:06:48 +01:00
rune-scape
e79be6ce07 Unify String and StringName 2022-12-05 21:46:47 -05:00
Dmitrii Maganov
97280279ee Fix incomplete shadowing of member properties by parameters 2022-12-06 00:22:56 +02:00
rune-scape
d531869a7c GDScript: Fix subclass script path issues 2022-12-01 20:43:27 -05:00
Yuri Rubinsky
8d2506e811 Reset unassigned local variables to null in the loops 2022-11-28 19:45:24 +03:00
Adam Scott
4e60689695 Fix cyclic reference base being loaded but not valid (which is ok) 2022-11-27 15:50:19 -05:00
Adam Scott
5704055d30 Fix cyclic references in GDScript 2.0 2022-11-18 16:41:31 -05:00
Rune
61df8f4484 GDScript Compiler: regression fix 2022-11-15 22:20:49 -06:00
Rune
bce6f1792e GDScript compiler subclass bugfixes 2022-11-13 02:29:21 -08:00
Yuri Rubinsky
f11b66b084 Fix named enums to use int64 type 2022-11-08 11:20:28 +03:00
bruvzg
0103af1ddd
Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4. 2022-10-07 11:32:33 +03:00
Andy Maloney
127e2333f4 Remove redundant "if" condition in GDScriptCompiler::_parse_function()
Looking at the original PR, I believe this is the original intent, but it now means that previously dead code is now executed.
2022-09-24 12:30:43 -04:00
Fabio Alessandrelli
ca7d572908 [Net] Modularize multiplayer, expose MultiplayerAPI to extensions.
- RPC configurations are now dictionaries.
- Script.get_rpc_methods renamed to Script.get_rpc_config.
- Node.rpc[_id] and Callable.rpc now return an Error.
- Refactor MultiplayerAPI to allow extension.
- New MultiplayerAPI.rpc method with Array argument (for scripts).
- Move the default MultiplayerAPI implementation to a module.
2022-07-26 09:31:12 +02:00
cdemirer
52781535a3 Check for parameters shadowing class members 2022-07-18 00:28:27 +03:00
Yuri Sizov
f85bafaa11 Add grouping annotations for class properties in GDScript 2022-07-05 22:01:40 +03:00
cdemirer
a0608bd891 Fix set chain bug with jump_if_shared 2022-06-28 18:45:27 +03:00
Rémi Verschelde
c4a426d6ec
Merge pull request #62462 from vnen/gdscript-setter-chaining
GDScript: Fix setter being called in chains for shared types
2022-06-27 23:25:53 +02:00
George Marques
511a4b761c
GDScript: Fix setter being called in chains for shared types
When a type is shared (i.e. passed by reference) it doesn't need to be
called in a setter chain (e.g. `a.b.c = 0`) since it will be updated in
place.

This commit adds an instruction that jumps when the value is shared so
it can be used to skip those cases and avoid redundant calls of setters.
It also solves issues when assigning to sub-properties of read-only
properties.
2022-06-27 12:09:51 -03:00
George Marques
cf015673d3
GDScript: Use implicit method for @onready variables
Initialize them with the implicit method so they're not related to the
overriding of the `_ready` method of the script but instead are always
set.
2022-06-24 14:49:21 -03:00
George Marques
81cac4907f
GDScript: Don't add implicit constructor to the list of functions
So it's not shown on docs or when listing the methods. This also avoids
being able to call it using the `call()` function.
2022-06-24 14:48:46 -03:00
bruvzg
860e24683f
Make enum/constant binds 64-bit. 2022-06-17 16:36:26 +03:00
George Marques
15740c37a3
Merge pull request #57151 from cdemirer/fix-match-array-dict-pattern-logic-error
Fix logic errors in match-statement Array & Dictionary patterns
2022-06-14 21:30:05 -03:00
George Marques
eba3e0a9fc
GDScript: Support % in shorthand for get_node
The `%` is used in scene unique nodes. Now `%` can also be used instead
of `$` for the shorthand, besides being allowed generally anywhere in
the path as the prefix for a node name.
2022-05-27 13:46:18 -03:00
Yuri Rubinsky
5d95a5a024 Fix crash when extending inner class in GDScript 2022-05-18 16:53:24 +03:00
reduz
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
reduz
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
Hugo Locurcio
180e5d3028
Remove RES and REF typedefs in favor of spelled out Ref<>
These typedefs don't save much typing compared to the full `Ref<Resource>`
and `Ref<RefCounted>`, yet they sometimes introduce confusion among
new contributors.
2022-05-03 01:43:50 +02:00
George Marques
01d13ab2c1
GDScript: Allow using self in lambdas 2022-04-24 21:49:02 -03:00
George Marques
cdbd6056ef
GDScript: Fix method call on singletons 2022-04-08 12:20:57 -03:00
George Marques
4710e2b278
GDScript: Add support for static method calls in native types 2022-04-06 14:14:38 -03:00
Rémi Verschelde
79bbe57244
Merge pull request #56830 from strank/parent-signals 2022-03-04 17:29:49 +01:00
Rémi Verschelde
4bbd7417c4
Merge pull request #58320 from mphe/fix_object_typed_arrays 2022-03-04 14:49:06 +01:00
cdemirer
3afe50c2fa Fix logic errors in match-statement Array & Dictionary Patterns 2022-03-02 19:05:18 +08:00
Marvin Ewald
cea0630fef Fix typed arrays for Object based types
Fixes https://github.com/godotengine/godot/issues/53771.
2022-02-19 16:27:06 +01:00
SaracenOne
ab2a8bd1d8 Fix using typed arrays based on script classes 2022-02-17 17:34:53 +00:00
strank
dcf19f8914 Fix "Identifier not found" compiler error when accessing inherited signals or functions as callables. 2022-02-11 20:45:04 -05:00
George Marques
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
George Marques
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
strank
960a26f6c0 GDScript: Fix parsing default parameter values from function calls 2022-01-13 19:28:39 -05:00
SaracenOne
64d8b3aef2 Assign member type when parsing setters to prevent
'Compiler bug: unresolved assign' errors
2022-01-11 11:23:17 +00:00
Rémi Verschelde
cc7f634066
Merge pull request #56260 from cdemirer/fix-type-mutation-upon-assignment-with-operation 2022-01-10 17:12:34 +01:00
Rémi Verschelde
c8b4fe3b8d
Merge pull request #56287 from cdemirer/fix-member-property-only-getter-cant-be-set 2022-01-10 17:12:06 +01:00
Rémi Verschelde
1fd5954962
Merge pull request #56288 from cdemirer/fix-member-property-getter-dont-update-subscript-chain-root 2022-01-10 17:10:57 +01:00
Ger Hean
609964848d Fix leak when function returning self type
Leak is caused by cyclic reference
2022-01-10 02:14:48 +08:00
Rémi Verschelde
fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
cdemirer
bb9469aa65 Fix member properties with getters don't update as subscript chain root 2021-12-28 07:52:44 +08:00
cdemirer
e8305e17ff Fix member properties with only getters can't be set 2021-12-28 07:51:18 +08:00
cdemirer
067b4c8c07 Fix type mutation upon compound assignment 2021-12-27 03:32:22 +08:00
Nathan Franke
49403cbfa0
Replace String comparisons with "", String() to is_empty()
Also:
- Adds two stress tests to test_string.h
- Changes to .empty() on std::strings
2021-12-09 04:48:38 -06:00
George Marques
d36213bab8
GDScript: Make sure calls don't use return when not needed 2021-10-14 19:55:45 -03:00
ZuBsPaCe
551ceb590b GDScript: Report property type errors
Inline getters & setters are now FunctionNodes.
Their names are set in the parser, not in the compiler.
GDScript-Analyzer will now run through getter and setter.
Also report wrong type or signature errors regarding getset properties.
Added GDScript tests for getters and setters.
#53102
2021-10-08 22:06:15 +02:00
Brian Semrau
c18a27a9cd GDScript fix wrong base class assignment 2021-10-04 20:38:08 -04:00
George Marques
84956fee4b
GDScript: Fix member assignment with operation
It was wrongly updating the assigned value with the result of the
operation.
2021-10-04 14:09:54 -03:00
Lightning_A
c63b18507d Use range iterators for Map 2021-09-30 15:09:12 -06:00
George Marques
991f4d8527
GDScript: Fix assignment with operation for properties 2021-09-29 10:54:16 -03:00
George Marques
5a612d61b9
Merge pull request #49765 from Blackiris/fix-assignment-with-operator-on-type-member
Fix assignment with operator on type member
2021-09-15 10:56:20 -03:00
George Marques
5d31ce4b16
GDScript: Allow string keys on Lua-style dictionaries
Which is useful when the key isn't a valid identifier, such as keys with
spaces or numeric keys.
2021-09-15 09:56:24 -03:00
Rémi Verschelde
ffe8412291
Merge pull request #52323 from vnen/gdscript-singleton-interdependence-fix
Fix loading of interdependent autoloads
2021-09-13 21:10:34 +02:00
Fabio Alessandrelli
bf9aae09ba [Net] Move multiplayer to core subdir, split RPCManager.
Move multiplayer classes to "core/multiplayer" subdir.

Move the RPCConfig and enums (TransferMode, RPCMode) to a separate
file (multiplayer.h), and bind them to the global namespace.

Move the RPC handling code to its own class (RPCManager).

Renames "get_rpc_sender_id" to "get_remote_sender_id".
2021-09-07 11:14:30 +02:00
SaracenOne
84852585b9 Check for GDScript member and class naming conflicts in a variety of conditions. 2021-09-02 07:16:06 +01:00
George Marques
3d13588057
GDScript: Fix loading of interdependent autoloads
Move the autoload resolution to runtime by loading it into the stack
with an extra instruction. This allows an autoload to use another
autoload singleton independent of load order.
2021-09-01 16:06:30 -03:00
Julien Nguyen
9bc5119d4e Fix assignment with operator on type member 2021-08-21 21:56:11 +02:00
George Marques
89695da337
GDScript: Fix memory leak when using self class as type 2021-08-18 18:58:45 -03:00
Julien Nguyen
51b7179b5a Fix infinite loop when creating a newly inherited GdScript file 2021-08-09 23:52:31 +02:00
Rémi Verschelde
ac3322b0af
Use const references where possible for List range iterators 2021-07-25 12:22:25 +02:00
Aaron Franke
4e6efd1b07
Use C++ iterators for Lists in many situations 2021-07-23 17:38:28 -04:00
Fabio Alessandrelli
ddb68f76ff [Net] Single rpc annotation. "sync" no longer part of mode.
- Move the "sync" property for RPCs to RPCConfig.

- Unify GDScript annotations into a single one:
  - `@rpc(master)` # default
  - `@rpc(puppet)`
  - `@rpc(any)` # former `@remote`

- Implement three additional `@rpc` options:
  - The second parameter is the "sync" option (which also calls the
    function locally when RPCing). One of "sync", "nosync".
  - The third parameter is the transfer mode (reliable, unreliable,
    ordered).
  - The third parameter is the channel (unused for now).
2021-07-20 11:17:59 +02:00
Lightning_A
e28fd07b2b Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
Pedro J. Estébanez
04688b92ff Rename Reference to RefCounted 2021-06-11 18:48:42 +02:00
Lyuma
771190a9db Fix regression from 160c260 causing export of non-@export properties. 2021-06-10 20:35:58 -07:00
Rémi Verschelde
59b524ae4c
Merge pull request #49067 from JFonS/fix_gcc_warnings
Fix some warnings raised by GCC-11.1
2021-06-01 10:47:37 +02:00
George Marques
c7459e3855
GDScript: Use analyzer data to decide assignment conversion
Since there might be tricky cases in the analyzer (in the case of unsafe
lines) which would need to be properly checked again. Instead, this
splits the code generator in two functions and use information set by
the analyzer to tell which function to use, without a need to re-check.
2021-05-26 14:09:00 -03:00
jfons
f8e34209af Fix some warnings raised by GCC-11.1 2021-05-25 17:23:53 +02:00
George Marques
cdb3726fe6
Merge pull request #48347 from Blackiris/fix-temporary-key-not-released
GDScript: Fix temporary value not released when used as a dictionary key
2021-05-17 18:50:25 -03:00
George Marques
ec783dd885
GDScript: Add support for builtin static method calls 2021-05-16 11:54:33 -03:00
Julien Nguyen
82522662f8 Fix temporary value not released when used as a dictionary key 2021-05-06 22:13:05 +02:00
George Marques
c201b212c7
GDScript: Implement lambdas compilation and runtime 2021-04-28 11:09:38 -03:00
George Marques
1e4ff2ede6
GDScript: Make sure Lua-style dicts use StringName as keys 2021-04-23 16:00:23 -03:00
George Marques
c7511de02e
GDScript: Fix resolution of dictionary keys
There was a mixup between String and StringName keys. Now they're
clearly separated. This also means you have to consider which type
you're using for the dictionary keys and how you are accessing them.
2021-04-23 15:42:33 -03:00
George Marques
40502a1689
GDScript: Pool temporary values by type on the stack
So the stack slots perform less type changes, which is useful for
future optimizations.
2021-04-14 14:35:51 -03:00
George Marques
cf4079cb5f
Reduce number of addressing modes in GDScript VM
There's now only 3 addressing modes: stack, constant, and member.

Self, class, and nil are now present respectively in the first 3 stack
slots. Global and class constants are moved to local constants when
compiling. Named globals is only present on editor to use on tool
singletons, so its use now emits a new instruction to copy the global to
the stack.

This allow us to further optimize the VM later by embedding the
addressing modes in the instructions themselves, which is better done
with less permutations.
2021-04-08 14:29:55 -03:00
Julien Nguyen
43c1c680f0 Fix stack overflow in setter 2021-04-06 19:00:08 +02:00
Julien Nguyen
3168c2a513 Fix GDScript variables addresses getting mixed 2021-04-04 19:03:15 +02:00
George Marques
160c260495
GDScript: Allow export of enum variables
Also fix the enum type in variables to be integer.
2021-03-30 08:29:38 -03:00
George Marques
85e316a5d5
Add typed arrays to GDScript
- Use `Array[type]` for type-hints. e.g.:
  `var array: Array[int] = [1, 2, 3]`
- Array literals are typed if their storage is typed (variable
  asssignment of as argument in function all). Otherwise they are
  untyped.
2021-03-29 10:45:48 -03:00
Rémi Verschelde
6edb0a75ab
Merge pull request #46936 from DavidSichma/match_temp_header
Fixed match test expression for temporaries
2021-03-14 15:46:53 +01:00
David Sichma
762bb5843b
Fixed match test expression for temporaries
Fixed that a potentially popped temporary was used for the value in
match statements.
2021-03-12 15:04:45 +01:00
Anshul7sp1
91181c2086 Fixes small typos and grammar correction 2021-03-12 19:05:16 +05:30
David Sichma
66a5002750
Fixed match for expression pattern
equality comparison now writes to right target address
2021-03-02 19:18:29 +01:00
Thakee Nathees
9869522e6a false positive "Identifier not found" error or signals fixed 2021-02-24 19:34:01 +05:30