Last active
August 30, 2022 11:45
-
-
Save joseoliv/8d5cbe043565dbe3d2990263cbc64b1c to your computer and use it in GitHub Desktop.
onMessageSend_semAn
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
package metaobjectTest | |
@doc{* | |
Annotations of this metaobject should be attached to a prototype. | |
The attached DSL code is made in Myan, which supports interpreted Cyan | |
within parameterless methods declared with 'func': | |
func afterResTypes_codeToAdd { | |
// interpreted Cyan code | |
} | |
According to the method name, the Cyan code is interpreted in phase | |
afterResTypes or semAn. Methods of interfaces | |
IAction_semAn | |
IActionNewPrototypes_semAn | |
IAction_afterResTypes | |
IActionNewPrototypes_afterResTypes | |
IParseWithCyanCompiler_parsing | |
ICommunicateInPrototype_afterResTypes_semAn_afterSemAn | |
IActionMessageSend_semAn | |
can be implemented. To better understand this, see the documentation | |
for action_afterResTypes_semAn. | |
*} | |
object OnMessageSend_semAn | |
func run { | |
var Int r = self mult: 2 to: 5; | |
assert r == 0; | |
} | |
/* | |
message passings | |
x mult: n, other | |
are replaced by, simply, 0. | |
*/ | |
@onMessageSend_semAn{* | |
func semAn_analyzeReplaceKeywordMessage { | |
return [. "0", "cyan.lang", "Int" .] | |
} | |
*} | |
func mult: Int n to: Int other -> Int { | |
return n*other | |
} | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment