Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package metaobjectTest
Annotations of this metaobject are attached to a declaration. The
Cyan code attached to the annotation is run in phase afsa. To better
understand this, see the documentation for action_afti_dsa.
var Boolean found = false;
var Int size = compiler getMethodDecList size;
for i in 0..< size {
var String methodName = ((compiler getMethodDecList) get: i) getName;
if methodName == "run" {
found = true;
if !found {
metaobject addError: "This prototype should have a 'run' method";
object OnDeclaration_afsa
func run {
var annotation = metaobject getMetaobjectAnnotation;
var String name = annotation getDeclaration getName;
if name != "age" {
metaobject addError: "Field name should be 'age'"
var Int age = 0;
var Int size = metaobject getAttachedDeclaration
getMethodSignature getParameterList size;
if ( size != 2 ) {
metaobject addError: "This method should have two paramters"
func at: Int n put: String s {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment