Skip to content

Commit

Permalink
#362 #364 Fix alias bug, refine ownership & replicator
Browse files Browse the repository at this point in the history
Fixes #364
  • Loading branch information
SanderMertens committed Oct 3, 2015
1 parent 5f485be commit fd3bd3f
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 127 deletions.
21 changes: 11 additions & 10 deletions components/vm/src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,7 @@ typedef union Di2f_t {
DEFINE_##code:\
fetchOp1(DEFINE,code);\
if (!op1_##code) {\
printf("Exception: null dereference in define\n");\
abort();\
cx_error("Exception: null dereference in define");\
goto STOP;\
}\
cx_define((cx_object)op1_##code);\
Expand All @@ -587,8 +586,7 @@ typedef union Di2f_t {
UPDATE_##code:\
fetchOp1(UPDATE,code);\
if (!op1_##code) {\
printf("Exception: null dereference in updateFrom\n");\
abort();\
cx_error("Exception: null dereference in updateFrom");\
goto STOP;\
}\
cx_update((cx_object)op1_##code);\
Expand All @@ -598,19 +596,20 @@ typedef union Di2f_t {
UPDATEBEGIN_##code:\
fetchOp1(UPDATEBEGIN,code);\
if (!op1_##code) {\
printf("Exception: null dereference in updateBegin\n");\
abort();\
cx_error("Exception: null dereference in updateBegin");\
goto STOP;\
}\
cx_updateBegin((cx_object)op1_##code);\
if (cx_updateBegin((cx_object)op1_##code)) {\
cx_error("Exception: %s", cx_lasterr());\
goto error;\
}\
next();\

#define UPDATEEND(type,code)\
UPDATEEND_##code:\
fetchOp1(UPDATEEND,code);\
if (!op1_##code) {\
printf("Exception: null dereference in updateEnd\n");\
abort();\
cx_error("Exception: null dereference in updateEnd");\
goto STOP;\
}\
cx_updateEnd((cx_object)op1_##code);\
Expand All @@ -621,7 +620,6 @@ typedef union Di2f_t {
fetchOp2(UPDATEFROM, code);\
if (!op1_##code) {\
printf("Exception: null dereference in updateFrom\n");\
abort();\
goto STOP;\
}\
{\
Expand Down Expand Up @@ -1062,6 +1060,9 @@ static int32_t cx_vm_run_w_storage(vm_program program, void* reg, void *result)

/* ---- Expand instruction macro's */
OPS_EXP(INSTR);

error:
return -1;
}

/* Delete a string concatenation cache (cleanup function for thread
Expand Down
16 changes: 11 additions & 5 deletions generators/c/api/src/cx_apitype.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ static cx_int16 c_apiAssignMember(cx_serializer s, cx_value* v, void* userData)
g_fileWrite(data->source, "this->%s",
memberId);
} else {
cx_id typeId;
g_fileWrite(data->source, "%s(this)->%s",
g_fullOid(data->g, cx_parentof(m), typeId), memberId);
if (cx_type(cx_parentof(m))->reference) {
cx_id typeId;
g_fileWrite(data->source, "%s(this)->%s",
g_fullOid(data->g, cx_parentof(m), typeId), memberId);
} else {
cx_id typeId;
g_fileWrite(data->source, "((%s*)this)->%s",
g_fullOid(data->g, cx_parentof(m), typeId), memberId);
}
}

/* Strdup strings */
Expand Down Expand Up @@ -117,7 +123,7 @@ static struct cx_serializer_s c_apiParamSerializer(void) {

cx_serializerInit(&s);
s.metaprogram[CX_MEMBER] = c_apiParamMember;
s.access = CX_LOCAL|CX_READONLY|CX_PRIVATE;
s.access = CX_LOCAL|CX_READONLY|CX_PRIVATE|CX_HIDDEN;
s.accessKind = CX_NOT;

return s;
Expand All @@ -129,7 +135,7 @@ static struct cx_serializer_s c_apiAssignSerializer(void) {

cx_serializerInit(&s);
s.metaprogram[CX_MEMBER] = c_apiAssignMember;
s.access = CX_LOCAL|CX_READONLY|CX_PRIVATE;
s.access = CX_LOCAL|CX_READONLY|CX_PRIVATE|CX_HIDDEN;
s.accessKind = CX_NOT;

return s;
Expand Down
3 changes: 2 additions & 1 deletion packages/corto/ast/src/ast_Initializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ struct cx_serializer_s ast_findMemberSerializer(void) {
struct cx_serializer_s s;
cx_serializerInit(&s);
s.metaprogram[CX_MEMBER] = ast_Initializer_findMember;
s.access = CX_LOCAL | CX_PRIVATE | CX_READONLY;
s.access = CX_LOCAL | CX_PRIVATE | CX_READONLY | CX_HIDDEN;
s.accessKind = CX_NOT;
s.traceKind = CX_SERIALIZER_TRACE_NEVER;
s.aliasAction = CX_SERIALIZER_ALIAS_FOLLOW;
return s;
}

Expand Down
40 changes: 20 additions & 20 deletions packages/corto/lang/include/cx__api.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,14 @@ CORTO_LANG_EXPORT cx_int16 cx_delegatedataInit(cx_delegatedata* value);
CORTO_LANG_EXPORT cx_int16 cx_delegatedataDeinit(cx_delegatedata* value);

/* ::corto::lang::destructAction */
CORTO_LANG_EXPORT cx_destructAction* cx_destructActionCreate(void);
CORTO_LANG_EXPORT cx_destructAction* cx_destructActionCreateChild(cx_object _parent, cx_string _name);
CORTO_LANG_EXPORT cx_destructAction* cx_destructActionCreate(cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT cx_destructAction* cx_destructActionCreateChild(cx_object _parent, cx_string _name, cx_object instance, cx_function procedure);

CORTO_LANG_EXPORT cx_destructAction* cx_destructActionDeclare(void);
CORTO_LANG_EXPORT cx_destructAction* cx_destructActionDeclareChild(cx_object _parent, cx_string _name);
CORTO_LANG_EXPORT cx_int16 cx_destructActionDefine(cx_destructAction* this);
CORTO_LANG_EXPORT void cx_destructActionUpdate(cx_destructAction* this);
CORTO_LANG_EXPORT void cx_destructActionSet(cx_destructAction* this);
CORTO_LANG_EXPORT cx_int16 cx_destructActionDefine(cx_destructAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT void cx_destructActionUpdate(cx_destructAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT void cx_destructActionSet(cx_destructAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT cx_string cx_destructActionStr(cx_destructAction* value);
CORTO_LANG_EXPORT cx_destructAction* cx_destructActionFromStr(cx_destructAction* value, cx_string str);
CORTO_LANG_EXPORT cx_int16 cx_destructActionCopy(cx_destructAction* *dst, cx_destructAction* src);
Expand Down Expand Up @@ -431,14 +431,14 @@ CORTO_LANG_EXPORT cx_int16 cx_functionCopy(cx_function *dst, cx_function src);
CORTO_LANG_EXPORT cx_int16 cx_functionCompare(cx_function dst, cx_function src);

/* ::corto::lang::initAction */
CORTO_LANG_EXPORT cx_initAction* cx_initActionCreate(void);
CORTO_LANG_EXPORT cx_initAction* cx_initActionCreateChild(cx_object _parent, cx_string _name);
CORTO_LANG_EXPORT cx_initAction* cx_initActionCreate(cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT cx_initAction* cx_initActionCreateChild(cx_object _parent, cx_string _name, cx_object instance, cx_function procedure);

CORTO_LANG_EXPORT cx_initAction* cx_initActionDeclare(void);
CORTO_LANG_EXPORT cx_initAction* cx_initActionDeclareChild(cx_object _parent, cx_string _name);
CORTO_LANG_EXPORT cx_int16 cx_initActionDefine(cx_initAction* this);
CORTO_LANG_EXPORT void cx_initActionUpdate(cx_initAction* this);
CORTO_LANG_EXPORT void cx_initActionSet(cx_initAction* this);
CORTO_LANG_EXPORT cx_int16 cx_initActionDefine(cx_initAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT void cx_initActionUpdate(cx_initAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT void cx_initActionSet(cx_initAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT cx_string cx_initActionStr(cx_initAction* value);
CORTO_LANG_EXPORT cx_initAction* cx_initActionFromStr(cx_initAction* value, cx_string str);
CORTO_LANG_EXPORT cx_int16 cx_initActionCopy(cx_initAction* *dst, cx_initAction* src);
Expand Down Expand Up @@ -596,14 +596,14 @@ CORTO_LANG_EXPORT cx_int16 cx_interfaceVectorseqInit(cx_interfaceVectorseq* valu
CORTO_LANG_EXPORT cx_int16 cx_interfaceVectorseqDeinit(cx_interfaceVectorseq* value);

/* ::corto::lang::invokeAction */
CORTO_LANG_EXPORT cx_invokeAction* cx_invokeActionCreate(void);
CORTO_LANG_EXPORT cx_invokeAction* cx_invokeActionCreateChild(cx_object _parent, cx_string _name);
CORTO_LANG_EXPORT cx_invokeAction* cx_invokeActionCreate(cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT cx_invokeAction* cx_invokeActionCreateChild(cx_object _parent, cx_string _name, cx_object instance, cx_function procedure);

CORTO_LANG_EXPORT cx_invokeAction* cx_invokeActionDeclare(void);
CORTO_LANG_EXPORT cx_invokeAction* cx_invokeActionDeclareChild(cx_object _parent, cx_string _name);
CORTO_LANG_EXPORT cx_int16 cx_invokeActionDefine(cx_invokeAction* this);
CORTO_LANG_EXPORT void cx_invokeActionUpdate(cx_invokeAction* this);
CORTO_LANG_EXPORT void cx_invokeActionSet(cx_invokeAction* this);
CORTO_LANG_EXPORT cx_int16 cx_invokeActionDefine(cx_invokeAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT void cx_invokeActionUpdate(cx_invokeAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT void cx_invokeActionSet(cx_invokeAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT cx_string cx_invokeActionStr(cx_invokeAction* value);
CORTO_LANG_EXPORT cx_invokeAction* cx_invokeActionFromStr(cx_invokeAction* value, cx_string str);
CORTO_LANG_EXPORT cx_int16 cx_invokeActionCopy(cx_invokeAction* *dst, cx_invokeAction* src);
Expand Down Expand Up @@ -746,14 +746,14 @@ CORTO_LANG_EXPORT cx_int16 cx_modifierInit(cx_modifier* value);
CORTO_LANG_EXPORT cx_int16 cx_modifierDeinit(cx_modifier* value);

/* ::corto::lang::notifyAction */
CORTO_LANG_EXPORT cx_notifyAction* cx_notifyActionCreate(void);
CORTO_LANG_EXPORT cx_notifyAction* cx_notifyActionCreateChild(cx_object _parent, cx_string _name);
CORTO_LANG_EXPORT cx_notifyAction* cx_notifyActionCreate(cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT cx_notifyAction* cx_notifyActionCreateChild(cx_object _parent, cx_string _name, cx_object instance, cx_function procedure);

CORTO_LANG_EXPORT cx_notifyAction* cx_notifyActionDeclare(void);
CORTO_LANG_EXPORT cx_notifyAction* cx_notifyActionDeclareChild(cx_object _parent, cx_string _name);
CORTO_LANG_EXPORT cx_int16 cx_notifyActionDefine(cx_notifyAction* this);
CORTO_LANG_EXPORT void cx_notifyActionUpdate(cx_notifyAction* this);
CORTO_LANG_EXPORT void cx_notifyActionSet(cx_notifyAction* this);
CORTO_LANG_EXPORT cx_int16 cx_notifyActionDefine(cx_notifyAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT void cx_notifyActionUpdate(cx_notifyAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT void cx_notifyActionSet(cx_notifyAction* this, cx_object instance, cx_function procedure);
CORTO_LANG_EXPORT cx_string cx_notifyActionStr(cx_notifyAction* value);
CORTO_LANG_EXPORT cx_notifyAction* cx_notifyActionFromStr(cx_notifyAction* value, cx_string str);
CORTO_LANG_EXPORT cx_int16 cx_notifyActionCopy(cx_notifyAction* *dst, cx_notifyAction* src);
Expand Down
2 changes: 1 addition & 1 deletion packages/corto/lang/include/cx__type.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ CX_BITMASK(cx_modifier);
#define CX_PRIVATE (0x2)
#define CX_READONLY (0x4)
#define CX_CONST (0x8)
#define CX_HIDDEN (0x16)
#define CX_HIDDEN (0x10)

/* ::corto::lang::member */
CX_CLASS(cx_member);
Expand Down
Loading

0 comments on commit fd3bd3f

Please sign in to comment.