Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
onMessageSend_dsa
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 afti_codeToAdd {
// interpreted Cyan code
}
According to the method name, the Cyan code is interpreted in phase
afti or dsa. Methods of interfaces
IAction_dsa
IActionNewPrototypes_dsa
IAction_afti
IActionNewPrototypes_afti
IParseWithCyanCompiler_dpa
ICommunicateInPrototype_afti_dsa_afsa
IActionMessageSend_dsa
can be implemented. To better understand this, see the documentation
for action_afti_dsa.
*}
object OnMessageSend_dsa
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_dsa{*
func dsa_analyzeReplaceKeywordMessage {
let t = env searchPackagePrototype: "cyan.lang", "Int";
return [. "0", t .]
}
*}
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
You can’t perform that action at this time.