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 / main.c
Created November 28, 2024 22:59
Dynamically typed language translation to C
// also in https://www.onlinegdb.com/edit/xhqFlnv8f
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
struct TypeData {
void (**virtualTable)(void);
char **methodNameList;
int methodNameListSize;
@joseoliv
joseoliv / OnSubprototype.cyan
Last active August 31, 2022 12:25
onSubprototype
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a prototype. The
Cyan code attached to the annotation is run in phase afterSemAn. Method
afterSemAn_checkSubprototype of the class of metaobject onSubprototype,
overridden from ICheckSubprototype_afterSemAn, just interpret the Cyan
statements attached to the annotation.
@joseoliv
joseoliv / OnOverride.cyan
Last active August 31, 2022 12:23
onOverride
package metaobjectTest
@doc{*
Annotations of this metaobject are attached to a declaration. The
Cyan code attached to the annotation is run in phase afterSemAn. Method
afterSemAn_checkOverride of the class of metaobject onOverride,
overridden from ICheckOverride_afterSemAn, just interpret the Cyan
statements attached to the annotation.
@joseoliv
joseoliv / onDeclaration_afterSemAn.cyan
Last active August 31, 2022 12:22
onDeclaration_afterSemAn
package metaobjectTest
@doc{*
Annotations of this metaobject are attached to a declaration. The
Cyan code attached to the annotation is run in phase afterSemAn. Method
afterSemAn_checkDeclaration of the class of metaobject onDeclaration_afterSemAn,
overridden from ICheckDeclaration_afterSemAn, just interpret the Cyan
statements attached to the annotation.
@joseoliv
joseoliv / Cyan-in-20-minutes
Last active August 30, 2022 12:53
Cyan in 20 minutes
package main
// import a Cyan package
import cyan.math
import cyan.reflect
// import a Java package
import java.lang
@doc{*
@joseoliv
joseoliv / OverrideTest.cyan
Last active August 30, 2022 12:13
overrideTest
package metaobjectTest
@doc{*
Annotation 'overrideTest' should be attached to a method.
It generates a file with a prototype for testing with
the contents of the attached DSL whenever the attached
method is overridden in a subprototype. Let us see the details.
The following checks are made whenever the method attached
@joseoliv
joseoliv / OnVariableDeclaration.cyan
Last active August 30, 2022 12:12
onVariableDeclaration
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a local
variable. The attached DSL code is made in Myan, which supports
interpreted Cyan within parameterless methods declared with 'func':
func afterResTypes_codeToAdd {
// interpreted Cyan code
@joseoliv
joseoliv / OnOverride_afterResTypes_semAn_afterSemAn.cyan
Last active August 30, 2022 11:54
onOverride_afterResTypes_semAn_afterSemAn
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a method.
The attached DSL code is made in Myan, which supports interpreted Cyan
within parameterless methods declared with 'func':
func afterResTypes_codeToAdd {
// interpreted Cyan code
@joseoliv
joseoliv / OnMethodMissing.cyan
Last active August 30, 2022 11:50
onMethodMissing
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a prototype.
The attached DSL code is made in Myan, which supports interpreted Cyan
within parameterless methods declared with 'func':
func afterResTypes_codeToAdd {
// interpreted Cyan code
@joseoliv
joseoliv / OnMessageSend_afterSemAn.cyan
Last active August 30, 2022 11:48
onMessageSend_afterSemAn
package metaobjectTest
@doc{*
Annotations of this metaobject should be attached to a method or
method signature (of an interface).
The attached DSL code is made in Myan, which supports interpreted Cyan
within parameterless methods declared with 'func':
func afterResTypes_codeToAdd {