0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

106 Commits

Author SHA1 Message Date
LemonBoy
afe0466fb1
patch 9.0.1786: Vim9: need instanceof() function
Problem:  Vim9: need instanceof() function
Solution: Implement instanceof() builtin

Implemented in the same form as Python's isinstance because it allows
for checking multiple class types at the same time.

closes: #12867

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-08-23 21:08:11 +02:00
Yegappan Lakshmanan
618e47d1cd
patch 9.0.1780: Vim9 type not defined during object creation
Problem:  Vim9 type not defined during object creation
Solution: Define type during object creation and not during class
          definition, parse mulit-line member initializers, fix lock
          initialization

If type is not specified for a member, set it during object creation
instead of during class definition.  Add a runtime type check for the
object member initialization expression

Also, while at it, when copying an object or class, make sure the lock
is correctly initialized.

And finally, parse multi-line member initializers correctly.

closes: #11957
closes: #12868
closes: #12869
closes: #12881

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-08-22 21:29:28 +02:00
Yegappan Lakshmanan
6ac1544e13
patch 9.0.1760: vim9 class problem with new() constructor
Problem:  vim9 class problem with new() constructor
Solution: Don't allow a return type for the new() class constructor.

closes: #12863
closes: #12040

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-20 18:20:17 +02:00
Yegappan Lakshmanan
4b1cc7906f
patch 9.0.1757: ex_class() function is too long
Problem:  ex_class() function is too long
Solution: refactor it

closes: #12858

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-19 22:39:33 +02:00
Christian Brabandt
28ae5a32fd
patch 9.0.1746: vim9class compile error for char/char_u conversion
Problem: vim9class compile error for char/char_u conversion
Solution: Correctly cast to (char *)

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-08-19 14:10:48 +02:00
LemonBoy
c5d2744c04
patch 9.0.1741: No type checking in interfaces
Problem: No type checking in interfaces
Solution: Implement member type check in vim9 interfaces

Most of the code is a small refactoring to allow the use of a where_T
for signaling the type mismatch, the type checking itself is pretty
simple.

Improve where_T error reports

Let the caller explicitly define the kind of location it's referring to
and free the WT_ARGUMENT enum from its catch-all role.

Implement type checking for interface methods

Follows closely the logic used for type-checking the members.

closes: #12844

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-08-19 13:04:53 +02:00
Yegappan Lakshmanan
b102728c20
patch 9.0.1737: Calling a base class method through an extended class fails
Problem: Calling a base class method through an extended class fails
Solution: Create lookup table for member index in the interface to
          to the member class implementing the interface

Create additional tests for Vim9 classes.  Fix unconvered memory leaks
and crashes found by the new tests.

closes: #12848
closes: #12089

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>author
2023-08-19 11:26:42 +02:00
Yegappan Lakshmanan
a456b12011
patch 9.0.1720: Vim9 class using wrong index for overridden method
Problem: Vim9 class using wrong index for overridden method
Solution: Use correct index for overridden method

closes: #12524
closes: #12813

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-16 20:14:37 +02:00
Jia-Ju Bai
5b0889b8bf
patch 9.0.1712: missing null check in object_clear()
Problem: missing null check in object_clear()
Solution: Add null check of cl

closes: #12627

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Jia-Ju Bai <baijiaju@buaa.edu.cn>
2023-08-13 20:05:18 +02:00
Yegappan Lakshmanan
74cc13cc40
patch 9.0.1703: Vim9 Calling a method in an extended class fails
Problem: Vim9 Calling a method in an extended class fails
Solution: use method index directly

closes: #12778

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-13 17:41:26 +02:00
Yegappan Lakshmanan
57a02ccf4c
patch 9.0.1701: vim9 crash when class member overridden
Problem: vim9 crash when class member overridden
Solution: Use method_count field instead

closes: #12676
closes: #12677

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-13 10:19:38 +02:00
Bram Moolenaar
f7ca56f719 patch 9.0.1609: crash when an object indirectly references itself
Problem:    Crash when an object indirectly references itself.
Solution:   Avoid clearing an object while it is already being cleared.
            (closes #12494)
2023-06-05 16:53:25 +01:00
Ernie Rael
114ec813b3 patch 9.0.1605: crash when calling method on super in child constructor
Problem:    Crash when calling method on super in child constructor. (Israel
            Chauca Fuentes)
Solution:   Clear the type list. (Ernie Rael, closes #12489, closes #12471)
2023-06-04 18:11:35 +01:00
h-east
61378a1542 patch 9.0.1466: cannot use an object member name as a method argument
Problem:    Cannot use an object member name as a method argument.
Solution:   Do not give an error for using an object member name for a method
            argument. (Hirohito Higashi, closes #12241, closes #12225)
            Fix line number for other argument error.
2023-04-18 19:07:29 +01:00
Bram Moolenaar
d13dd30240 patch 9.0.1402: crash when using null_class
Problem:    Crash when using null_class.
Solution:   Give an error when trying to use a null class.
2023-03-11 20:56:35 +00:00
=?UTF-8?q?Ola=20S=C3=B6der?=
d8742476d1 patch 9.0.1381: ACCESS_ names have a conflict with on some systems
Problem:    ACCESS_ names have a conflict with on some systems.
Solution:   Rename by prepending VIM_. (Ola Söder, closes #12105)
2023-03-05 13:12:32 +00:00
Bram Moolenaar
83ae6150bf patch 9.0.1355: no error when declaring a class twice
Problem:    No error when declaring a class twice. (Ernie Rael)
Solution:   Pass different flags when declaring the class. (closes #12057)
2023-02-25 19:59:31 +00:00
Bram Moolenaar
b1e32ac0c9 patch 9.0.1334: using tt_member for the class leads to mistakes
Problem:    Using tt_member for the class leads to mistakes.
Solution:   Add a separate tt_class field.
2023-02-21 12:38:51 +00:00
Bram Moolenaar
552bdca781 patch 9.0.1317: crash when using an unset object variable
Problem:    Crash when using an unset object variable.
Solution:   Give an error instead. (closes #12005)
2023-02-17 21:08:50 +00:00
Bram Moolenaar
d0200c8631 patch 9.0.1254: calling a method on an interface does not work
Problem:    Calling a method on an interface does not work.
Solution:   At runtime figure out what method to call. (closes #11901)
2023-01-28 15:19:40 +00:00
Bram Moolenaar
657aea7fc4 patch 9.0.1249: cannot export an abstract class
Problem:    Cannot export an abstract class. (Ernie Rael)
Solution:   Add the EX_EXPORT flag to :abstract. (closes #11884)
2023-01-27 13:16:19 +00:00
Bram Moolenaar
62a6923470 patch 9.0.1240: cannot access a private object member in a lambda
Problem:    Cannot access a private object member in a lambda defined inside
            the class.
Solution:   Go up the context stack to find the class. (closes #11866)
2023-01-24 15:07:04 +00:00
Bram Moolenaar
29ac5df37b patch 9.0.1209: getting interface member does not always work
Problem:    Getting interface member does not always work.
Solution:   Convert the index on the interface to the index on the object.
            (closes #11825)
2023-01-16 19:43:47 +00:00
Bram Moolenaar
ae3205aa55 patch 9.0.1205: crash when handling class that extends another class
Problem:    Crash when handling class that extends another class with more
            than one object members.
Solution:   Correct pointer computations. (closes #11824)
2023-01-15 20:49:00 +00:00
Bram Moolenaar
24a8d06d7f patch 9.0.1198: abstract class not supported yet
Problem:    Abstract class not supported yet.
Solution:   Implement abstract class and add tests.
2023-01-14 13:12:06 +00:00
Bram Moolenaar
b40a2fb3b3 patch 9.0.1194: compiler warning for comparing pointer with int
Problem:    Compiler warning for comparing pointer with int.
Solution:   Change NULL to zero.
2023-01-13 19:18:38 +00:00
Bram Moolenaar
d40f00cb43 patch 9.0.1192: no error when class function argument shadows a member
Problem:    No error when class function argument shadows a member.
Solution:   Check for shadowing.
2023-01-13 17:36:49 +00:00
Bram Moolenaar
a86655af84 patch 9.0.1185: using class from imported script not tested
Problem:    Using class from imported script not tested.
Solution:   Add tests.  Implement what is missing.
2023-01-12 17:06:27 +00:00
Bram Moolenaar
a94bd9d939 patch 9.0.1184: interface of an object is not recognized when checking type
Problem:    Interface of an object is not recognized when checking type.
Solution:   Use the interface implemented by an object.
2023-01-12 15:01:32 +00:00
Bram Moolenaar
58b40092e6 patch 9.0.1178: a child class cannot override functions from a base class
Problem:    A child class cannot override functions from a base class.
Solution:   Allow overriding and implement "super".
2023-01-11 15:59:05 +00:00
Bram Moolenaar
8367716a6e patch 9.0.1159: extends argument for class not implemented yet
Problem:    Extends argument for class not implemented yet.
Solution:   Basic implementation of "extends".
2023-01-08 19:54:10 +00:00
Bram Moolenaar
df8f947359 patch 9.0.1157: "implements" only handles one interface name
Problem:    "implements" only handles one interface name.
Solution:   Handle a comma separated list of names.  Check for duplicate
            names.
2023-01-07 14:51:03 +00:00
Bram Moolenaar
2c01131c2a patch 9.0.1154: Coverity warns for dead code
Problem:    Coverity warns for dead code.
Solution:   Remove condition that is always true.
2023-01-07 10:51:30 +00:00
Bram Moolenaar
7d4d87ba89 patch 9.0.1153: build error with some compilers
Problem:    Build error with some compilers.
Solution:   Clear pointer the right way.
2023-01-06 18:59:08 +00:00
Bram Moolenaar
94674f2223 patch 9.0.1152: class "implements" argument not implemented
Problem:    Class "implements" argument not implemented.
Solution:   Implement "implements" argument.  Add basic checks for when a
            class implements an interface.
2023-01-06 18:42:20 +00:00
Bram Moolenaar
554d031302 patch 9.0.1150: :interface is not implemented yet
Problem:    :interface is not implemented yet.
Solution:   Implement the basics of :interface.
2023-01-05 19:59:18 +00:00
Bram Moolenaar
e83c133eb9 patch 9.0.1136: memory leak when getting class member type from expr
Problem:    Memory leak when getting class member type from expr.
Solution:   Clear the expression result.
2023-01-02 21:04:04 +00:00
Bram Moolenaar
993dbc33a8 patch 9.0.1128: build failure
Problem:    Build failure.
Solution:   Add type cast.  Add missing error messages.
2023-01-01 20:31:30 +00:00
Bram Moolenaar
6acf757c6a patch 9.0.1127: no error if function argument shadows class member
Problem:    No error if function argument shadows class member.
Solution:   Give an error for shadowing a class member.
2023-01-01 19:53:30 +00:00
Bram Moolenaar
ec8b74f7ab patch 9.0.1125: memory leak when using class functions
Problem:    Memory leak when using class functions.
Solution:   Clear and free the array with class functions.
2023-01-01 14:11:27 +00:00
Bram Moolenaar
6bafdd41cb patch 9.0.1123: class function not implemented yet
Problem:    Class function not implemented yet.
Solution:   Implement defining and calling a class function.
2023-01-01 12:58:33 +00:00
Bram Moolenaar
f54cedd676 patch 9.0.1091: assignment to non-existing member causes a crash
Problem:    Assignment to non-existing member causes a crash. (Yegappan
            Lakshmanan)
Solution:   Give an error message and bail out when a member cannot be found.
2022-12-23 17:56:27 +00:00
Bram Moolenaar
418b547881 patch 9.0.1083: empty and comment lines in a class cause an error
Problem:    Empty and comment lines in a class cause an error.
Solution:   Skip empty and comment lines. (closes #11734)
2022-12-20 13:38:22 +00:00
Bram Moolenaar
8efdcee02e patch 9.0.1076: ASAN complains about NULL argument
Problem:    ASAN complains about NULL argument.
Solution:   Skip memmove() when there is nothing to move.
2022-12-19 12:18:09 +00:00
Bram Moolenaar
d505d17885 patch 9.0.1074: class members are not supported yet
Problem:    Class members are not supported yet.
Solution:   Add initial support for class members.
2022-12-18 21:42:55 +00:00
Bram Moolenaar
3d473ee1a6 patch 9.0.1060: private and public object members are not implemented yet
problem:    Private and public object members are not implemented yet.
Solution:   Implement private and public object members.
2022-12-14 20:59:32 +00:00
Bram Moolenaar
eb53350c02 patch 9.0.1056: leaking memory when disassembling an object method
Problem:    Leaking memory when disassembling an object method.
Solution:   Free the typval of the class.
2022-12-14 15:06:11 +00:00
Bram Moolenaar
74e1274edf patch 9.0.1054: object member can't get type from initializer
Problem:    Object member can't get type from initializer.
Solution:   If there is no type specified try to use the type of the
            initializer.  Check for a valid type.
2022-12-13 21:14:28 +00:00
Bram Moolenaar
65b0d16768 patch 9.0.1053: default constructor arguments are not optional
Problem:    Default constructor arguments are not optional.
Solution:   Use "= v:none" to make constructor arguments optional.
2022-12-13 18:43:22 +00:00
Bram Moolenaar
7ce7daf6cd patch 9.0.1045: in a class object members cannot be initialized
Problem:    In a class object members cannot be initialized.
Solution:   Support initializing object members. Make "dissassemble" work on
            an object method.
2022-12-10 18:42:12 +00:00