Commit graph

1383 commits

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