# HG changeset patch # User Nobuyasu Oshiro # Date 1339670694 -32400 # Node ID a3a2f64cf8f4ca387af7a7b3558e40ac1246ba77 # Parent 85047c4f1ca4734e20145043302ddda89a18aff9 modify implementation of rectype diff -r 85047c4f1ca4 -r a3a2f64cf8f4 CbC-examples/rectypeTest/instruct.cbc --- a/CbC-examples/rectypeTest/instruct.cbc Wed Jun 13 17:18:58 2012 +0900 +++ b/CbC-examples/rectypeTest/instruct.cbc Thu Jun 14 19:44:54 2012 +0900 @@ -1,26 +1,28 @@ #include +// miss struct interface { - __rectype *next; + __rectype *next; }; - __code print(struct interface p) { - puts("print"); - exit(0); + puts("print"); + exit(0); } __code csA(struct interface p) { - struct interface ds = { csA }; - goto p.next(ds); + struct interface ds; + ds.next = csA; + goto p.next(ds); } void main1() { - struct interface ds = { print }; - goto csA(ds); + struct interface ds; + ds.next = print; + goto csA(ds); } int main() { - main1(); - return 0; + main1(); + return 0; } diff -r 85047c4f1ca4 -r a3a2f64cf8f4 CbC-examples/rectypeTest/typedef.cbc --- a/CbC-examples/rectypeTest/typedef.cbc Wed Jun 13 17:18:58 2012 +0900 +++ b/CbC-examples/rectypeTest/typedef.cbc Thu Jun 14 19:44:54 2012 +0900 @@ -1,21 +1,24 @@ -#include +typedef __code (CS)(__rectype*); // CS *p -//typedef __code (*csPtr)(__rectype); -typedef __code (*csPtr)(__rectype*); // TODO: error +//typedef __code (*CS)(__code(*p)()); +//typedef __code (CS)(__code(*p)()); // CS *p - -//__code print(csPtr p ) { TODO: -__code print(__rectype *p ) { - puts("hello"); +#include +__code cs_end(CS *p) +{ + printf("end\n"); } -//__code func(csPtr p ) { TODO: -__code func(__rectype *p ) { - goto p(func); +__code cs(CS *p) +{ + CS *b; + goto p(b); +// goto p("aaa"); //note: expected ‘void (*)’ but argument is of type ‘char } - int main() { - goto func(print); - return 0; + CS *p; + p = cs_end; + goto cs(p); + return 0; } diff -r 85047c4f1ca4 -r a3a2f64cf8f4 gcc/c-decl.c --- a/gcc/c-decl.c Wed Jun 13 17:18:58 2012 +0900 +++ b/gcc/c-decl.c Thu Jun 14 19:44:54 2012 +0900 @@ -5159,6 +5159,7 @@ #ifndef noCbC if ( declspecs->typespec_word == cts_CbC_rec ) { + // IS_RECTYPE(type) = 1; // type = build_code_segment_type (type, NULL_TREE); IS_RECTYPE(type) = 1; } diff -r 85047c4f1ca4 -r a3a2f64cf8f4 gcc/c-family/c-common.c --- a/gcc/c-family/c-common.c Wed Jun 13 17:18:58 2012 +0900 +++ b/gcc/c-family/c-common.c Thu Jun 14 19:44:54 2012 +0900 @@ -423,7 +423,7 @@ #ifndef noCbC /* CbC project */ { "__code", RID_CbC_CODE, 0 }, - { "code", RID_CbC_CODE, 0 }, + // { "code", RID_CbC_CODE, 0 }, { "__rectype", RID_CbC_REC, 0}, { "selftype", RID_CbC_SELFTYPE, 0}, #endif diff -r 85047c4f1ca4 -r a3a2f64cf8f4 gcc/c-family/c-pretty-print.c --- a/gcc/c-family/c-pretty-print.c Wed Jun 13 17:18:58 2012 +0900 +++ b/gcc/c-family/c-pretty-print.c Thu Jun 14 19:44:54 2012 +0900 @@ -547,7 +547,8 @@ || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE) pp_c_right_paren (pp); #ifndef noCbC - if(IS_RECTYPE(t)) return; + if(IS_RECTYPE(t)) + return; #endif t = TREE_TYPE (t); } diff -r 85047c4f1ca4 -r a3a2f64cf8f4 gcc/c-parser.c --- a/gcc/c-parser.c Wed Jun 13 17:18:58 2012 +0900 +++ b/gcc/c-parser.c Thu Jun 14 19:44:54 2012 +0900 @@ -2144,7 +2144,8 @@ t.kind = ctsk_resword; t.spec = c_parser_peek_token (parser)->value; declspecs_add_type (loc, specs, t); - + + IS_RECTYPE(t.spec) = 1; /* attrs = get_identifier("fastcall"); attrs = build_tree_list(attrs, NULL_TREE); @@ -2520,7 +2521,9 @@ while(TREE_CODE (TREE_TYPE (tmptype)) == POINTER_TYPE) tmptype = TREE_TYPE(tmptype); if(IS_SELFTYPE ( TREE_TYPE (tmptype))) TREE_TYPE(tmptype) = type; - if(IS_RECTYPE ( TREE_TYPE (tmptype))) TREE_TYPE(tmptype) = type; + // if(IS_RECTYPE ( TREE_TYPE (tmptype))) + if(IS_RECTYPE (tmptype)) + TREE_TYPE(tmptype) = type; } #endif