Skip to content

Instantly share code, notes, and snippets.

@joseoliv
Last active August 31, 2022 12:25
Show Gist options
  • Save joseoliv/30673d2fbfa4d1963bd6ace0ae09d215 to your computer and use it in GitHub Desktop.
Save joseoliv/30673d2fbfa4d1963bd6ace0ae09d215 to your computer and use it in GitHub Desktop.
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 afterSemAn. Method
afterSemAn_checkSubprototype of the class of metaobject onSubprototype,
overridden from ICheckSubprototype_afterSemAn, just interpret the Cyan
statements attached to the annotation.
Then, in phase afterSemAn of the compilation, the Myan statements
attached to the annotation onSubprototype below are interpreted.
Myan is interpreted Cyan.
To better understand this, see the documentation for action_afterResTypes_semAn.
*}
@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