Skip to content

Instantly share code, notes, and snippets.

View joseoliv's full-sized avatar

José de Oliveira Guimarães joseoliv

View GitHub Profile
@joseoliv
joseoliv / afti_dsa_test(MetSig,UMS,Ret).myan
Created June 24, 2019 07:51
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;
@joseoliv
joseoliv / RunFile.cyan
Last active June 24, 2019 07:54
runFile
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:
package metaobjectTest
@doc{*
Annotation 'rpn' takes an expression in Reverse Polish Notation (RPN)
in the attached DSL and evaluates it at compile-time. The annotation
is an expression of type Int. Only positive integer numbers are allowed
in the RPN expression.
This is a demonstration metaobject.
@joseoliv
joseoliv / SubRestrictOverrideTo.cyan
Created June 24, 2019 07:21
SubRestrictOverrideTo
package main
open
object SubRestrictOverrideTo extends metaobjectTest.RestrictOverrideTo
override
func myprint { }
end
@joseoliv
joseoliv / RestrictOverrideTo.cyan
Created June 24, 2019 07:20
restrictOverrideTo
package metaobjectTest
@doc{*
Annotation 'restrictOverrideTo' should be attached to
a method. Its parameter list is composed of prototype names,
with the package. The annotated method can only be
overridden in those prototypes.
*}
open
object RestrictOverrideTo
@joseoliv
joseoliv / ImplementRestrictImplementation.cyan
Created June 24, 2019 06:55
ImplementRestrictImplementation
package metaobjectTest
object ImplementRestrictImplementation implements RestrictImplementation
func run {
}
override
func myprint { }
@joseoliv
joseoliv / RestrictImplementation
Last active June 24, 2019 07:04
restrictImplementation
package metaobjectTest
@doc{*
Annotation 'restrictImplementation' should be attached to
an interface. Its parameter list is composed of prototypes.
The interface can only be implemented by prototypes that
are in the list or its subprototypes.
*}
@joseoliv
joseoliv / RenameMethod.cyan
Last active June 24, 2019 05:19
renameMethod
package metaobjectTest
@doc{*
Annotation 'renameMethod' should be attached to a prototype.
It takes at least two parameters: the first is a method name
and the others are the new selectors for the method. Example:
@renameMethod("at:1 with:2", "myAt:", "myWith:")
This annotation will rename method "at:1 with: 2" to "myAt:1 myWith:2".
Overloaded methods cannot be renamed.
package metaobjectTest
@doc{*
Annotation 'readOnly' should be attached to a method.
It assures that there is no assignment to either
shared or non-shared fields inside the method.
Note that does not guarantee that the method does
not change the receiver fields (self fields). These
can be changed by methods called by the attached method:
@joseoliv
joseoliv / PrototypeCallOnly.cyan
Last active June 24, 2019 04:08
prototypeCallOnly
package metaobjectTest
@doc{*
Annotation 'prototypeCallOnly' should be attached to a method.
It assures that the method is only called with a prototype
as receiver. This is a replacement for 'static' methods
of Java/C++/C#. An annotated method cannot access
non-shared fields and it should be final (either
declared with 'final' or the prototype is final).