3 Routines for compiling Flash2 AVM2 ABC Actionscript
5 Extension module for the rfxswf library.
6 Part of the swftools package.
8 Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
24 #ifndef __abc_registry_h__
25 #define __abc_registry_h__
33 DECLARE(unresolvedinfo);
35 DECLARE_LIST(classinfo);
36 DECLARE_LIST(slotinfo);
38 /* member/class flags */
40 #define FLAG_BUILTIN 128
44 #define FLAG_OVERRIDE 8
45 #define FLAG_NATIVE 16
49 #define FLAG_DYNAMIC 8
50 #define FLAG_INTERFACE 16
52 #define INFOTYPE_VAR 1
53 #define INFOTYPE_METHOD 2
54 #define INFOTYPE_CLASS 3
55 #define INFOTYPE_UNRESOLVED 4
58 #define SUBTYPE_GETSET 3
61 U8 kind,subtype,flags,access;
66 struct _unresolvedinfo {
67 U8 kind,subtype,flags,access;
71 namespace_list_t*nsset;
74 U8 kind,subtype,flags,access;
78 classinfo_t*superclass;
80 void*data; //TODO: get rid of this- parser.y should pass type/value/code triples around
81 classinfo_t*interfaces[];
84 U8 kind,subtype,flags,access;
89 classinfo_t*return_type;
94 struct _methodinfo /*extends memberinfo*/ {
95 U8 kind,subtype,flags,access;
99 classinfo_t*return_type;
101 classinfo_list_t*params;
103 struct _varinfo /*extends memberinfo*/ {
104 U8 kind,subtype,flags,access;
113 extern type_t memberinfo_type;
114 extern type_t slotinfo_type;
115 char slotinfo_equals(slotinfo_t*c1, slotinfo_t*c2);
117 void registry_init();
119 classinfo_t* classinfo_register(int access, const char*package, const char*name, int num_interfaces);
120 methodinfo_t* methodinfo_register_onclass(classinfo_t*cls, U8 access, const char*ns, const char*name);
121 methodinfo_t* methodinfo_register_global(U8 access, const char*package, const char*name);
122 varinfo_t* varinfo_register_onclass(classinfo_t*cls, U8 access, const char*ns, const char*name);
123 varinfo_t* varinfo_register_global(U8 access, const char*package, const char*name);
125 slotinfo_t* registry_resolve(slotinfo_t*s);
126 void registry_resolve_all();
128 slotinfo_t* registry_find(const char*package, const char*name);
129 void registry_dump();
130 memberinfo_t* registry_findmember(classinfo_t*cls, const char*ns, const char*name, char superclasses);
131 memberinfo_t* registry_findmember_nsset(classinfo_t*cls, namespace_list_t*ns, const char*name, char superclasses);
133 void registry_fill_multiname(multiname_t*m, namespace_t*n, slotinfo_t*c);
134 #define MULTINAME(m,x) \
138 registry_fill_multiname(&m, &m##_ns, (slotinfo_t*)(x));
140 multiname_t* classinfo_to_multiname(slotinfo_t*cls);
142 char registry_isfunctionclass();
143 char registry_isclassclass();
145 classinfo_t* slotinfo_asclass(slotinfo_t*f);
146 classinfo_t* slotinfo_gettype(slotinfo_t*);
148 namespace_t access2namespace(U8 access, char*package);
150 char registry_ispackage(char*package);
153 classinfo_t* registry_getanytype();
154 classinfo_t* registry_getarrayclass();
155 classinfo_t* registry_getobjectclass();
156 classinfo_t* registry_getnumberclass();
157 classinfo_t* registry_getstringclass();
158 classinfo_t* registry_getintclass();
159 classinfo_t* registry_getuintclass();
160 classinfo_t* registry_getnullclass();
161 classinfo_t* registry_getregexpclass();
162 classinfo_t* registry_getbooleanclass();
163 classinfo_t* registry_getMovieClip();
164 classinfo_t* registry_getclassclass(classinfo_t*a);
165 classinfo_t* registry_getnamespaceclass();
167 char* infotypename(slotinfo_t*s);
168 void slotinfo_dump(slotinfo_t*s);
170 /* convenience functions */
171 #define sig2mname(x) (x->superclass,classinfo_to_multiname((slotinfo_t*)(x)))
174 #define TYPE_IS_ANY(t) ((t) == 0)
175 #define TYPE_INT registry_getintclass()
176 #define TYPE_IS_INT(t) ((t) == registry_getintclass())
177 #define TYPE_UINT registry_getuintclass()
178 #define TYPE_IS_UINT(t) ((t) == registry_getuintclass())
179 #define TYPE_NUMBER registry_getnumberclass()
180 #define TYPE_IS_NUMBER(t) ((t) == registry_getnumberclass())
181 #define TYPE_FLOAT registry_getnumberclass()
182 #define TYPE_IS_FLOAT(t) ((t) == registry_getnumberclass())
183 #define TYPE_BOOLEAN registry_getbooleanclass()
184 #define TYPE_IS_BOOLEAN(t) ((t) == registry_getbooleanclass())
185 #define TYPE_STRING registry_getstringclass()
186 #define TYPE_IS_STRING(t) ((t) == registry_getstringclass())
187 #define TYPE_OBJECT registry_getobjectclass()
188 #define TYPE_IS_OBJECT(t) ((t) == registry_getobjectclass())
189 #define TYPE_REGEXP registry_getregexpclass()
190 #define TYPE_IS_REGEXP(t) ((t) == registry_getregexpclass())
191 #define TYPE_NAMESPACE registry_getnamespaceclass()
192 #define TYPE_IS_NAMESPACE(t) ((t) == registry_getnamespaceclass())
193 #define TYPE_FUNCTION(f) ((f)->return_type,slotinfo_asclass((slotinfo_t*)(f)))
194 #define TYPE_IS_FUNCTION(t) registry_isfunctionclass(t)
195 #define TYPE_CLASS(f) ((f)->superclass,slotinfo_asclass((slotinfo_t*)(f)))
196 #define TYPE_IS_CLASS(t) registry_isclassclass(t)
197 #define TYPE_NULL registry_getnullclass()
198 #define TYPE_IS_NULL(t) ((t) == registry_getnullclass())
200 #define TYPE_IS_BUILTIN_SIMPLE(type) (TYPE_IS_INT(type) || \
201 TYPE_IS_UINT(type) || \
202 TYPE_IS_FLOAT(type) || \
203 TYPE_IS_BOOLEAN(type) || \
204 TYPE_IS_STRING(type))