Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
onVariableDeclaration
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a local
variable. 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
IActionVariableDeclaration_dsa
can be implemented. To better understand this, see the documentation
for action_afti_dsa.
*}
open
object OnVariableDeclaration
func run {
@onVariableDeclaration{*
func dsa_codeToAddAfter {
return """ count = self getZero;
Out println: "count = " ++ count;"""
}
func afti_codeToAdd {
return [. "func getZero -> Int = 0; ",
"func getZero -> Int" .];
}
*}
var Int count = 1;
assert self getZero == 0;
assert count == 0;
}
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.