Commit graph

1657 commits

Author SHA1 Message Date
Rémi Verschelde
4e06731346
Merge pull request #47958 from Xrayez/gdscript-rename-test-scripts
Rename GDScript test script filenames to use `snake_case`
2021-05-03 15:44:46 +02:00
Rémi Verschelde
5b16020846
Replace remaining uses of NULL with nullptr
Follow-up to #38736 (these uses were likely added after this PR was merged).
2021-04-29 11:53:27 +02:00
George Marques
9ed0f0384c
GDScript: Fix crash when base of an attribute is invalid
In attribute expressions (`a.b`) it's possible that the base has an
incorrect syntax and thus become a nullptr expression in the tree. This
commit add the check for this case to fail gracefully instead of
crashing.
2021-04-28 11:09:40 -03:00
George Marques
c201b212c7
GDScript: Implement lambdas compilation and runtime 2021-04-28 11:09:38 -03:00
George Marques
3155368093
GDScript: Add lambdas to the type analyzer
- Lambdas are always callables (no specific signature match).
- Captures from the current context are evaluated.
2021-04-28 10:56:16 -03:00
George Marques
c6e66a43b0
GDScript: Add lambda syntax parsing
Lambda syntax is the same as a the function syntax (using the same
`func` keyword) except that the name is optional and it can be embedded
anywhere an expression is expected. E.g.:

    func _ready():
        var my_lambda = func(x):
            print(x)
        my_lambda.call("hello")
2021-04-28 10:56:16 -03:00
Rémi Verschelde
8247667a3e
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.
2021-04-27 16:26:27 +02:00
Hugo Locurcio
5d124c4a8f
Remove uses of auto for better readability and online code reviews
The current code style guidelines forbid the use of `auto`.

Some uses of `auto` are still present, such as in UWP code (which
can't be currently tested) and macros (where removing `auto` isn't
easy).
2021-04-26 14:59:28 +02:00
Rémi Verschelde
d1dc28e46c
Merge pull request #48139 from vnen/gdscript-dict-keys
Fix mismatch between String and StringName in dictionary keys
2021-04-24 19:46:59 +02:00
Rémi Verschelde
db90ab86b9
Merge pull request #47891 from Razoric480/lsp-update-filesystem
Make LSP update the filesystem for changed scripts
2021-04-24 13:17:31 +02: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
Rémi Verschelde
a9ecf66342
Merge pull request #47956 from vnen/gdscript-double-stack
GDScript: Use special stack space for temporaries to reduce type changes
2021-04-20 17:39:09 +02:00
Andrii Doroshenko (Xrayez)
1e26bf23c2 Rename GDScript test script filenames to use snake_case 2021-04-16 22:16:19 +03:00
George Marques
9411bf05a4
GDScript: Adjust type of temporaries when needed 2021-04-16 12:04:08 -03:00
Rémi Verschelde
200d9a734c
Merge pull request #47701 from vnen/gdscript-test-runner 2021-04-16 10:34:39 +02: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
Francois Belair
b16bb33a5b Make LSP update the filesystem of changed scripts
This updates global classes and exposes base member variables.
Fixes #39713
2021-04-14 13:12:39 -04:00
George Marques
8fc4a732de
Merge pull request #47330 from Blackiris/fix-corrupt-scene-when-export-has-setter
Fix corrupt scene when export var has setter
2021-04-14 10:00:57 -03:00
Julien Nguyen
79a16b8a44 Fix corrupt scene when export var has setter 2021-04-14 09:14:50 +02:00
Julien Nguyen
9936abb3d5 Fix type argument in is_builtin which was treated as an address 2021-04-11 20:34:48 +02:00
ray90514
1f9524bf57 Fix Constants at function scope are not defined as constants for autocompletion 2021-04-11 22:41:04 +08:00
Francois Belair
39f7408ccb Implement LSP didDeleteFiles & make parser aware of sub-nodes 2021-04-10 15:21:59 -04: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
George Marques
5f77f38573
Add runner for GDScript testing
This is meant for testing the GDScript implementation, not for testing
user scripts nor testing the engine using scripts.

Tests consists in a GDScript file and a .out file with the expected
output. The .out file format is: expected status (based on the enum
GDScriptTest::TestStatus) on the first line, followed by either an error
message or the resulting output. Warnings are added after the first
line, before the output (or compiler errors) if the parser pass without
any error.

The test script must have a function called `test()` which takes no
argument. Such function will be called by the test runner. The test
should not have any dependency unless it's part of the test too. Global
classes (using `class_name`) are registered before the runner starts, so
those should work if needed.

Use the command `godot --gdscript-generate-tests
godot-source/modules/gdscript/tests/scripts` to update the .out files
with the current output (make sure the output are the expected values
before committing).

The tests themselves are part of the doctest suite so those can be
executed with `godot --test`.

Co-authored-by: Andrii Doroshenko (Xrayez) <xrayez@gmail.com>
2021-04-08 09:34:59 -03:00
Rémi Verschelde
40dff7117a
Merge pull request #47648 from Blackiris/fix-gdscript-editor-hangs
Fix infinite loop when guessing argument type from parent class
2021-04-07 23:19:29 +02:00
Julien Nguyen
43c1c680f0 Fix stack overflow in setter 2021-04-06 19:00:08 +02:00
Julien Nguyen
20f18f1621 Fix infinite loop when guessing argument type from parent class 2021-04-05 16:39:41 +02:00
Rémi Verschelde
5b2c4ad91c
Merge pull request #47569 from vnen/gdscript-typed-return
GDScript: Properly validate return type
2021-04-05 15:16:43 +02:00
George Marques
35682d3079
GDScript: Properly validate return type
When the type cannot be validated at compile time, the runtime must do a
check to ensure type safety is kept, as the code might be assuming the
return type is correct in another place, leading to crashes if the
contract is broken.
2021-04-05 09:52:05 -03:00
Rémi Verschelde
d83761ba80
Style: Apply clang-tidy's readability-braces-around-statements 2021-04-05 14:09:59 +02:00
Rémi Verschelde
9bbe51dc27
Style: Apply clang-tidy's modernize-use-nullptr 2021-04-05 14:05:07 +02:00
Julien Nguyen
3168c2a513 Fix GDScript variables addresses getting mixed 2021-04-04 19:03:15 +02:00
Rémi Verschelde
4b6e9f3157
Merge pull request #46991 from madmiraal/rename-invert-reverse
Rename Array.invert() to Array.reverse()
2021-04-01 13:32:22 +02:00
Rémi Verschelde
737f09895d
Merge pull request #47131 from vnen/gdscript-export-fix
Fix a few issues with @export in GDScript
2021-03-30 15:12:04 +02:00
Rémi Verschelde
7c14e987b4
Merge pull request #47492 from vnen/gdscript-typed-arrays
GDScript: Fix array type check on constants
2021-03-30 14:37:42 +02:00
George Marques
5d9585d83b
GDScript: Fix array type check on constants
They mistakenly pointing to the wrong union member (variable instead of
constant).
2021-03-30 09:09:13 -03:00
George Marques
2b9be53243
GDScript: Implement export of typed arrays 2021-03-30 08:29:38 -03: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
3e4ecd9669
GDScript: Show error on invalid initializer expression 2021-03-30 08:29:38 -03:00
George Marques
577a17980d
Move GDSript annotation application after type-checking
This ensures that annotations that rely on the datatype (such as
@export) can validated it timely, allowing compound expressions instead
of only literal values.
2021-03-30 08:29:36 -03:00
Rémi Verschelde
aba03110ba
Merge pull request #46830 from vnen/gdscript-typed-arrays
GDScript typed arrays
2021-03-29 16:47:38 +02: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
eeba8d63f8
Merge pull request #44398 from RevoluPowered/unit-tests-for-export-templates
Add unit tests for export templates
2021-03-23 00:42:29 +01:00
Gordon MacPherson
6b4ff3b44b Add unit tests for export templates 2021-03-22 18:57:08 +00:00
Marcel Admiraal
755c70b871 Rename Array.invert() to Array.reverse()
Does the same internally for List and Vector<>, which includes all
PackedArray types.
2021-03-21 10:20:08 +00:00
Alex Hirsch
d7ac5ba1c6 Fix missing quote in multiline GDScript string
fix #47117
2021-03-19 01:24:18 +01: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
Gilles Roudière
ba1344408f Implement Navigation layers 2021-03-10 11:23:06 +01:00
Johannes
982a0ac348
Fix GDScript Tokenizer being very strict about the number of underscores
You can use multiple underscores in one number, just not two of them
together.
2021-03-06 01:57:37 +01:00
David Sichma
66a5002750
Fixed match for expression pattern
equality comparison now writes to right target address
2021-03-02 19:18:29 +01:00
George Marques
16e88f99e2
Merge pull request #42029 from ThakeeNathees/export-type-infer-bug-fix
GDScript export array/dictionary type infer bug fix
2021-03-02 12:14:57 -03:00
Rémi Verschelde
d86369b590
Merge pull request #46559 from asmaloney/fix-code-completion
Script editor: Fix two special cases not being checked in code completion
2021-03-02 15:39:13 +01:00
Rémi Verschelde
75bfb016f2
Merge pull request #41897 from strank/not-in-conditional-done
Add a "not in" operator to GDScript.
2021-03-02 15:16:52 +01:00
Andy Maloney
4e89cb330b [script editor] Fix two special cases not being checked in code completion
When this code was changed for 4.0, a "break" statement inside a for loop in 3.x was changed to "return".

This means that the two special cases (autoloads and input actions) are never checked.

Removing the return lets these work properly in the editor.

(Also reorder conditionals to short-circuit and avoid expensive methods.)
2021-03-01 09:39:03 -05:00
Rémi Verschelde
b7b70004bc
Merge pull request #46379 from ThakeeNathees/signal-idf-not-found-fix
GDScript: False positive "Identifier not found" error on signals fixed
2021-02-25 22:30:22 +01:00
Rémi Verschelde
ee5ea64e83
Merge pull request #40276 from Taywee/master
remove invalid codeLensProvider value from lsp
2021-02-25 17:26:26 +01:00
Thakee Nathees
9869522e6a false positive "Identifier not found" error or signals fixed 2021-02-24 19:34:01 +05:30
Vignesh1-art
a5d931033e
Fixed Invalid function bindings #46135
Fixed  GDScriptLanguageProtocol::notify_client - have 3 arguments, but only 2 are binded
2021-02-18 11:12:54 +05:30
reduz
f8d03b98e7 Improve resource load cache
-Added a new method in Resource: reset_state , used for reloading the same resource from disk
-Added a new cache mode "replace" in ResourceLoader, which reuses existing loaded sub-resources but resets their data from disk (or replaces them if they chaged type)
-Because the correct sub-resource paths are always loaded now, this fixes bugs with subresource folding or subresource ordering when saving.
2021-02-11 15:44:28 -03:00
Rafał Mikrut
f7209b459b Initialize class/struct variables with default values in modules/ 2021-02-08 10:57:18 +01:00
Rémi Verschelde
5525cd85c6
Merge pull request #45315 from RandomShaper/modernize_thread
Modernize Thread
2021-01-31 15:24:56 +01:00
Pedro J. Estébanez
99fe462452 Modernize Thread
- Based on C++11's `thread` and `thread_local`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed (except for the few cases of non-portable functions)
- Simpler for `NO_THREADS`
- Thread ids are now the same across platforms (main is 1; others follow)
2021-01-29 12:02:13 +01:00
Aaron Franke
e829b7aee4
Unify URI encoding/decoding and add to C#
http_escape and percent_encode have been unified into uri_encode, and http_unescape and percent_decode have been unified into uri_decode.
2021-01-28 07:45:01 -05:00
Lucas Van Mol
749d0c708c Fix highlight color for class attributes that are also keywords 2021-01-26 15:17:18 +01:00
Rémi Verschelde
51992250e6
Merge pull request #43176 from mateosss/crash-uninit-const
Fix crash by adding nullcheck for uninitialized constants
2021-01-11 14:00:54 +01:00
Rémi Verschelde
6d48943768
Merge pull request #43980 from gvekan/fix-missing-function-hints
Fix missing function hints
2021-01-11 13:54:22 +01:00
Rémi Verschelde
c17413f159
Merge pull request #44104 from nekomatata/coroutine-await-fix
Fix error when calling coroutine with await in _ready
2021-01-11 13:54:04 +01:00
Rémi Verschelde
813bdb4941
Merge pull request #44005 from RandomShaper/gds_needless_check
Remove useless check in GDScript
2021-01-11 13:53:52 +01:00
Rémi Verschelde
3e9a40cdc0
Merge pull request #44604 from lyuma/gdscript_dictionary_crash
GDScript: Fix crash when iterating through empty dictionary.
2021-01-11 13:53:12 +01:00
Rémi Verschelde
8363c44265
Merge pull request #44719 from ThakeeNathees/assert-argument-bug-fixed
GDScript assert message parsing bug fixed
2021-01-11 13:51:44 +01:00
Rémi Verschelde
a2021588ca
Merge pull request #44672 from ThakeeNathees/array-dict-const-fold-bug-fix
Array/Dictionary marked as not safe to const fold
2021-01-11 13:51:31 +01:00
Rémi Verschelde
bcfb698fb4
Merge pull request #44818 from ThakeeNathees/const-crash-fix
GDScript crash at incomplete const bug fix
2021-01-11 13:51:18 +01:00
Rémi Verschelde
aaf6725150
Merge pull request #44889 from ThakeeNathees/builtin-invalid-call-crash-fix
GDScript invalid method call on built-in crash fix
2021-01-11 13:51:07 +01:00
Rémi Verschelde
0dba21a4d1
Merge pull request #45076 from ThakeeNathees/gdscript-operator-precedence-bug-fix
GDScript operator `+` `-` precedence bug fix
2021-01-11 13:50:00 +01:00
Thakee Nathees
0889f14af9 GDScript operator + - precedence bug fix
Fix: #43265
2021-01-10 18:33:05 +05:30
Rémi Verschelde
215d18814e
doc: Sync classref with current source 2021-01-04 14:33:44 +01:00
Thakee Nathees
01c11ec29b GDScript builtin invalid function call crash fix
Fix: #44852
2021-01-03 18:44:01 +05:30
Rémi Verschelde
b5334d14f7
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +01:00
Thakee Nathees
18f30dda63 GDScript crash at incomplete const bug fix 2020-12-30 23:27:46 +05:30
Marcel Admiraal
b743a2ef3c Rename Math::stepify to snapped 2020-12-28 13:01:30 +00:00
Marcel Admiraal
5b937d493f Rename empty() to is_empty() 2020-12-28 10:39:56 +00:00
Thakee Nathees
ebade0e454 GDScript assert message parsing bug fixed
Fix: #43540
2020-12-27 13:13:50 +05:30
Thakee Nathees
16bb01adfb Array/Dictionary marked as not safe to const fold
Fix: #44459
2020-12-25 12:33:55 +05:30
Lyuma
0d4b750051 Fix crash when iterating through empty dictionary. 2020-12-21 20:15:29 -08:00
PouleyKetchoupp
2e4ee06b7a Fix error when calling coroutine with await in _ready
The code paths for calling async functions seemed to be missing in some
cases, causing a debug break and false positive error.
2020-12-17 09:01:39 -07:00
Rémi Verschelde
88b8c3ec00
Merge pull request #44424 from briansemrau/gdscript-fix-and
Fix gdscript `and` operator
2020-12-16 14:42:56 +01:00
Brian Semrau
61ac640aa0 Fix gdscript and operator 2020-12-16 07:41:10 -05:00
Jordan Schidlowsky
7d07e20bda fixes crash in disassemlber for opcode OPCODE_ASSIGN_TYPED_NATIVE 2020-12-15 21:44:52 -06:00
Rémi Verschelde
94b15bfb89
Merge pull request #44275 from vnen/variant-function-arg-pointers
Use pointer parameters in Variant function pointers
2020-12-15 20:52:03 +01:00
Rémi Verschelde
abfc528439
Merge pull request #43890 from vnen/gdscript-builtin-functions-refactor
GDScript: Refactor builtin functions
2020-12-15 20:51:38 +01:00
skyace65
4fd20015f3 Pow method doc fix 2020-12-13 17:53:30 -05:00
George Marques
e4e9231420
Use pointer parameters in Variant function pointers
Instead of references. This is needed because those function pointers
are used in GDNative which needs to work with plain C, which doesn't
support passing parameters by reference.
2020-12-10 18:18:47 -03:00
Rémi Verschelde
cf62289d24
LSP: Fix iterator in enum API dump 2020-12-09 13:34:29 +01:00
bruvzg
644f739660
Static analyzer fixes:
Removes unused code in OS.
Fixes return types.
Fixes few typos.
2020-12-09 10:17:53 +02:00
Rémi Verschelde
90bdba576a
Merge pull request #43742 from qarmin/editor_modules_default_values
Initialize class/struct variables with default values in platform/ and editor/
2020-12-08 15:53:42 +01:00
Emmanuel Leblond
a211812932
Constify ScriptLanguage.can_inherit_from_file 2020-12-08 13:06:15 +01:00
PouleyKetchoupp
87d73faa66 Fix base script not initialized properly in some cases
Storing script references to pointer only in result.script_type could
lead to losing the last reference, causing further conversions from
Script* to Ref<Script> to fail.

Now result.script_type_ref is always set first, and then cleared in the
specific case of the script being the owner, to avoid cyclic reference
issues.
2020-12-06 08:20:33 -07:00
Rémi Verschelde
ea7dd1be36
Merge pull request #43328 from gvekan/better-keyword-completion
Add bracket or space to some keyword completions
2020-12-03 17:14:32 +01:00
Rémi Verschelde
9c30c83aee
Merge pull request #44011 from KoBeWi/red_roses_minus_blue_violets
Fix subtracting colors and quats
2020-12-03 14:44:52 +01:00
Tomasz Chabora
4c232e4222 Fix subtracting colors and quats 2020-12-03 14:22:12 +01:00
Rémi Verschelde
9a0610c1ff
Merge pull request #43959 from dalexeev/gds-doc
Several edits to the GDScript docs
2020-12-03 13:32:32 +01:00
Gustav
dff3875ae3 Add bracket or space to some keyword completions 2020-12-03 09:44:42 +01:00
Rafał Mikrut
e1811b689b Initialize class/struct variables with default values in platform/ and editor/ 2020-12-02 16:09:11 +01:00
Rémi Verschelde
d1231be1c8
Merge pull request #41095 from ThakeeNathees/GDScript-Documentation
GDScript(2.0) Documentation generation system
2020-12-02 14:15:38 +01:00
George Marques
0019aa940e
Merge pull request #41773 from ThakeeNathees/default-argument-override-buf-fix
GDScript default argument override bug fix
2020-12-02 09:54:47 -03:00
Thakee Nathees
42bfa16996 Refactor DocData into core and editor (DocTools) parts 2020-12-02 00:48:39 +05:30
Danil Alexeev
bf96056ad0 Several edits to the GDScript docs 2020-12-01 16:05:10 +03:00
Pedro J. Estébanez
86ece881e5 Remove useless check in GDScript
The removed check was adding a protection for the case where a `Reference` has not yet got its reference count initialized and a script is called on it. That would cause the object to be released after the call. The removed code was constructing the `Variant` via the `Object` constructor so it didn't deal with the reference count and so the release was prevented.

However, `Variant` no longer works that way so that check was useless. Now it's just illegal to run GDScript on a Reference whose reference count has not been initialized.
2020-12-01 12:28:52 +01:00
Rémi Verschelde
04bef80b42
Merge pull request #43992 from vnen/variant-internal-object-set
Fix VariantInternal initialization and setting of object
2020-11-30 20:22:15 +01:00
Rémi Verschelde
8f3dde18f1
Merge pull request #43504 from AndreaCatania/gds_fix_2
Implement proper error print, Fixes a crash when no error messages are generated by the analyser.
2020-11-30 19:10:38 +01:00
George Marques
029fd88adb
Fix VariantInternal initialization and setting of object
- Initialize Object pointer to nullptr so it's not used by mistake.
- When setting an Object check if it's a reference so refcounting works
  as intended.
2020-11-30 14:49:52 -03:00
George Marques
a604e72dc9
GDScript: Don't construct ref values in compiler
Values that are passed by reference are not suited for being constructed
at compile time because in this case they would be shared across all the
construction statements.
2020-11-30 09:42:22 -03:00
Gustav
e995d5c378 Fix missing function hints 2020-11-30 09:26:32 +01:00
Thakee Nathees
d0e7d9b62f Documentation generation for GDScript
- ClassDoc added to GDScript and property reflection data were extracted
from parse tree

- GDScript comments are collected from tokenizer for documentation and
applied to the ClassDoc by the GDScript compiler

- private docs were excluded (name with underscore prefix and doesn't
have any doc comments)

- default values (of non exported vars), arguments are extraced from the
parser

- Integrated with GDScript 2.0 and new enums were added.

- merge conflicts fixed
2020-11-29 19:45:36 +05:30
Thakee Nathees
d42b305377 GDScript default argument override bug fix
Fix: #41766
2020-11-28 20:42:57 +05:30
AndreaCatania
40403b02fb Implement proper error print, Fixes a crash when no error messages are generated by the analyser. 2020-11-28 13:47:52 +01:00
Rémi Verschelde
d395f70828
Merge pull request #43500 from AndreaCatania/gds_fixes
Fixes crash when parse_expression returns nullptr.
2020-11-27 16:37:45 +01:00
Rémi Verschelde
9f9b269d32
Merge pull request #43914 from ThakeeNathees/range-argument-type-bug-fix
GDScript: range function type check bug fixed
2020-11-27 15:08:02 +01:00
George Marques
cf7a6be1db
Merge pull request #43226 from mateosss/unreachable-prop-crash
Fix crash due to unreachable code in properties
2020-11-27 11:03:20 -03:00
Thakee Nathees
f0613a91be GDScript range function typecheck bug fixed
Fix: #43586
2020-11-27 18:23:35 +05:30
George Marques
fbb806fd68
Unregister GDScriptFunctionState class
This is not user accessible anymore so it does not need to be show in
documentation.
2020-11-26 21:39:54 -03:00
Rémi Verschelde
ed2f84735b
Merge pull request #43895 from vnen/gdscript-operators-fix
GDScript: Improve handling of operators
2020-11-26 21:19:31 +01:00
Rémi Verschelde
e5ff2d0ffd
Merge pull request #43894 from vnen/gdscript-some-fixes
Some GDScript fixes
2020-11-26 18:56:42 +01:00
George Marques
0cb185927c
GDScript: Improve handling of operators
- Use the new functions in Variant to determine the validity and resulting
  type of operators.
- Split the operator function in codegen between binary and unary, since
  the unary ones have now a special requirement of having the second
  argument to be the NIL type when requesting info.
2020-11-26 14:41:55 -03:00
George Marques
627ca7f30e
GDScript: Don't clear depended parsers too soon
It can wait until the analyzer itself is destructed, otherwise other
phases might be using freed parsers.
2020-11-26 14:14:29 -03:00
George Marques
817fb3d702
GDScript: Give an error if dependency can't be parsed
Otherwise this may lead to a crash when the dependency is not present.
2020-11-26 12:27:48 -03:00
George Marques
c7b6a7adcc
GDScript: Refactor builtin functions
They are now called "utility functions" to avoid confusion with methods
of builtin types, and be consistent with the naming in Variant.

Core utility functions are now available in GDScript. The ones missing
in core are added specifically to GDScript as helpers for convenience.

Some functions were remove when there are better ways to do, reducing
redundancy and cleaning up the global scope.
2020-11-26 12:05:42 -03:00
Jordan Schidlowsky
afa15c5f15 fixes crash for OPCODE_CAST_TO_NATIVE opcode in gdscript disassemlber 2020-11-25 16:26:32 -06:00
Rémi Verschelde
fc28de64c4
Merge pull request #43856 from vnen/gdscript-some-fixes
A couple of GDScript fixes
2020-11-25 17:13:41 +01:00
George Marques
ed3d8f31df
GDScript: Fix return of cast expression on compilation
It was mistakenly returning the source instead of the result.
2020-11-25 11:37:51 -03:00
George Marques
fb3dc2670a
GDScript: Fix range() being treated as array when optimized out
The call of range() in a for loop is optimized to use int or vectors, to
avoid allocating an array, however the type was set as array still. With
the new typed VM this is an issue as the type mismatch the actual value,
resulting in wrong instructions to be selected.
2020-11-25 11:35:07 -03:00
George Marques
2e528ef382
GDScript: Fix mishandling of stack pointers
- Replace the for loop temporaries by locals. They cause conflicts with
  the stack when being popped, while locals are properly handled in the
  scope.
- Change the interface for the codegen so the for loop list doesn't live
  through the whole block if it's a temporary.
- Keep track of the actual amount of local variables in the stack. Using
  the size of the map is misleading in cases where multiple locals have
  the same name (which is allowed when there's no shadowing).
- Added a few debug checks for temporaries, to avoid them being wrongly
  manipulated in the future. They should not live more than a line of
  code.
- Rearrange some of compiler code to make sure the temporaries don't
  live across blocks.
2020-11-25 11:24:13 -03:00
George Marques
5518e2a68e
GDScript: Add faster instruction for validated constructor
Only for built-in types.
2020-11-21 13:30:17 -03:00
George Marques
e0dca3c6b6
GDScript: Add typed iterate instructions 2020-11-21 13:24:50 -03:00
George Marques
52ab64db69
GDScript: Add faster call instructions for builtin methods
Methods from builtin types can be called by using the function pointer
when the argument and base types are known at compile time.
2020-11-21 13:24:50 -03:00
George Marques
d8b22097f2
GDScript: Add faster call instructions for native methods 2020-11-21 13:24:50 -03:00
George Marques
5aeb390cd7
GDScript: Add speficic set/get instructions
When the base type is known at compile-time, we can get a direct
function pointer that is faster than the regular set/get paths.
2020-11-21 13:24:49 -03:00
George Marques
1ad5c926dc
GDScript: Add faster operator for known types
It now uses the direct operator function pointer, which increases
performance in evaluation.
2020-11-21 13:24:49 -03:00
George Marques
c707d6fe71
GDScript: Gather instructions arguments beforehand
Almost all instructions need variant arguments. With this change they
are loaded in an array before each instruction call. This makes the
addressing code be localized to less places, improving compilation
overhead and binary size by a small margin.

This should not affect performance.
2020-11-21 13:24:49 -03:00
George Marques
b6519d0d03
GDScript: Split Function code into multiple files
To improve organization and reduce the size of compilation units.
2020-11-21 13:24:49 -03:00
Aaron Franke
02161aad5a
Remove empty lines around braces with the formatting script 2020-11-16 23:38:11 -05:00
Andrea Catania
98daa0af6b Fixes crash when returns . 2020-11-13 15:09:52 +01:00
George Marques
8bcd345782
GDScript: Fix native class not set with inheritance 2020-11-13 10:35:24 -03:00
reduz
635d33dc6c Refactor variant built-in methods yet again.
* Using C-style function pointers now, InternalMethod is gone.
* This ensures much better performance in typed code.
* Renamed builtin_funcs to utility_funcs, to avoid naming confusion
2020-11-11 16:36:36 -03:00
Aaron Franke
ee79fc627c
Minor clamp and float fixes 2020-11-10 14:30:07 -05:00
Gustav
0ddd4097a6 Fix completion for built-in load function 2020-11-10 12:00:08 +01:00
Rémi Verschelde
68067b8d97
Merge pull request #43423 from Calinou/doc-assert-avoid-side-effects
Clarify that code in `assert()` should avoid side effects
2020-11-10 11:31:28 +01:00
Rémi Verschelde
0f249f5c0a
Variant: Sync docs with new constructors, fixups after #43403
Change DocData comparators for MethodDoc and ArgumentDoc to get a better
ordering of constructors.
2020-11-09 23:39:53 +01:00
Hugo Locurcio
d6c7073bd7
Clarify that code in assert() should avoid side effects 2020-11-09 21:48:24 +01:00
Rémi Verschelde
9d2e8f2f27
Variant: Rename Type::_RID to Type::RID
The underscore prefix was used to avoid the conflict between the `RID` class
name and the matching enum value in `Variant::Type`.

This can be fixed differently by prefixing uses of the `RID` class in `Variant`
with the scope resolution operator, as done already for `AABB`.
2020-11-09 16:29:04 +01:00
reduz
221a2a1742 Refactored variant constructor logic 2020-11-09 08:54:43 -03:00
reduz
127458ed17 Reorganized core/ directory, it was too fatty already
-Removed FuncRef, since Callable makes it obsolete
-Removed int_types.h as its obsolete in c++11+
-Changed color names code
2020-11-07 20:17:12 -03:00
reduz
05de7ce6ca Refactored variant setters/getters
-Discern between named, indexed and keyed
-Get direct access to functions for typed GDScript and GDNative bindings
-Small changes to some classes in order to work with the new setget binder
2020-11-07 15:16:15 -03:00
Yuri Roubinsky
38fb26794b Exposed randi_range to global funcs + renamed rand_range to randf_range 2020-11-06 17:06:26 +03:00
Rémi Verschelde
c35517f07e
Merge pull request #42724 from theoway/error_message_fix_call_recursive
Fixes the misleading message when a non-existing function name is passed to TreeItem.call_recursive()
2020-11-05 00:46:28 +01:00
Rémi Verschelde
bd13e82080
Merge pull request #41516 from Lunatoid/allow-object-new
Fixed ParseError when calling Object.new()
2020-11-03 13:08:48 +01:00
Mateo de Mayo
531958b2f0 Fix crash due to unreachable code in properties 2020-10-30 22:21:50 -03:00
Mateo de Mayo
f388177aed Fix crash by adding nullcheck for uninitialized constants 2020-10-29 01:11:19 -03:00
Hugo Locurcio
a1d9c67f43
Optimize SVG using svgcleaner --multipass
This decreases the editor binary size by about 8 KB.
2020-10-25 10:02:37 +01:00
Yuri Roubinsky
4c65dc975c Shows ColorRect in Color constants autocompletion 2020-10-23 19:03:50 +03:00
Rémi Verschelde
ef62e93677
Merge pull request #42943 from vnen/gdscript-local-scope-fix
Fix handling of scope for local GDScript variables
2020-10-20 21:00:57 +02:00
George Marques
96884ef41e
Merge pull request #41983 from ThakeeNathees/array-const-folding-bug-fix
Array/Dictionary Nodes no more reduced to array/dictionary variant
2020-10-20 15:43:07 -03:00
George Marques
11c05642fe
GDScript: Fix handling of scope for local variables 2020-10-20 14:57:31 -03:00
George Marques
48b91b900d
GDScript: Add initialization for the language before debug tests
This ensures that the tests will use a full environment with correct
settings so global classes and autoloads can be properly found.
2020-10-20 10:07:03 -03:00
George Marques
5ddfc657ab
Merge pull request #42067 from ThakeeNathees/for-loop-stack-overriden-fix
GDScript: for loop override stack variable bug fix
2020-10-19 20:21:14 -03:00
Umang Kalra
c37f633216 Fixes the misleading error message for call_recursive method for TreeItems 2020-10-17 12:30:36 +05:30
Hugo Locurcio
802c1e4df1
Link the Random number generation tutorial in the class reference 2020-10-14 18:03:29 +02:00
George Marques
fe6109101f
Merge pull request #41881 from ThakeeNathees/crash-on-builtin-constructor
GDScript crash on builtin type constructor fix
2020-10-08 19:35:35 -03:00
Rémi Verschelde
3556bc48a1
Merge pull request #42439 from Xrayez/doc-gdscript-load-and-resloader-xref
Cross-reference GDScript `load` and `ResourceLoader.load` in classref
2020-10-04 20:48:07 +02:00
Paulb23
ee4a1c99a7 Switch from recursion to iterative for backfilling colour regions 2020-10-03 14:58:55 +01:00
Serhat
9f2cdfea82 Fixed padding bug of sprintf function 2020-10-02 00:25:42 +03:00
Rémi Verschelde
39ea52f36f
Merge pull request #41829 from RandomShaper/fix_40353
Avoid warning about harmless unfulfilled yields
2020-10-01 14:17:34 +02:00
Andrii Doroshenko (Xrayez)
a8404cf56c Cross-reference GDScript load and ResourceLoader.load in classref
The GDScript `load` mention is moved from the class `ResourceLoader`
description to the `ResourceLoader.load` method description instead,
where it is more likely to be found.
2020-09-30 23:03:36 +03:00
Pedro J. Estébanez
de4e54dd91 Avoid infinite loop in GDScript at shutdown 2020-09-26 19:21:09 +02:00
Hugo Locurcio
50f3a8e312
Improve documentation related to printing error/warning messages 2020-09-24 14:23:53 +02:00
strank
409af31b55 Add a "not in" operator to GDScript. 2020-09-21 17:53:54 -04:00
Rémi Verschelde
cff43e5326
Merge pull request #41930 from RandomShaper/fix_gdscript_leaks
Fix leaks in GDScript
2020-09-18 16:18:57 +02:00
Rémi Verschelde
3e78963bb9
Fix typos with codespell
Using codespell 1.17.1.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2020-09-18 13:44:25 +02:00
Thakee Nathees
119936d939 GDScript: for loop override stack variable bug fix
Fix: #42050
2020-09-18 01:22:22 +05:30
Danil Alexeev
a4c5790350 Several documentation improvements 2020-09-14 20:02:19 +03:00
Thakee Nathees
e4d5393ecf GDScript export array/dictionary type infer bug fix
Fix : #41980
2020-09-13 19:36:20 +05:30
Thakee Nathees
3886a2f9f6 Array/Dictinoary no more reduced to array/dictionary variant
Fix: #41377
Fix: #20436
Fix: #41953
2020-09-11 19:46:20 +05:30
Pedro J. Estébanez
e25f5e791e Ensure cyclic dependencies between scripts are broken at exit 2020-09-10 01:34:42 +02:00
Pedro J. Estébanez
95828161d4 Prevent cyclic reference between script and its members 2020-09-10 01:26:07 +02:00
Rémi Verschelde
1c881c973b
GDScript: Fix MutexLock usage, fixes Clang 6 compat
Fixes #41852.
2020-09-09 14:56:57 +02:00
Rémi Verschelde
2410016638
Merge pull request #41709 from ThakeeNathees/dictionary-indexing-bug-fix
Fixed parser error when indexing a dictionary.
2020-09-08 21:38:14 +02:00
Thakee Nathees
279a11bbda GDScript crash on builtin type constructor fix
Fix: #41848
2020-09-08 18:33:53 +05:30
Rémi Verschelde
3c42d5789f
Merge pull request #38308 from bruvzg/sad_security_circus
Adds PCK encryption support (using script encryption key for export).
2020-09-07 17:12:01 +02:00
Pedro J. Estébanez
f76a13dea0 Avoid warning about harmless unfulfilled yields 2020-09-06 22:30:46 +02:00
Rémi Verschelde
859322343c
Merge pull request #41803 from ThakeeNathees/parameter-type-infer-bug-fix
GDScript: parameter infer type bug fix
2020-09-06 15:22:44 +02:00
Thakee Nathees
89489a3cac GDScript: parameter infer type bug fix
Fix: #41772
2020-09-06 13:26:52 +05:30
bruvzg
f043eabdd8
Adds PCK encryption support (using script encryption key for export).
Change default encryption mode from ECB to CFB.
2020-09-05 14:53:39 +03:00
Rémi Verschelde
605d7b7e82
Merge pull request #41760 from ThakeeNathees/null-dereference-on-gdscript-function-fix
null pointer dereference at GDScriptFunction::call crash fix
2020-09-04 14:45:31 +02:00
Thakee Nathees
75d4511cb5 null pointer dereference at GDScriptFunction::call fix 2020-09-04 15:24:09 +05:30
bruvzg
80b8eff6aa
[Complex Test Layouts] Change String to use UTF-32 encoding on all platforms. 2020-09-03 19:56:24 +03:00
Thakee Nathees
4fc14e8e11 fixed parser error when indexing a dictionary.
Fix: #41707
2020-09-03 18:04:54 +05:30
Rémi Verschelde
d84954a281
Merge pull request #41459 from Paulb23/nested_color_regions
Fix colour region end key seach and start key order
2020-09-03 11:32:04 +02:00