Skip to content

Instantly share code, notes, and snippets.

@joseoliv
Last active August 30, 2022 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseoliv/8d5cbe043565dbe3d2990263cbc64b1c to your computer and use it in GitHub Desktop.
Save joseoliv/8d5cbe043565dbe3d2990263cbc64b1c to your computer and use it in GitHub Desktop.
onMessageSend_semAn
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