Skip to content

Commit

Permalink
version 10.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ab25cq committed May 13, 2019
1 parent b69fcfa commit d544146
Show file tree
Hide file tree
Showing 24 changed files with 340 additions and 183 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

version 10.4.5

Faster compile speed.

version 10.4.4

Finished to implement C-FFI on JIT.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# clover2 computer language

version 10.4.4
version 10.4.5

サポートしている機能

Expand Down
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ C FFI C関数でi8*だけじゃなくてi32*の引数も渡せるか。
array終わったかな。

struct

クラスファイルでアライメント
4 changes: 4 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

clover2 (10.4.5-1) unstable; urgency=medium

* Faster compile speed.

clover2 (10.4.4-1) unstable; urgency=medium

* Finished to implement C-FFI on JIT.
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Section: unknown
Priority: optional
Maintainer: Daisuke Minato <[email protected]>
Build-Depends: debhelper (>= 9), autotools-dev, libpcre3-dev, libreadline-dev, clang, libreadline7
Standards-Version: 10.4.4
Standards-Version: 10.4.5
Homepage: https://github.com/ab25cq/clover2/wiki
Vcs-Git: https://github.com/ab25cq/clover2.git

Expand Down
6 changes: 3 additions & 3 deletions debian/files
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
clover2-dbgsym_10.4.4-1_amd64.deb debug extra
clover2_10.4.4-1_amd64.buildinfo unknown optional
clover2_10.4.4-1_amd64.deb unknown optional
clover2-dbgsym_10.4.5-1_amd64.deb debug extra
clover2_10.4.5-1_amd64.buildinfo unknown optional
clover2_10.4.5-1_amd64.deb unknown optional
4 changes: 4 additions & 0 deletions manual/changelog-en.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

version 10.4.5

Faster compile speed.

version 10.4.4

Finished to implement C-FFI on JIT.
Expand Down
4 changes: 4 additions & 0 deletions manual/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
English page is here [>> English page](changelog-en)

version 10.4.5

Faster compile speed.

version 10.4.4

Finished to implement C-FFI on JIT.
Expand Down
9 changes: 9 additions & 0 deletions src/alignment.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ void alignment(unsigned int* size)
{
*size = (*size + 3) & ~3;
}

void alignment_pointer(char** p, char* head)
{
unsigned int len = *p - head;

alignment(&len);

*p = head + len;
}
13 changes: 13 additions & 0 deletions src/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ void sBuf_append(sBuf* self, void* str, size_t size)
MFREE(str2);
}

void sBuf_append_fast(sBuf* self, void* str, size_t size)
{
if(self->mSize <= self->mLen + size + 1) {
self->mSize = (self->mLen + size + 1) * 2;
self->mBuf = MREALLOC(self->mBuf, sizeof(char)*self->mSize);
}

memcpy(self->mBuf + self->mLen, str, size);

self->mLen += size;
self->mBuf[self->mLen] = 0;
}

/*
void sBuf_append(sBuf* self, void* str, size_t size)
{
Expand Down
1 change: 1 addition & 0 deletions src/clover2-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ typedef struct sBufStruct sBuf;

void sBuf_init(sBuf* self);
void sBuf_append(sBuf* self, void* str, size_t size);
void sBuf_append_fast(sBuf* self, void* str, size_t size);
void sBuf_append_char(sBuf* self, char c);
void sBuf_append_str(sBuf* self, char* str);
void sBuf_append_int(sBuf* self, int value);
Expand Down
13 changes: 8 additions & 5 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,10 @@ typedef struct sCLClassStruct sCLClass;
void class_init();
void class_final();

BOOL read_block_from_file(int fd, sCLBlockObject* block_object);
BOOL read_from_file(int fd, void* buf, size_t size);
BOOL read_file(char* fname, sBuf* source);
BOOL read_block_from_file(char** p, sCLBlockObject* block_object, char* head);
BOOL read_from_file(char** p, void* buf, size_t size, char* head);
BOOL read_char_from_file(char** p, char* c);
void reset_js_load_class();
sCLClass* get_class_with_load(char* class_name, BOOL js);
sCLClass* get_class(char* class_name, BOOL js);
Expand Down Expand Up @@ -2031,9 +2033,9 @@ void dependency_final();
void append_block_to_buffer(sBuf* buf, sCLBlockObject* block_object);
void append_byte_codes_to_buffer(sBuf* buf, sByteCode* code);
void append_const_to_buffer(sBuf* buf, sConst* constant);
BOOL read_code_from_file(int fd, sByteCode* code);
BOOL read_int_from_file(int fd, int* n);
BOOL read_const_from_file(int fd, sConst* constant);
BOOL read_code_from_file(char** p, sByteCode* code, char* head);
BOOL read_int_from_file(char** p, int* n);
BOOL read_const_from_file(char** p, sConst* constant, char* head);
void add_native_code_to_method(sCLMethod* method, sBuf* native_code);
BOOL add_method_to_class(sCLClass* klass, char* method_name, sParserParam* params, int num_params, sNodeType* result_type, BOOL native_, BOOL static_, BOOL dynamic_, BOOL pure_native_, sGenericsParamInfo* ginfo, sCLMethod** appended_method, char* clibrary_path, sParserInfo* info);
int add_block_object_to_class(sCLClass* klass, sByteCode codes, sConst constant, int var_num, int num_params, BOOL lambda);
Expand Down Expand Up @@ -2623,6 +2625,7 @@ extern CLObject signal_handler_object[SIGMAX];

/// alignment.c ///
void alignment(unsigned int* size);
void alignment_pointer(char** p, char* head);

/// clover_to_clang ///
ALLOC wchar_t* string_object_to_wchar_array(CLObject string_object);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static BOOL class_compiler(char* fname)

int gARGC;
char** gARGV;
char* gVersion = "10.4.4";
char* gVersion = "10.4.5";

char gScriptDirPath[PATH_MAX];
BOOL gRunningCompiler = TRUE;
Expand Down
2 changes: 1 addition & 1 deletion src/get_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static BOOL is_shell_mode(char* source, char* fname, sVarTable* lv_table)

int gARGC;
char** gARGV;
char* gVersion = "10.4.4";
char* gVersion = "10.4.5";

char gScriptDirPath[PATH_MAX];
BOOL gRunningCompiler = FALSE;
Expand Down
2 changes: 1 addition & 1 deletion src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2294,7 +2294,7 @@ static void compiler_final()

int gARGC;
char** gARGV;
char* gVersion = "10.4.4";
char* gVersion = "10.4.5";

char gScriptDirPath[PATH_MAX];
BOOL gRunningCompiler = FALSE;
Expand Down
72 changes: 45 additions & 27 deletions src/jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4944,51 +4944,72 @@ static BOOL compile_jit_methods(sCLClass* klass)

static BOOL read_script(char* fname, sByteCode* code, sConst* constant, int* var_num, int* param_num)
{
int fd = open(fname, O_RDONLY);
sBuf buf;

if(fd < 0) {
fprintf(stderr, "%s doesn't exist(1)\n", fname);
sBuf_init(&buf);

if(!read_file(fname, &buf)) {
MFREE(buf.mBuf);
return FALSE;
}

/// magic number ///
char* p = buf.mBuf;

char c;
if(!read_from_file(fd, &c, 1) || c != 10) { close(fd); return FALSE; }
if(!read_from_file(fd, &c, 1) || c != 12) { close(fd); return FALSE; }
if(!read_from_file(fd, &c, 1) || c != 34) { close(fd); return FALSE; }
if(!read_from_file(fd, &c, 1) || c != 55) { close(fd); return FALSE; }
if(!read_from_file(fd, &c, 1) || c != 'C') { close(fd); return FALSE; }
if(!read_from_file(fd, &c, 1) || c != 'L') { close(fd); return FALSE; }
if(!read_from_file(fd, &c, 1) || c != 'O') { close(fd); return FALSE; }
if(!read_from_file(fd, &c, 1) || c != 'V') { close(fd); return FALSE; }
if(!read_from_file(fd, &c, 1) || c != 'E') { close(fd); return FALSE; }
if(!read_from_file(fd, &c, 1) || c != 'R') { close(fd); return FALSE; }

if(!read_int_from_file(fd, var_num)) {
close(fd);

read_char_from_file(&p, &c);
if(c != 10) { return FALSE; }

read_char_from_file(&p, &c);
if(c != 12) { return FALSE; }

read_char_from_file(&p, &c);
if(c != 34) { return FALSE; }

read_char_from_file(&p, &c);
if(c != 55) { return FALSE; }

read_char_from_file(&p, &c);
if(c != 'C') { return FALSE; }

read_char_from_file(&p, &c);
if(c != 'L') { return FALSE; }

read_char_from_file(&p, &c);
if(c != 'O') { return FALSE; }

read_char_from_file(&p, &c);
if(c != 'V') { return FALSE; }

read_char_from_file(&p, &c);
if(c != 'E') { return FALSE; }

read_char_from_file(&p, &c);
if(c != 'R') { return FALSE; }

alignment_pointer(&p, buf.mBuf);

if(!read_int_from_file(&p, var_num)) {
fprintf(stderr, "Clover2 can't read variable number\n");
return FALSE;
}

*param_num = *var_num;

if(!read_code_from_file(fd, code))
if(!read_code_from_file(&p, code, buf.mBuf))
{
close(fd);
fprintf(stderr, "Clover2 can't read variable number\n");
return FALSE;
}

if(!read_const_from_file(fd, constant))
if(!read_const_from_file(&p, constant, buf.mBuf))
{
close(fd);
fprintf(stderr, "Clover2 can't read variable number\n");
return FALSE;
}

int n;
if(!read_int_from_file(fd, &n)) {
close(fd);
if(!read_int_from_file(&p, &n)) {
fprintf(stderr, "Clover2 can't read variable number\n");
return FALSE;
}
Expand All @@ -4997,17 +5018,14 @@ static BOOL read_script(char* fname, sByteCode* code, sConst* constant, int* var
for(i=0; i<n; i++) {
sCLBlockObject block_object;

if(!read_block_from_file(fd, &block_object)) {
close(fd);
if(!read_block_from_file(&p, &block_object, buf.mBuf)) {
fprintf(stderr, "Clover2 can't read variable number\n");
return FALSE;
}

add_block_object_to_script2(&block_object);
}

close(fd);

return TRUE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/jit_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void set_signal()

int gARGC;
char** gARGV;
char* gVersion = "10.4.4";
char* gVersion = "10.4.5";
BOOL gCompilingCore = FALSE;

char gScriptDirPath[PATH_MAX];
Expand Down
Loading

0 comments on commit d544146

Please sign in to comment.