Skip to content

Instantly share code, notes, and snippets.

@joseoliv joseoliv/OnOverride.cyan
Last active Nov 4, 2019

Embed
What would you like to do?
onOverride
package metaobjectTest
@doc{*
Annotations of this metaobject are attached to a declaration. The
Cyan code attached to the annotation is run in phase afsa. Method
afsa_checkOverride of the class of metaobject onOverride,
overridden from ICheckOverride_afsa, just interpret the Cyan
statements attached to the annotation.
Then, in phase afsa of the compilation, the Tyan statements
attached to the annotation onOverride below are interpreted.
Tyan is interpreted Cyan.
To better understand this, see the documentation for action_afti_dsa.
*}
open
object OnOverride
func run {
}
@onOverride{*
// the overridden method should call
// this method in its first statement
// shouldCallSuperMethod is an action function
// of package cyan.lang
call: #shouldCallSuperMethod;
*}
/* print a warning message if method 'draw' is overridden in
a subprototype that does not declares a 'subMethod' method.
*/
@onOverride{*
var Boolean found = false;
var methodList =
method getDeclaringObject getMethodDecList: (compiler getEnv);
for i in 0..< methodList size {
var String methodName = (methodList get: i) getName;
if methodName == "subMethod" {
found = true;
break;
}
}
if !found {
var String protoName = method getDeclaringObject getName;
Out println: "Prototype " ++ method getDeclaringObject getName ++
" should have a 'subMethod' method";
}
*}
func draw {
}
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.