OSDN Git Service

* public snapshot of sid simulator
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / gloss / compGloss.cxx
1 // compGloss.cxx - Gloss component.  -*- C++ -*-
2
3 // Copyright (C) 1999, 2000 Red Hat.
4 // This file is part of SID and is licensed under the GPL.
5 // See the file COPYING.SID for conditions for redistribution.
6
7 #include "config.h"
8 #include "tconfig.h"
9
10 #include <sidcomp.h>
11 #include <sidso.h>
12
13 #if SIDTARGET_ARM
14 #include "angel.h"
15 #endif
16 #if SIDTARGET_M32R
17 #include "m32r.h"
18 #endif
19 #if SIDTARGET_MIPS
20 #include "mips.h"
21 #endif
22 #include "gloss.h"
23
24 using namespace std;
25 using namespace sid;
26
27
28 static
29 vector<string>
30 compGlossListTypes()
31 {
32   vector<string> types;
33 #if SIDTARGET_M32R
34   types.push_back("sw-gloss-m32r/libgloss");
35 #endif
36 #if SIDTARGET_ARM
37   types.push_back("sw-gloss-arm/angel");
38 #endif
39 #if SIDTARGET_MIPS
40   types.push_back("sw-gloss-mips32/idt");
41 #endif
42   types.push_back("sw-gloss-generic/libgloss");
43   return types;
44 }
45
46
47 static
48 component*
49 compGlossCreate(const string& typeName)
50 {
51 #if SIDTARGET_M32R
52   if (typeName == "sw-gloss-m32r/libgloss")
53     return new m32r_libgloss();
54 #endif
55 #if SIDTARGET_ARM
56   if (typeName == "sw-gloss-arm/angel")
57     return new arm_angel();
58 #endif
59 #if SIDTARGET_MIPS
60   if (typeName == "sw-gloss-mips32/idt")
61     return new mips32_idt();
62 #endif
63   if (typeName == "sw-gloss-generic/libgloss")
64     return new gloss32();
65   return 0;
66 }
67
68
69 static
70 void
71 compGlossDelete(component* c)
72 {
73   // Two of these dynamic_cast<>s will return 0.  It is safe to delete 0.
74 #if SIDTARGET_M32R
75   m32r_libgloss* g1 = dynamic_cast<m32r_libgloss*>(c);
76   if (g1) { delete g1; return; }
77 #endif
78 #if SIDTARGET_ARM
79   arm_angel* g2 = dynamic_cast<arm_angel*>(c);
80   if (g2) { delete g2; return; }
81 #endif
82 #if SIDTARGET_MIPS
83   mips32_idt* g3 = dynamic_cast<mips32_idt*>(c);
84   if (g3) { delete g3; return; }
85 #endif
86   gloss32* g4 = dynamic_cast<gloss32*>(c);
87   if (g4) { delete g4; return; }
88 }
89
90
91 // static object
92 extern const component_library gloss_component_library;
93
94 const component_library gloss_component_library DLLEXPORT = 
95 {
96   COMPONENT_LIBRARY_MAGIC,
97   & compGlossListTypes, 
98   & compGlossCreate,
99   & compGlossDelete
100 };