Last active
August 30, 2022 12:12
-
-
Save joseoliv/a967b5acc412d745967aa452141e877f to your computer and use it in GitHub Desktop.
onVariableDeclaration
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 local | |
variable. 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_dpa | |
ICommunicateInPrototype_afterResTypes_semAn_afterSemAn | |
IActionVariableDeclaration_semAn | |
can be implemented. To better understand this, see the documentation | |
for action_afterResTypes_semAn. | |
*} | |
open | |
object OnVariableDeclaration | |
func run { | |
@onVariableDeclaration{* | |
func semAn_codeToAddAfter { | |
return """ count = self getZero; | |
Out println: "count = " ++ count;""" | |
} | |
func afterResTypes_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