X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=testprograms%2Foo_program_example.c;h=ab3a4cc961cfdd832bad7ba99ea4f65c4dd42b52;hb=76572961989e62cef01b295c6c8af7460f6080dd;hp=8339fa130179b1346ba37cba5a5886cb69e01b94;hpb=6ed168c29789db8edf25c87f2da9164c49a5512c;p=libfirm diff --git a/testprograms/oo_program_example.c b/testprograms/oo_program_example.c index 8339fa130..ab3a4cc96 100644 --- a/testprograms/oo_program_example.c +++ b/testprograms/oo_program_example.c @@ -1,10 +1,14 @@ -/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe -** All rights reserved. -** -** Authors: Goetz Lindenmaier -** -** testprogram. -*/ +/* + * Project: libFIRM + * File name: testprograms/oo_program_example.c + * Purpose: A complex example. + * Author: Goetz Lindenmaier + * Modified by: + * Created: + * CVS-ID: $Id$ + * Copyright: (c) 1999-2003 Universität Karlsruhe + * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + */ # include # include @@ -13,28 +17,28 @@ # include "irdump.h" # include "firm.h" -/** This file constructs the IR for the following program: -*** -*** class PRIMA { -*** a: int; -*** -*** int c(d: int) { -*** return (d + self.a); -*** } -*** -*** void set_a(e:int) { -*** self.a = e; -*** } -*** -*** } -*** -*** int main() { -*** o: PRIMA; -*** o = new PRIMA; -*** o.set_a(2); -*** return o.c(5); -*** }; -*** +/** +* +* class PRIMA { +* a: int; +* +* int c(d: int) { +* return (d + self.a); +* } +* +* void set_a(e:int) { +* self.a = e; +* } +* +* } +* +* int main() { +* o: PRIMA; +* o = new PRIMA; +* o.set_a(2); +* return o.c(5); +* }; +* **/ int @@ -55,7 +59,7 @@ main(void) int i; - init_firm (); + init_firm (NULL); set_opt_constant_folding(1); set_opt_cse(1); @@ -94,12 +98,12 @@ main(void) owner is the global type. */ owner = get_glob_type(); /* Main has zero parameters and one result. */ - proc_main = new_type_method(id_from_str("main", 4), 0, 1); + proc_main = new_type_method(id_from_str("OO_PROGRAM_EXAMPLE_main", 23), 0, 1); /* The result type is int. */ set_method_res_type(proc_main, 0, prim_t_int); /* The entity for main. */ - proc_main_e = new_entity (owner, id_from_str ("main", 4), proc_main); + proc_main_e = new_entity (owner, id_from_str ("OO_PROGRAM_EXAMPLE_main", 23), proc_main); /** Build code for procedure main. **/ /* We need one local variable (for "o"). */ @@ -110,8 +114,8 @@ main(void) set_irp_main_irg(main_irg); /* Make the constants. They are independent of a block. */ - c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2)); - c5 = new_Const (mode_Is, tarval_from_long (mode_Is, 5)); + c2 = new_Const (mode_Is, new_tarval_from_long (2, mode_Is)); + c5 = new_Const (mode_Is, new_tarval_from_long (5, mode_Is)); /* There is only one block in main, it contains the allocation and the calls. */ /* Allocate the defined object and generate the type information. */