Re: [ooc-compiler] Compiler error
Brought to you by:
mva
|
From: Frank H. <hr...@te...> - 2010-07-30 02:17:06
|
Hi Stewart,
I deleted the bin, obj and sym directory and compiled with
oo2c --make Test
Same result as before. Then:
oo2c --version
oo2c/gcc 2.1.11
gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
obj/Test.c:
------------------------------------------------------------
#include <Test.d>
#include <__oo2c.h>
#include <setjmp.h>
void Test__NodeD_Init(Test__Node node) {
register OOC_INT32 i0,i1;
i0 = (OOC_INT32)node;
i1 = _check_pointer(i0, 216);
L__Init((void*)((_check_pointer(i0, 216))+4),
(RT0__Struct)((OOC_INT32)&_td_L__Header));
i0 = L__IsEmpty((void*)((_check_pointer(i0, 244))+4));
i0 = !i0;
if (!i0) goto l4;
Out__String((OOC_CHAR8*)"n1.sons not empty!", 19);
Out__Ln();
l4:
return;
;
}
void OOC_Test_init(void) {
register OOC_INT32 i0;
i0 = (OOC_INT32)RT0__NewObject(_td_Test__Node.baseTypes[0]);
Test__n1 = (Test__Node)i0;
Test__NodeD_Init((Test__Node)i0);
return;
;
}
void OOC_Test_destroy(void) {
}
/* --- */
----------------------------------------------------------
obj/L.c:
----------------------------------------------------------
#include <L.d>
#include <__oo2c.h>
#include <setjmp.h>
OOC_CHAR8 L__IsEmpty(const struct L__Header *list__ref) {
register OOC_INT32 i0;
OOC_ALLOCATE_VPAR(list,L__Header ,1)
OOC_INITIALIZE_VPAR(list__ref,list,L__Header ,8)
i0 = (OOC_INT32)*(OOC_INT32*)(OOC_INT32)list;
return (i0==0);
;
}
void L__Init(struct L__Header *list, RT0__Struct list__tag) {
*(OOC_INT32*)(OOC_INT32)list = 0;
*(OOC_INT32*)((OOC_INT32)list+4) = 0;
Out__String((OOC_CHAR8*)"List initialized", 17);
Out__Ln();
return;
;
}
void OOC_L_init(void) {
return;
;
}
void OOC_L_destroy(void) {
}
/* --- */
--------------------------------------------------------
I'm curious.
--
Frank Hrebabetzky +55 / 48 / 3235 1106
Florianopolis, Brazil
On 07/28/2010 11:23 PM, Stewart Greenhill wrote:
> Hi Frank,
>
> Sorry for the delay. I just tested this code and it works fine for me.
>
> Which version of oo2c and gcc are you running?
>
> Can you post the output files obj/Test.c and obj/L.c? Do a clean build
> after first removing all of the files under the sym and obj directories.
>
> One slight inefficiency is that L.IsEmpty should be:
> PROCEDURE IsEmpty* (VAR list:Header): BOOLEAN;
> Otherwise it makes a copy of the record before testing the pointer.
>
> Cheers,
> Stewart
>
> Frank Hrebabetzky wrote:
>> Hi there,
>>
>> I guess I found a compiler error. I have a module L which implements a
>> rudimentary list and a module Test which imports L:
>>
>>
>> MODULE L;
>> IMPORT Out;
>>
>> TYPE
>> Item* = POINTER TO ItemD;
>> ItemD* = RECORD
>> next-: Item;
>> END;
>>
>> Header* = RECORD
>> first-, last-: Item;
>> END;
>>
>> PROCEDURE IsEmpty* (list:Header): BOOLEAN;
>> BEGIN RETURN list.first=NIL
>> END IsEmpty;
>>
>> PROCEDURE Init* (VAR list:Header);
>> BEGIN
>> list.first:= NIL; list.last:= NIL;
>> Out.String("List initialized"); Out.Ln;
>> END Init;
>>
>> END L.
>>
>>
>> MODULE Test;
>> IMPORT L, Out;
>>
>> TYPE
>> Node = POINTER TO NodeD;
>> NodeD = RECORD (L.ItemD)
>> sons-: L.Header;
>> END;
>> VAR n1: Node;
>>
>> PROCEDURE (node:Node) Init;
>> BEGIN
>> L.Init (node.sons);
>> IF ~L.IsEmpty(node.sons) THEN
>> Out.String("n1.sons not empty!"); Out.Ln;
>> END
>> END Init;
>>
>> BEGIN
>> NEW (n1);
>> n1.Init;
>> END Test.
>>
>>
>> Executing Test prints the following:
>>
>> List initialized
>> n1.sons not empty!
>>
>> which means that n1.Init didn't change n1. This is an error, isn't it?
>> If details matter I can tell them (platform, versions etc.).
>>
>
|