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 / ChangeFunctionForMethod
Last active June 22, 2018 18:09
Metaobject changeFunctionForMethod
package metaobjectTest
@doc{*
This metaobject should only be attached to methods 'functionForMethod:1' and
'functionForMethodWithSelf:1' of Any. It replaces method calls to these
methods by an anonymous function. If the parameter of 'functionForMethod:1' is
a literal string "m:1", then the code that
replaces the method call is
{ (: T elem :) receiver m: elem }
@joseoliv
joseoliv / CheckCatchParameter.cyan
Created June 24, 2018 21:36
checkCatchParameter
package metaobjectTest
@doc{*
checkCatchParameter checks whether each parameter to a catch: selector
has at least one 'eval:' method, each of them accepting one parameter whose
type is subprototype of CyException
*}
object CheckCatchParameter
package metaobjectTest
@doc{*
Annotation 'codeAfter' adds the code attached to the
annotation after a local variable declaration.
*}
object CodeAfter
func run {
@joseoliv
joseoliv / CompilationInfo.cyan
Created June 12, 2019 02:12
compilationInfo
package metaobjectTest
@doc{*
Annotation 'compilationInfo' takes a parameter and returns an information
on the current source code. The parameter and the return type are as
follows:
"filename", "String"
"prototypename", "String"
package metaobjectTest
import generic
@doc{*
Annotation 'concept' should be attached to a prototype. It tests
whether one or more prototypes obey some restrictions. That
includes parameters to the generic prototype.
*}
object Concept
@joseoliv
joseoliv / GroupWork(1).cyan
Created June 12, 2019 02:25
prototype with annotation concept
package generic
@concept{*
T has [ func * (T other) -> T
func unit -> T
func inverse -> T ],
"T should have methods *, unit, and inverse in order to be considered element of a Group",
axiom opTest: T a, T b, T c {%
@joseoliv
joseoliv / IntGroupPlus.cyan
Created June 12, 2019 02:26
prototype that uses annotation concept
package generic
@concept{*
cyan.lang.init(IntGroupPlus, Int),
cyan.lang.lessThan(IntGroupPlus)
*}
object IntGroupPlus
@init(_elem)
@property var Int _elem;
@joseoliv
joseoliv / CountFieldAccess
Created June 12, 2019 02:36
countFieldAccess
package metaobjectTest
@doc{*
Annotation 'countFieldAccess' should be attached to a field. It
creates an Int field countFieldAccess_fieldName if the attached field
is fieldName. countFieldAccess_fieldName is the number of times
the field was accessed for reading or writing.
*}
object CountFieldAccess
@joseoliv
joseoliv / Deprecated.cyan
Last active June 12, 2019 17:06
deprecated
package metaobjectTest
@doc{*
Annotation 'deprecated' should be attached to a method.
Whenever there is a possible message passing that can call
the method, an error message is issued at compile-time
*}
object Deprecated
package metaobjectTest
@doc{*
Annotation 'doc' can be attached to any declaration, including
the program and packages
*}
object Doc
@doc{*