This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// import a Cyan package | |
import cyan.math | |
import cyan.reflect | |
// import a Java package | |
import java.lang | |
@doc{* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
object Program | |
func run { | |
"Hello world" println | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package metaobjectTest | |
import cyan.io | |
@doc{* | |
Annotation 'runPastCode' | |
*} | |
object RunPastCode | |
NewerOlder