Commit graph

1492 commits

Author SHA1 Message Date
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
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
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
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
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