forked from supercollider/supercollider
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SCLang, ClassLib: Add keyword argument syntax ... kwargs (supercollid…
…er#6339) SCLang and ClassLib: implement ... kwargs This commit makes many changes, but because of how the interpreter bootstraps itself, it isn't possible to pull these out into smaller atomic steps that will each pass the CI. Implement a new syntax for passing keyword arguments. This commit should not change behaviour. Update parse node code so it is compiler correctly. Refactor out putting the arguments onto the stack for a method call so the logic for keyword collisions and other issues is always the same. Further, make this function take an optional environment to look values up in. This is called `prepareArgsForExecute`. Use this new function to rewrite `executeMethod`. Since the logic for all method calls goes through only one function, `executeMethodWithKeys` can be removed. Do the same for `blockValue`, `blockValueWithKeys`, `blockValueEnvir` and `blockValueEnvirWithKeys`, these other methods can't be removed because they are primitive functions and a stable pointer to them is needed. Similarly, `doesNotUnderstand` is unified with `doesNotUnderstandWithKeys`, refactored, and made to pass the new keyword argument array correctly. The logic from `sendMessage`, `sendMessageWithKeys`, `superSendMessage` and `superSendMessageWithKeys` is extracted into one function and deletes the `*WithKeys` functions. An additional primitive, `objectPerformArgsAndKwArgs` is created that allows you to pass an keyword argument array as this is impossible to do otherwise. The sc method `performList`'s signature is changed to fix a longstanding bug with keyword arguments and `*[]` array unpacking of arguments. The cpp function objectperformListWithKeys is also created to fix this. Now in the class library Object is given a new method, `performWithArgsAndKwArgs` allowing to pass an array to the keyword arguments array. DoesNotUnderstand is updated to allow keywords to be reported. Object's `doesNotUnderstand` method is updated to accept keyword arguments and passes these to the error correctly. TestKwargs.sc is created that tests all this behaviour. Further, the documentation is updated. This required a new primitive to correctly report how many variable arguments there are. * ClassLib: fix functionPerformList to use _ObjectPerformList primitive to conform to its namesake. * ClassLib: Add test to TestKwargs.sc to check functionPerformList is working correctly. * SCLang: unite the primitives superPerformList with performList, adding support for keyword arguments * SCLang: Remove unused class, update headers in touched files, insert static_casts on touched code, new line at end of file. * SCLang: Comment PyrMessage.cpp, remove unnecessary variables, generally improve readability. Also comment PyrKernel.h as one of the slots is used oddly and not mentioned. * SCLang: Add comments, simplify code in performListTemplate. * SCLang: Improve error message in performList variants * ClassLib: Add test of performArgs * SCLang: Add HOT to block frame creation in blockValueWithKeys. This prefers functions with normal arguments, matching keywords and no variable arguments. --------- authored-by: JordanHendersonMusic <[email protected]>, co-authored by Julian Rohrhuber and Dennis Scheiba
- Loading branch information
1 parent
976098f
commit a404575
Showing
30 changed files
with
2,486 additions
and
3,173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.