Skip to content

Commit

Permalink
Merge pull request #21 from geode-lang/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
nickwanninger authored Oct 11, 2018
2 parents dea9d4a + 1fe000e commit 34bd2de
Show file tree
Hide file tree
Showing 65 changed files with 1,486 additions and 654 deletions.
22 changes: 1 addition & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,16 @@ gen:
default:

lib.clean:
# @rm -rf gc
@rm -rf lib/gc/*
@rm -rf lib/include/gc

# $(GCPATH):
# mkdir -p dl
# wget -O dl/libatomic_ops.tar.gz https://github.com/ivmai/libatomic_ops/releases/download/v7.6.6/libatomic_ops-7.6.6.tar.gz
# wget -O dl/gc.tar.gz https://github.com/ivmai/bdwgc/releases/download/v7.6.8/gc-7.6.8.tar.gz
# rm -rf gc
# tar -C ./ -xvf dl/gc.tar.gz
# mv gc-* gc
# tar -C ./ -xvf dl/libatomic_ops.tar.gz
# mv libatomic_ops* gc/libatomic_ops
# rm -rf dl
# cd gc && make -f Makefile.direct
# mkdir -p lib/gc/
# cp gc/gc.a lib/gc/gc.a
# cd lib/gc && ar x gc.a
# mkdir -p lib/include/gc
# cp -a gc/include/* lib/include/gc
# rm -rf gc


install.lib:# $(GCPATH)
@rm -rf $(LIBDIR)
@mkdir -p $(LIBDIR)
@cp -a lib/* $(LIBDIR)



docker.build:
docker build -t nickwanninger/geode-test:latest .

Expand All @@ -77,4 +57,4 @@ docker.push: docker.build

default: build
install: install.lib install.bin
all: build install
all: build install
4 changes: 2 additions & 2 deletions example/ideas/ideas.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ protocol Addable {

class Foo(a) {
int a;
func add(Addable other) int -> this.value() + other.value();
func value int -> this.a;
func add(Addable other) int = this.value() + other.value();
func value int = this.a;
}

func add(Addable a, Addable b) int {
Expand Down
23 changes: 20 additions & 3 deletions example/main.g
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
is main

include "io"
# github.com/geode-lang/geode

func main {
io:print("hello, world\n")
func main int {
log("hello, world")
return 0
}

# func parseint(string str, int base) long {
# set = "0123456789abcdef"
# setlen = str:len(set)
# long res = 0
# digit = 0
# for i = 0; str[i] != 0; i += 1 {
# for c = 0; c <= setlen; c += 1 {
# if set[c] == str[i] {
# digit = c
# }
# }
# res = res * base + digit
# }
# return res
# }
21 changes: 11 additions & 10 deletions example/mandelbrot/mandelbrot.g
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ is mandel
include "io"
include "str"
include "math"
include "c"


func printdensity(int d, int iter) {
r = d % 255
if d > iter {
r = 0
}
a = io:format("\x1b[48;2;%d;%d;%dm ", r, 0, 0)
io:fputs(a, io:stdout)
io:fputs("\x1b[0m", io:stdout)
a = "\x1b[48;2;%d;%d;%dm "(r, r, r)
c:fputs(a, io:stdout)
c:fputs("\x1b[0m", io:stdout)
}


Expand All @@ -21,7 +22,8 @@ func mandelconverger(float real, float imag, float iters, float creal, float cim
return iters
} else {
return mandelconverger(real * real - imag * imag + creal, 2.0 * real * imag + cimag, iters + 1.0, creal, cimag, iter)
}
}
return 0.0
}


Expand All @@ -32,7 +34,6 @@ func mandelconverge(float real, float imag, int iter) float {
}

func printMandel(float realstart, float imagstart, float zoom, int iter, float width, float height) {
io:print("%.40f\n", zoom)
# x-values
xmin = realstart - zoom * (width / 2.0)
xmax = realstart + zoom * (width / 2.0)
Expand All @@ -53,9 +54,9 @@ func mandelhelp(float xmin, float xmax, float xstep, float ymin, float ymax, flo
cov = mandelconverge(x,y, iter)
printdensity(cov, iter)
}
io:fputs("\n", io:stdout)
c:fputs("\n", io:stdout)
}
io:fflush(io:stdout)
c:fflush(io:stdout)

}

Expand All @@ -82,9 +83,9 @@ func main int {
clear()
printMandel(x, y, z, iter, width, height)

io:system("stty raw")
input = io:getchar()
io:system("stty cooked")
c:system("stty raw")
input = c:getchar()
c:system("stty cooked")

io:print("\n")

Expand Down
79 changes: 79 additions & 0 deletions lib/c/cbindings.g
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
is c


class FILE {}

func tmpfile FILE* ...
func fopen(string path, string mode) FILE* ...
func fseek(FILE* handle, int offset, int whence) int ...
func ftell(FILE* handle) long ...
func rewind(FILE* handle) ...
func fread(string where, int size, int nmemb, FILE* handle) long ...
func fwrite(string what, int size, int nmemb, FILE* handle) ...
func fclose(FILE* handle) ...
func getenv(string what) string ...
func fgetc(FILE* handle) string ...
func fflush(FILE* handle) int ...
func fprintf(FILE* handle, byte* format, ...) int ...
func ferror(FILE* handle) int ...
func feof(FILE* handle) int ...
func fputs(string str, FILE* handle) ...


func fprintf(FILE* stream, byte* format, ...) int ...
func printf(byte* format, ...) int ...


func fgetc(FILE* stream) int ...
func fgets(FILE* stream) byte* ...
func fputc(FILE* stream, int c) int ...
func fputs(byte* str, FILE* stream) int ...
func getc(FILE* stream) int ...
func getchar() int ...
func gets(byte* str) byte* ...
func putc(int c, FILE* stream) int ...
func putchar(int c) int ...
func puts(byte* str) int ...
func ungetc(int c, FILE* stream) int ...

# this file contains bindings to most c stdlib, stdio, unistd, etc.. functions

func atof(byte* str) float ...
func atoi(byte* str) int ...
func atol(byte* str) long ...
func strtod(byte* str, byte** endptr) float ...
func malloc(long size) byte* ...
func calloc(long nitems size) byte* ...
func realloc(byte* ptr, long size) byte* ...
func free(byte* ptr) ...
func abort ...
func system(byte* cmd) int ...
func getenv(byte* name) byte* ...
func abs(int x) int ...
func srand(int seed) int ...
func mblen(byte* str, long n) int ...
func memchr(byte* str, int c, long n) byte* ...
func memcmp(byte* str1, byte* str2, long n) int ...
func memcpy(byte* dest src, long n) byte* ...
func memmove(byte* dest src, long n) byte* ...
func memset(byte* str, int c, long n) byte* ...
func strcat(byte* dest src) byte* ...
func strncat(byte* dest src, long n) byte* ...
func strchr(byte* str, int c) byte* ...
func strcmp(byte* str1 str2) int ...
func strncmp(byte* str1 str2, long n) int ...
func strcoll(byte* str1 str2) int ...
func strcmp(byte* dest src) byte* ...
func strncpy(byte* dest src, long n) byte* ...
func strcspn(byte* str1 str2) long ...
func strerr(int errnum) byte* ...
func strlen(byte* str) long ...
func strpbrk(byte* str1 str2) byte* ...
func strrchr(byte* str, int c) byte* ...
func strspn(byte* str1 str2) long ...
func strstr(byte* haystack needle) byte* ...
func strtok(byte* str delim) byte* ...
func strxfrm(byte* dest src, long n) long ...


func tmpnam(byte* str) byte* ...
67 changes: 0 additions & 67 deletions lib/encoding/b64.h

This file was deleted.

91 changes: 0 additions & 91 deletions lib/encoding/b64_encode.c

This file was deleted.

Loading

0 comments on commit 34bd2de

Please sign in to comment.