Created
July 24, 2013 14:42
-
-
Save antonijn/6071230 to your computer and use it in GitHub Desktop.
Boh Source Code And Compiled Result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ORIGINAL BOH FILE 1 | |
/* | |
import boh.lang; | |
private class Program { | |
public static void main() { | |
Program p = new Extends(); | |
int i = p.getNumber(); | |
} | |
public virtual int getNumber() { | |
return 10; | |
} | |
} | |
*/ | |
// ORIGINAL BOH FILE 2 | |
/* | |
import boh.lang; | |
private class Extends extends Program { | |
public override int getNumber() { | |
Program program = new Program(); | |
int i = program.getNumber(); | |
return 2 * i; | |
} | |
} | |
*/ | |
// | |
// | |
// EXTENDS.C | |
// | |
#include <gc.h> | |
#include "_program.h" | |
#include "_extends.h" | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
const struct _vtable__Extends _EXTENDS_VTABLE = { &__Extends_getNumber_0 }; | |
// method implementations | |
int32_t __Extends_getNumber_0(struct _Extends * __this__) { | |
struct _Program * program = new__Program_0(); | |
struct _Program * __this1__ = program; | |
int32_t i = (*(const struct _vtable__Program **) __this1__)->_vtable__Program_getNumber_0(__this1__); | |
return 2 * i; | |
} | |
// constructor implementations | |
struct _Extends * new__Extends_0(void) { | |
struct _Extends * result = (struct _Extends *) GC_MALLOC(sizeof(struct _Extends)); | |
*(const struct _vtable__Extends **) result = &_EXTENDS_VTABLE; | |
__Extends_this_0(result); | |
return result; | |
} | |
void __Extends_this_0(struct _Extends * __this__) { | |
} | |
#ifdef __cplusplus | |
} | |
#endif | |
// | |
// | |
// EXTENDS.H | |
// | |
#pragma once | |
#ifndef _EXTENDS | |
#define _EXTENDS | |
#include <stdint.h> | |
#include <wchar.h> | |
#include <stdbool.h> | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
struct _Program; | |
struct _Extends; | |
// non-private constructor declarations | |
extern struct _Extends * new__Extends_0(void); | |
extern void __Extends_this_0(struct _Extends *); | |
// non-private method declarations | |
extern int32_t __Extends_getNumber_0(struct _Extends *); | |
// virtual function table | |
struct _vtable__Extends { | |
int32_t (*_vtable__Program_getNumber_0)(struct _Program *); | |
}; | |
extern const struct _vtable__Extends _EXTENDS_VTABLE; | |
// class | |
struct _Extends { | |
struct _Program __super__; | |
}; | |
#ifdef __cplusplus | |
} | |
#endif | |
#endif | |
// | |
// | |
// PROGRAM.C | |
// | |
#include <gc.h> | |
#include "_program.h" | |
#include "_extends.h" | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
const struct _vtable__Program _PROGRAM_VTABLE = { &__Program_getNumber_0 }; | |
// method implementations | |
void __Program_main_0(void) { | |
struct _Program * p = new__Extends_0(); | |
struct _Program * __this0__ = p; | |
int32_t i = (*(const struct _vtable__Program **) __this0__)->_vtable__Program_getNumber_0(__this0__); | |
} | |
int32_t __Program_getNumber_0(struct _Program * __this__) { | |
return 10; | |
} | |
// constructor implementations | |
struct _Program * new__Program_0(void) { | |
struct _Program * result = (struct _Program *) GC_MALLOC(sizeof(struct _Program)); | |
*(const struct _vtable__Program **) result = &_PROGRAM_VTABLE; | |
__Program_this_0(result); | |
return result; | |
} | |
void __Program_this_0(struct _Program * __this__) { | |
} | |
#ifdef __cplusplus | |
} | |
#endif | |
// | |
// | |
// PROGRAM.H | |
// | |
#pragma once | |
#ifndef _PROGRAM | |
#define _PROGRAM | |
#include <stdint.h> | |
#include <wchar.h> | |
#include <stdbool.h> | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
struct _Program; | |
struct _Extends; | |
// non-private constructor declarations | |
extern struct _Program * new__Program_0(void); | |
extern void __Program_this_0(struct _Program *); | |
// non-private method declarations | |
extern void __Program_main_0(void); | |
extern int32_t __Program_getNumber_0(struct _Program *); | |
// virtual function table | |
struct _vtable__Program { | |
int32_t (*_vtable__Program_getNumber_0)(struct _Program *); | |
}; | |
extern const struct _vtable__Program _PROGRAM_VTABLE; | |
// class | |
struct _Program { | |
const struct _vtable__Program * vtable_; | |
}; | |
#ifdef __cplusplus | |
} | |
#endif | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment