Skip to content

Commit

Permalink
Fix Anonymous Class bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ab25cq committed Feb 28, 2017
1 parent 307ca20 commit 4e2049a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
1 change: 1 addition & 0 deletions output_of_pwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/home/ab25cq/repo/clover2
2 changes: 1 addition & 1 deletion src/klass.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ void class_init()
alloc_class("regex", FALSE, -1, 0, NULL, FALSE, FALSE);

alloc_class("Null", FALSE, -1, 0, NULL, FALSE, FALSE);
alloc_class("Anonymous", FALSE, -1, 0, NULL, FALSE, TRUE);
alloc_class("Anonymous", FALSE, -1, 0, NULL, FALSE, FALSE);
alloc_class("Self", FALSE, -1, 0, NULL, FALSE, FALSE);

alloc_class("GenericsParametorClass0", FALSE, 0, 0, NULL, FALSE, FALSE);
Expand Down
21 changes: 21 additions & 0 deletions src/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -1960,6 +1960,27 @@ static BOOL call_normal_method(unsigned int node, sCompileInfo* info, sNodeType*
return TRUE;
}
}
else if(class_identify_with_class_name(klass, "Anonymous")) {
/// compile params ///
if(!compile_params(klass, method_name, num_params, params, param_types, generics_types, info)) {
return FALSE;
}

int num_real_params = num_params + 1;

int size_method_name_and_params = METHOD_NAME_MAX + PARAMS_MAX * CLASS_NAME_MAX + 256;
char method_name_and_params[size_method_name_and_params];
create_method_name_and_params(method_name_and_params, size_method_name_and_params, klass, method_name, param_types, num_params);

append_opecode_to_code(info->code, OP_INVOKE_VIRTUAL_METHOD, info->no_output);
append_int_value_to_code(info->code, num_real_params, info->no_output);
append_str_to_constant_pool_and_code(info->constant, info->code, method_name_and_params, info->no_output);

info->stack_num -= num_params + 1;
info->stack_num++;

info->type = create_node_type_with_class_name("Anonymous");
}
else if(klass->mFlags & CLASS_FLAGS_INTERFACE)
{
/// compile params ///
Expand Down
8 changes: 8 additions & 0 deletions tags
Original file line number Diff line number Diff line change
Expand Up @@ -982,17 +982,25 @@ arrange_alignment src/code.c /^static void arrange_alignment(sByteCode* code)$/;
arrange_alignment src/constant.c /^static void arrange_alignment(sConst* self)$/;" f file:
arrange_stack src/node.c /^void arrange_stack(sCompileInfo* cinfo)$/;" f
array_mark_fun src/array.c /^void array_mark_fun(CLObject self, unsigned char* mark_flg)$/;" f
as_fn_append config.status /^ as_fn_append ()$/;" f
as_fn_append configure /^ as_fn_append ()$/;" f
as_fn_arith config.status /^ as_fn_arith ()$/;" f
as_fn_arith configure /^ as_fn_arith ()$/;" f
as_fn_error config.status /^as_fn_error ()$/;" f
as_fn_error configure /^as_fn_error ()$/;" f
as_fn_executable_p config.status /^as_fn_executable_p ()$/;" f
as_fn_executable_p configure /^as_fn_executable_p ()$/;" f
as_fn_exit config.status /^as_fn_exit ()$/;" f
as_fn_exit configure /^as_fn_exit ()$/;" f
as_fn_failure configure /^as_fn_failure () { as_fn_return 1; }$/;" f
as_fn_mkdir_p config.status /^as_fn_mkdir_p ()$/;" f
as_fn_mkdir_p configure /^as_fn_mkdir_p ()$/;" f
as_fn_ret_failure configure /^as_fn_ret_failure () { return 1; }$/;" f
as_fn_ret_success configure /^as_fn_ret_success () { return 0; }$/;" f
as_fn_set_status config.status /^as_fn_set_status ()$/;" f
as_fn_set_status configure /^as_fn_set_status ()$/;" f
as_fn_success configure /^as_fn_success () { as_fn_return 0; }$/;" f
as_fn_unset config.status /^as_fn_unset ()$/;" f
as_fn_unset configure /^as_fn_unset ()$/;" f
assign_operator src/parser.c /^static BOOL assign_operator(unsigned int* node, sParserInfo* info)$/;" f file:
binary_operator src/node.c /^static BOOL binary_operator(sNodeType* left_type, sNodeType* right_type, int byte_operand, int ubyte_operand, int short_operand, int ushort_operand, int int_operand, int uint_operand, int long_operand, int ulong_operand, int float_operand, int double_operand, int pointer_operand, int null_operand, int char_operand, int bool_operand, char* op_string, sCompileInfo* info)$/;" f file:
Expand Down
33 changes: 33 additions & 0 deletions x.clc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module MEquals
{
def equals(right:SELF): bool {
return self.field == right.field;
}
}

interface IEquals
{
def equals(right:Self): bool;
}

class ClassA
{
field:int;

def initialize(num:int) {
self.field = num;
}

include MEquals;
}

class ClassB
{
field:float;

def initialize(num:float) {
self.field = num;
}

include MEquals;
}

0 comments on commit 4e2049a

Please sign in to comment.