View Cep.cyan
package metaobjectTest | |
@doc{* | |
This annotation takes two parameters. The first is a number. There should be | |
an error from the line of the annotation plus this number. The second parameter | |
is the error message that the compiler should issue (or a similar message). | |
The compiler checks if there is an error in the indicated line. If not, | |
an error message is issued. That is, suppose the code | |
@cep(1, "Expression expected) |
View SymbolToString.cyan
package metaobjectTest | |
@doc{* | |
Annotation 'symbolToString' takes a single parameter and produces | |
a string whose contents is the parameter. Then the annotation is | |
an expression of type String. | |
This annotation is used mainly in generic prototypes to convert | |
a generic parameter to a string. |
View Shout.cyan
package metaobjectTest | |
@doc{* | |
Annotation 'shout' can be attached to a method. It changes | |
all strings to uppercase letters. This is a demonstration | |
metaobject, of course. | |
*} | |
object Shout |
View ShouldCallSuperMethod
package metaobjectTest | |
@doc{* | |
Metaobject 'shouldCallSuperMethod' is an action function. Its | |
associated metaobject declares a method 'eval' that may be | |
called by other metaobjects. It cannot be associated to | |
an annotation: | |
// compile-time error | |
@shouldCallSuperMethod |
View GetPackageValueFromKey.cyan
package metaobjectTest | |
@doc{* | |
Annotation 'GetPackageValueFromKey' is String expression. It is | |
"" if its parameter is not a key of the package of the current | |
prototype. If it is, the expression is the value associated to | |
the key in the package but transformed into a string by either | |
method toString of Java or method asString of Cyan. | |
View GetProgramValueFromKey.cyan
package metaobjectTest | |
@doc{* | |
Annotation 'getProgramValueFromKey' is String expression. It is | |
"" if its parameter is not a program key. If it is, the expression | |
is the value associated to the key in the program but | |
transformed into a string by either method toString of Java or | |
method asString of Cyan. | |
View SetVariable.cyan
package metaobjectTest | |
@doc{* | |
Annotation 'setVariable' can be attached to the program or a package. | |
It takes two parameters, a key and a value, and associates the | |
program or package key to the value. If the attached annotation is | |
the program, the value can be got from method | |
Object getProgramValueFromKey(String key) | |
of WrProgram. If the attached annotation is a package, the value can |
View RunPastCode.cyan
package metaobjectTest | |
import cyan.io | |
@doc{* | |
Annotation 'runPastCode' | |
*} | |
object RunPastCode | |
View afti_dsa_test(MetSig,UMS,Ret).myan
var String funcName; | |
func afti_beforeMethodCodeList { | |
return [ [. MetSig, "fp = \"c\";".], [. UMS, "unaryReturn = Ret;" .] ]; | |
} | |
func afti_codeToAdd { | |
var java.lang.String ssi = "func succ: Int n -> Int"; | |
var String s = ssi; |
View RunFile.cyan
package metaobjectTest | |
@doc{* | |
This metaobject works like action_afti_dsa but the | |
Myan code is read from the file that is the first parameter. So, instead | |
of putting the Myan code attached to the annotation, it is read from | |
the file, which may be preceded by a package name. The file should have | |
extension myan and be in the –-data directory of the package. Usage example: | |
NewerOlder