Permalink
Browse files

Megacommit

  • Loading branch information...
1 parent cb832d2 commit 9c3bf9d598c166768b52d9072988d71d02d1f5ce @jaytaph jaytaph committed Feb 8, 2014
Showing with 1,478 additions and 754 deletions.
  1. +9 −9 configure.ac
  2. +10 −6 hello.sf
  3. +16 −1 sfl/saffire.sf
  4. +4 −4 src/Makefile.am
  5. +8 −8 src/components/compiler/ast_nodes.c
  6. +1 −1 src/components/compiler/ast_to_asm.c
  7. +1 −1 src/components/compiler/bytecode/io.c
  8. +12 −11 src/components/compiler/bytecode/marshal.c
  9. +7 −7 src/components/compiler/output/asm.c
  10. +4 −4 src/components/compiler/saffire.l
  11. +12 −8 src/components/debugger/dbgp/commands.c
  12. +1 −1 src/components/debugger/dbgp/dbgp.c
  13. +5 −5 src/components/fastcgi/fastcgi_srv.c
  14. +1 −1 src/components/gc/gc.c
  15. +1 −1 src/components/general/config.c
  16. +1 −1 src/components/general/gpg.c
  17. +33 −23 src/components/general/hash/chained.c
  18. +19 −18 src/components/general/hashtable.c
  19. +11 −11 src/components/general/ini.c
  20. +83 −41 src/components/general/output.c
  21. +6 −6 src/components/general/parse_options.c
  22. +68 −84 src/components/general/printf/arg_printf.c
  23. +1 −8 src/components/general/smm.c
  24. +35 −3 src/components/general/smm/asprintf.c
  25. +140 −0 src/components/general/string.c
  26. +206 −0 src/components/general/unicode.c
  27. +10 −9 src/components/modules/io.c
  28. +2 −2 src/components/modules/module_api.c
  29. +32 −4 src/components/modules/saffire.c
  30. +1 −1 src/components/modules/sapi/fastcgi.c
  31. +9 −6 src/components/objects/attrib.c
  32. +5 −6 src/components/objects/base.c
  33. +5 −4 src/components/objects/boolean.c
  34. +1 −0 src/components/objects/callable.c
  35. +9 −7 src/components/objects/exception.c
  36. +11 −10 src/components/objects/hash.c
  37. +2 −1 src/components/objects/list.c
  38. +3 −1 src/components/objects/null.c
  39. +9 −1 src/components/objects/numerical.c
  40. +40 −41 src/components/objects/object.c
  41. +12 −3 src/components/objects/regex.c
  42. +214 −194 src/components/objects/string.c
  43. +3 −2 src/components/objects/tuple.c
  44. +3 −2 src/components/objects/userland.c
  45. +1 −1 src/components/repl/repl.c
  46. +6 −6 src/components/vm/block.c
  47. +7 −7 src/components/vm/context.c
  48. +40 −37 src/components/vm/frame.c
  49. +11 −13 src/components/vm/import.c
  50. +23 −2 src/components/vm/thread.c
  51. +76 −60 src/components/vm/vm.c
  52. +3 −2 src/include/compiler/bytecode.h
  53. +4 −2 src/include/debug.h
  54. +2 −2 src/include/general/hashtable.h
  55. +21 −9 src/include/general/output.h
  56. +2 −1 src/include/general/printf.h
  57. +6 −3 src/include/general/smm.h
  58. +62 −0 src/include/general/string.h
  59. +72 −0 src/include/general/unicode.h
  60. +2 −2 src/include/objects/exception.h
  61. +2 −3 src/include/objects/object.h
  62. +21 −7 src/include/objects/string.h
  63. +7 −2 src/include/vm/thread.h
  64. +2 −1 src/main/commands/bytecode.c
  65. +8 −8 src/main/commands/config.c
  66. +1 −1 src/main/commands/exec.c
  67. +3 −3 src/main/commands/help.c
  68. +10 −10 src/main/commands/lint.c
  69. +2 −2 src/main/commands/version.c
  70. +12 −12 src/main/saffire.c
  71. +1 −1 support/generators/generate_exceptions.php
  72. +5 −0 support/readdump/bytecode/Constant/String.php
View
@@ -79,15 +79,15 @@ AM_CONDITIONAL(ENABLE_COVERAGE, test "x$enable_coverage" = "xyes")
-dnl # check for icu-config
-dnl AC_PATH_PROG(icu_config, icu-config, no)
-dnl if test "$icu_config" = "no"; then
-dnl AC_MSG_ERROR([Cannot find icu-config. ICU library is needed.])
-dnl fi
-dnl ICU_CPPFLAGS=`$icu_config --cppflags`
-dnl ICU_LIBS=`$icu_config --ldflags`
-dnl AC_SUBST([ICU_CPPFLAGS])
-dnl AC_SUBST([ICU_LIBS])
+# check for icu-config
+AC_PATH_PROG(icu_config, icu-config, no)
+if test "$icu_config" = "no"; then
+ AC_MSG_ERROR([Cannot find icu-config. ICU library is needed.])
+fi
+ICU_CFLAGS=`$icu_config --cflags`
+ICU_LIBS=`$icu_config --ldflags`
+AC_SUBST([ICU_CFLAGS])
+AC_SUBST([ICU_LIBS])
# Checks for libraries.
View
@@ -4,28 +4,32 @@ import io;
// Call the print method from our (imported) io class with a single argument
io.print("Hello world!\n");
+
+/*
+
class bar {
public method foo(b) {
- return 1;
+ return 1;
}
}
class foo {
public property a = 2;
public method bar(numerical b) {
- self.foo(b);
+ self.foo(b);
return self.a * b;
}
public method foo(b) {
- tmp = bar();
- tmp.foo(b);
-
+ tmp = bar();
+ tmp.foo(b);
}
}
io.print("Oh hai again!\n");
f = foo();
b = f.bar(5);
-io.print("The number is ",b," and ", f.bar(7),".\n");
+io.print("The number is ",b," and ", f.bar(7),".\n");
+
+*/
View
@@ -13,7 +13,7 @@ class saffire {
}
/**
- * Returnst the git SHA commit that is used for compiling this version
+ * Returns the git SHA commit that is used for compiling this version
*/
static public method git_revision() {
return ::_sfl::saffire::saffire.git_revision();
@@ -28,6 +28,21 @@ class saffire {
}
/**
+ *
+ */
+ static public method getLocale() {
+ return ::_sfl::saffire::saffire.get_locale();
+ }
+
+ /**
+ *
+ */
+ static public method setLocale(string locale) {
+ return ::_sfl::saffire::saffire.set_locale(locale);
+ }
+
+
+ /**
* Returns the current server API, could be "fastcgi", "cli", "repl" or "unknown"
*/
static public method sapi() {
View
@@ -117,7 +117,9 @@ libgeneral_a_SOURCES = components/general/hashtable.c \
components/general/mutex.c \
components/general/printf/arg_printf.c \
components/general/ini.c \
- components/general/base64.c
+ components/general/base64.c \
+ components/general/string.c \
+ components/general/unicode.c
########################################################################
@@ -234,8 +236,6 @@ libgc_a_SOURCES = components/gc/gc.c
SAFFIRE_LIBS = \
libobjects.a \
libgeneral.a \
- libobjects.a \
- libgeneral.a \
libcompiler.a \
libfastcgi.a \
librepl.a \
@@ -247,7 +247,7 @@ SAFFIRE_LIBS = \
bin_PROGRAMS = saffire
-saffire_LDADD = $(SAFFIRE_LIBS) $(SAFFIRE_LIBS) $(edit_LIBS) ${libxml2_LIBS} -lpthread
+saffire_LDADD = $(SAFFIRE_LIBS) $(SAFFIRE_LIBS) $(edit_LIBS) ${libxml2_LIBS} ${ICU_LIBS} -lpthread
saffire_SOURCES = main/saffire.c \
main/commands/config.c main/commands/fastcgi.c main/commands/lint.c \
@@ -119,7 +119,7 @@ t_ast_element *ast_node_string(int lineno, char *value) {
p->lineno = lineno;
p->type = typeAstString;
- p->string.value = smm_strdup(value);
+ p->string.value = string_strdup0(value);
return p;
}
@@ -129,7 +129,7 @@ t_ast_element *ast_node_regex(int lineno, char *value) {
p->lineno = lineno;
p->type = typeAstRegex;
- p->regex.value = smm_strdup(value);
+ p->regex.value = string_strdup0(value);
return p;
}
@@ -140,7 +140,7 @@ t_ast_element *ast_node_id_to_string(t_ast_element *src) {
p->lineno = src->lineno;
p->type = typeAstString;
- p->string.value = smm_strdup(src->identifier.name);
+ p->string.value = string_strdup0(src->identifier.name);
return p;
}
@@ -153,7 +153,7 @@ t_ast_element *ast_node_string_dup(int lineno, t_ast_element *src) {
p->lineno = lineno;
p->type = typeAstString;
- p->string.value = smm_strdup(src->string.value);
+ p->string.value = string_strdup0(src->string.value);
return p;
}
@@ -189,7 +189,7 @@ t_ast_element *ast_node_identifier(int lineno, char *var_name) {
p->lineno = lineno;
p->type = typeAstIdentifier;
- p->identifier.name = smm_strdup(var_name);
+ p->identifier.name = string_strdup0(var_name);
return p;
}
@@ -420,7 +420,7 @@ t_ast_element *ast_node_class(int lineno, t_class *class, t_ast_element *body) {
p->lineno = lineno;
p->type = typeAstClass;
p->class.modifiers = class->modifiers;
- p->class.name = smm_strdup(class->name);
+ p->class.name = string_strdup0(class->name);
p->class.extends = class->extends;
p->class.implements = class->implements;
@@ -439,7 +439,7 @@ t_ast_element *ast_node_interface(int lineno, int modifiers, char *name, t_ast_e
p->lineno = lineno;
p->type = typeAstInterface;
p->interface.modifiers = modifiers;
- p->interface.name = smm_strdup(name);
+ p->interface.name = string_strdup0(name);
p->interface.implements = implements;
p->interface.body = body;
@@ -454,7 +454,7 @@ t_ast_element *ast_node_attribute(int lineno, char *name, char attrib_type, char
p->lineno = lineno;
p->type = typeAstAttribute;
- p->attribute.name = smm_strdup(name);
+ p->attribute.name = string_strdup0(name);
p->attribute.attrib_type = attrib_type;
p->attribute.visibility = visibility;
p->attribute.access = access;
@@ -135,7 +135,7 @@ static void __ast_walker(t_ast_element *leaf, t_hash_table *output, t_dll *frame
// We know the scope now. We still need to use "self"
smm_free(node->identifier.name);
- node->identifier.name = smm_strdup("self");
+ node->identifier.name = string_strdup0("self");
}
stack_push(state->context, (void *)st_ctx_load);
@@ -74,7 +74,7 @@ t_bytecode *bytecode_load(const char *filename, int verify_signature) {
if (verify_signature == 0 &&
(header.flags & BYTECODE_FLAG_SIGNED) == BYTECODE_FLAG_SIGNED &&
header.signature_offset != 0) {
- output("A signature is present, but verification is disabled");
+ output_char("A signature is present, but verification is disabled");
}
// We need to check signature, and there is one present
@@ -74,25 +74,26 @@ static void _add_constant(t_bytecode *bc, t_bytecode_constant *c) {
/**
* Add a new string constant to the bytecode structure
*/
-static void _new_constant_string(t_bytecode *bc, char *s) {
+static void _new_constant_string(t_bytecode *bc, t_string *s) {
// Setup constant
t_bytecode_constant *c = (t_bytecode_constant *)smm_malloc(sizeof(t_bytecode_constant));
c->type = BYTECODE_CONST_STRING;
- c->len = strlen(s);
- c->data.s = smm_strdup(s);
+ c->len = s->len;
+ c->data.s = s->val;
+
_add_constant(bc, c);
}
/**
* Add a new regex constant to the bytecode structure
*/
-static void _new_constant_regex(t_bytecode *bc, char *s) {
+static void _new_constant_regex(t_bytecode *bc, t_string *r) {
// Setup constant
t_bytecode_constant *c = (t_bytecode_constant *)smm_malloc(sizeof(t_bytecode_constant));
c->type = BYTECODE_CONST_REGEX;
- c->len = strlen(s);
- c->data.s = smm_strdup(s);
+ c->len = r->len;
+ c->data.r = r->val;
_add_constant(bc, c);
}
@@ -133,7 +134,7 @@ static void _new_name(t_bytecode *bc, char *var) {
// Setup identifier
t_bytecode_identifier *c = smm_malloc(sizeof(t_bytecode_identifier));
c->len = strlen(var);
- c->s = smm_strdup(var);
+ c->s = string_strdup0(var);
// Add identifier
bc->identifiers = smm_realloc(bc->identifiers, sizeof(t_bytecode_identifier *) * (bc->identifiers_len + 1));
@@ -213,15 +214,15 @@ t_bytecode *bytecode_unmarshal(char *bincode) {
s = smm_malloc(len+1);
_read_buffer(bincode, &pos, len, s);
s[len] = '\0';
- _new_constant_string(bytecode, s);
+ _new_constant_string(bytecode, char_to_string(s, len));
smm_free(s);
break;
case BYTECODE_CONST_REGEX :
// Constant rexeg do not have a trailing \0 on disk.
s = smm_malloc(len+1);
_read_buffer(bincode, &pos, len, s);
s[len] = '\0';
- _new_constant_regex(bytecode, s);
+ _new_constant_regex(bytecode, char_to_string(s, len));
smm_free(s);
break;
case BYTECODE_CONST_NUMERICAL :
@@ -373,10 +374,10 @@ t_bytecode *convert_frames_to_bytecode(t_hash_table *frames, char *name, int sta
_new_constant_code(bc, convert_frames_to_bytecode(frames, c->data.s, 1));
break;
case const_string :
- _new_constant_string(bc, c->data.s);
+ _new_constant_string(bc, char0_to_string(c->data.s));
break;
case const_regex :
- _new_constant_regex(bc, c->data.s);
+ _new_constant_regex(bc, char0_to_string(c->data.s));
break;
case const_long :
_new_constant_long(bc, c->data.l);
@@ -129,7 +129,7 @@ static int _convert_constant_string(t_asm_frame *frame, char *s) {
// Add to DLL
t_asm_constant *c = smm_malloc(sizeof(t_asm_constant));
c->type = const_string;
- c->data.s = smm_strdup(s);
+ c->data.s = string_strdup0(s);
dll_append(frame->constants, c);
return frame->constants->size - 1;
@@ -148,7 +148,7 @@ static int _convert_constant_regex(t_asm_frame *frame, char *r) {
// Add to DLL
t_asm_constant *c = smm_malloc(sizeof(t_asm_constant));
c->type = const_regex;
- c->data.s = smm_strdup(r);
+ c->data.s = string_strdup0(r);
dll_append(frame->constants, c);
return frame->constants->size - 1;
@@ -167,7 +167,7 @@ static int _convert_constant_code(t_asm_frame *frame, char *s) {
// Add to DLL
t_asm_constant *c = smm_malloc(sizeof(t_asm_constant));
c->type = const_code;
- c->data.s = smm_strdup(s);
+ c->data.s = string_strdup0(s);
dll_append(frame->constants, c);
return frame->constants->size - 1;
@@ -337,7 +337,7 @@ static t_asm_frame *assemble_frame(t_dll *source_frame, int mainframe) {
bp = smm_malloc(sizeof(struct _backpatch));
bp->opcode_offset = opcode_off;
bp->operand_offset = frame->code_len;
- bp->label = smm_strdup(line->opr[i]->data.s);
+ bp->label = string_strdup0(line->opr[i]->data.s);
dll_append(frame->backpatch_offsets, bp);
opr = 0xFFFF; // Add dummy bytes keep the offsets happy
@@ -459,7 +459,7 @@ void assembler_free(t_hash_table *asm_code) {
t_asm_opr *asm_create_opr(int type, char *s, int l) {
t_asm_opr *opr = smm_malloc(sizeof(t_asm_opr));
opr->type = type;
- opr->data.s = s ? smm_strdup(s) : NULL;
+ opr->data.s = s ? string_strdup0(s) : NULL;
opr->data.l = l;
return opr;
}
@@ -492,7 +492,7 @@ t_asm_line *asm_create_codeline(int lineno, int opcode, int opr_cnt, ...) {
t_asm_line *asm_create_labelline(char *label) {
t_asm_line *line = smm_malloc(sizeof(t_asm_line));
line->type = ASM_LINE_TYPE_LABEL;
- line->s = smm_strdup(label);
+ line->s = string_strdup0(label);
return line;
}
@@ -520,7 +520,7 @@ t_bytecode *assembler(t_hash_table *asm_code, const char *filename) {
}
t_bytecode *bc = convert_frames_to_bytecode(assembled_frames, "main", 1);
- bc->source_filename = filename ? smm_strdup(filename) : NULL;
+ bc->source_filename = filename ? string_strdup0(filename) : NULL;
// Cleanup our frames
@@ -161,7 +161,7 @@ ml_comment "/*"([^\*]|\*[^/])*"*/"
/* Only match regex when we are in the regex state */
<st_regex>\/[^\/\\]*(?:\\.[^\/\\]*)*\/[a-z]* {
do_yylloc;
- yylval->sVal = smm_strdup(yytext);
+ yylval->sVal = string_strdup0(yytext);
return T_REGEX;
}
@@ -257,15 +257,15 @@ ml_comment "/*"([^\*]|\*[^/])*"*/"
<st_string_dbl>\" {
do_yylloc;
/* Closing double string quote */
- yylval->sVal = smm_strdup(strbuf ? strbuf : "");
+ yylval->sVal = string_strdup0(strbuf ? strbuf : "");
smm_free(strbuf);
saffire_pop_state();
return T_STRING;
}
<st_string_sgl>\' {
do_yylloc;
/* Closing Single string quote */
- yylval->sVal = smm_strdup(strbuf ? strbuf : "");
+ yylval->sVal = string_strdup0(strbuf ? strbuf : "");
smm_free(strbuf);
saffire_pop_state();
return T_STRING;
@@ -350,7 +350,7 @@ ml_comment "/*"([^\*]|\*[^/])*"*/"
{identifier} {
do_yylloc;
saffire_push_state(st_div);
- yylval->sVal = smm_strdup(yytext);
+ yylval->sVal = string_strdup0(yytext);
return T_IDENTIFIER;
}
Oops, something went wrong.

0 comments on commit 9c3bf9d

Please sign in to comment.