Skip to content

Instantly share code, notes, and snippets.

@mtasic85
Created February 8, 2014 17:35
Show Gist options
  • Save mtasic85/8887231 to your computer and use it in GitHub Desktop.
Save mtasic85/8887231 to your computer and use it in GitHub Desktop.
cosmos c backend semantics
from co.lang.c import * # var, field, struct, PTR, ptr, NULL, double ...
class A(struct):
field.x = int
field.y = double
field.z = PTR('A')
def __init__(self, x: int, y: double, z: PTR('A')):
self.x = x
self.y = y
self.z = z
# A a0;
# A__init__(&a0, 2, 0.4, NULL);
var.a0 = A
a0 = A(2, 0.4, NULL)
# A * a1;
# a1 = (A*) malloc(sizeof(A));
# A__init__(a1, 2, 0.4, NULL);
var.a1 = PTR(A)
a1 = A(2, 0.4, NULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment