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 | |
/* | |
@addCodeFromMetaobject is in prototype Array. The annotation | |
addCodeToGenericPrototype gives the code to be added to the | |
array of prototype AddCodeFromMetaobject. | |
*/ | |
@addCodeToGenericPrototype("Array", " func sumAll -> Int"){* |
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 | |
@addBeforeMethod("zero", "logStr = logStr ++ \"called zero\";") | |
object AddBeforeMethod | |
func run { | |
assert zero == 0; | |
assert logStr == "called zero"; | |
} |
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 | |
@addMethodTo("func zero -> Int", "func zero -> Int = 0;") | |
@addMethodTo( | |
"""func len: String s less: Int -> Int""", | |
""" | |
func len: String s less: Int n -> Int { return s size - n} | |
""") | |
object AddMethodTo |
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
@addToSet("debug", "yes") | |
@addToSet("author", "Jose") | |
program | |
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 | |
@annot("correct this") | |
@annot( [ 2, 3, 5, 7 ] ) | |
object Annot | |
func run { | |
var Int count = 0; | |
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{* | |
Ranges are attached to types. A variable of type Int@range(first, last) | |
can only contain values between first and last (inclusive). This is | |
checked at compile-time when a literal is assigned to the variable | |
and at run-time if an expression is assigned to the variable. | |
*} | |
object Range |
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{* | |
usage: | |
String@regex(re) | |
regex checks if the variable holds only strings that match the | |
regular expression re. | |
*} | |
object Regex |
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
@addToSet(debug, "yes") | |
@addToSet(author, "Jose") | |
/* Because of this association, prototype 'TaintedToUntainted' | |
of package 'untainted' can cast expressions of type | |
T@tainted to T@untainted in which T is any type. | |
*/ | |
@addToSet(untaintedDoNotCheckIn, "untainted.TaintedToUntainted") | |
program | |
main metaobjectTest.Program |
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 untainted | |
object TaintedToUntainted | |
func toUntaintedSql: String@tainted(sql) s -> String@untainted(sql) = s; | |
func toUntaintedHtml: String@tainted(html) s -> String@untainted(html) = s; | |
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 | |
import untainted | |
object Tainted | |
func run { | |
var String@tainted(sql) maliciousSqlCode = | |
"I will delete your database"; |
OlderNewer