Skip to content

Instantly share code, notes, and snippets.

@joseoliv
Last active June 13, 2019 20:44
Show Gist options
  • Save joseoliv/481f7e16d7d465d2ffc110cd190ee98b to your computer and use it in GitHub Desktop.
Save joseoliv/481f7e16d7d465d2ffc110cd190ee98b to your computer and use it in GitHub Desktop.
createPrototype
package metaobjectTest
@doc{*
Annotation 'createPrototype' creates one or two prototypes in the
current package given their names. It can be used
@createPrototype(prototypeName1, codeForPrototypeName1)
or
@createPrototype(prototypeName1, codeForPrototypeName1,
prototypeName2, codeForPrototypeName2)
prototypeName1 is created in phase dpa, and
prototypeName2 is created in phase afti.
*}
object CreatePrototype
@createPrototype(
"Dragon",
"package metaobjectTest\nobject Dragon\n func get -> Int { return 0 }\n\nend",
"Elf",
"package metaobjectTest\nobject Elf\n func get -> String { return \"Elf !\" }\n\nend"
)
func run {
let Dragon dragon = Dragon new;
assert dragon get == 0;
assert Elf() get == "Elf !";
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment