Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
onSubprototype
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a prototype. The
Cyan code attached to the annotation is run in phase afsa. Method
afsa_checkSubprototype of the class of metaobject onSubprototype,
overridden from ICheckSubprototype_afsa, just interpret the Cyan
statements attached to the annotation.
Then, in phase afsa of the compilation, the Tyan statements
attached to the annotation onSubprototype below are interpreted.
Tyan is interpreted Cyan.
To better understand this, see the documentation for action_afti_dsa.
*}
@onSubprototype{*
// demands that every subprototype has a method 'subprint'
// if not, issue a warning message
var Boolean found = false;
var methodList = subPrototype getMethodDecList: env;
for i in 0..< methodList size {
if (methodList get: i) getName == "subprint" {
return Nil;
}
}
Out println:
"'" ++ subPrototype getName ++
"' is a subprototype of '" ++
metaobject getAttachedDeclaration getName ++
"' It should define a method 'subprint'. It does not";
*}
open
object OnSubprototype
func run {
}
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.