DEADSOFTWARE

Patched for Linux
[mp3cc.git] / MPC.3.5.LINUX / structures / unit.c
1 /********************************************************************
3 block.h - structures and functions used to hold program
4 block descriptions
6 Niksa Orlic, 2005-03-30
8 ********************************************************************/
10 #include "../util/strings.h"
11 #include "../util/error.h"
12 //#include "../util/message.h"
13 #include "../classgen/bytecode.h"
14 #include "type_list.h"
15 #include "string_list.h"
16 #include "type.h"
17 #include "identifier.h"
18 #include "name_table.h"
19 #include "block.h"
20 #include "unit.h"
21 #include "../classgen/preverify.h"
23 #include "../util/memory.h"
25 #include <string.h>
26 #include <stdlib.h>
27 #include <stdio.h>
29 #include "../classgen/constant_pool.h"
30 #include "../classgen/classgen.h"
33 /*
34 Create an empty unit from the given name.
35 */
36 unit* unit_create(string *unit_name)
37 {
38 unit *new_unit;
39 new_unit = (unit*)mem_alloc(sizeof(unit));
41 if (new_unit == NULL)
42 return NULL;
44 new_unit->unit_name = unit_name;
45 new_unit->names = name_table_create();
46 new_unit->is_library = 0;
48 return new_unit;
49 }
51 /*
52 Destroy a unit.
53 */
54 void unit_destroy(unit *old_unit)
55 {
56 string_destroy(old_unit->unit_name);
58 mem_free(old_unit);
59 }
62 /*
63 Duplicate a unit.
64 */
65 unit* unit_duplicate(unit *item)
66 {
67 unit *new_item;
68 new_item = (unit*) mem_alloc(sizeof(unit));
70 new_item->names = item->names;
71 new_item->unit_name = string_duplicate(item->unit_name);
72 new_item->is_library = item->is_library;
74 return new_item;
75 }