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 */
29 static dict_t*classes=0;
31 // ----------------------- class signature ------------------------------
33 char class_signature_equals(class_signature_t*c1, class_signature_t*c2)
35 /* notice: access right is *not* respected */
36 if(!strcmp(c1->name, c2->name) &&
37 !strcmp(c1->package, c2->package)) {
42 static unsigned int class_signature_hash(class_signature_t*c)
44 unsigned int hash = 0;
45 hash = crc32_add_string(hash, c->package);
46 hash = crc32_add_string(hash, c->name);
50 static void* dummy_clone(void*other) {return other;}
51 static void dummy_destroy(class_signature_t*c) {}
53 type_t class_signature_type = {
54 hash: (hash_func)class_signature_hash,
55 equals: (equals_func)class_signature_equals,
56 /* all signatures are static */
57 dup: (dup_func)dummy_clone,
58 free: (free_func)dummy_destroy,
61 // ----------------------- function signature ------------------------------
63 static char function_signature_equals(function_signature_t*f1, function_signature_t*f2)
65 return !strcmp(f1->name, f2->name);
67 static unsigned int function_signature_hash(function_signature_t*f)
69 return crc32_add_string(0, f->name);
71 type_t function_signature_type = {
72 hash: (hash_func)function_signature_hash,
73 equals: (equals_func)function_signature_equals,
74 /* all signatures are static */
75 dup: (dup_func)dummy_clone,
76 free: (free_func)dummy_destroy,
79 // ------------------------- constructors --------------------------------
81 class_signature_t* class_signature_register(int access, char*package, char*name)
83 class_signature_t*c = malloc(sizeof(class_signature_t));
87 dict_put(classes, c, c);
91 // --------------- builtin classes (from builtin.c) ----------------------
95 classes = builtin_getclasses();
97 class_signature_t* registry_safefindclass(const char*package, const char*name)
99 class_signature_t*c = registry_findclass(package, name);
101 printf("%s.%s\n", package, name);
105 class_signature_t* registry_findclass(const char*package, const char*name)
108 class_signature_t tmp;
109 tmp.package = package;
111 class_signature_t* c = (class_signature_t*)dict_lookup(classes, &tmp);
114 void registry_fill_multiname(multiname_t*m, namespace_t*n, class_signature_t*c)
118 m->ns->access = c->access;
119 m->ns->name = (char*)c->package;
121 m->namespace_set = 0;
123 multiname_t* class_signature_to_multiname(class_signature_t*cls)
128 namespace_t*ns = namespace_new(cls->access, cls->package);
129 return multiname_new(ns,cls->name);
132 // ----------------------- builtin types ------------------------------
133 class_signature_t* registry_getanytype() {return 0;/*FIXME*/}
135 class_signature_t* registry_getobjectclass() {return registry_safefindclass("", "Object");}
136 class_signature_t* registry_getstringclass() {return registry_safefindclass("", "String");}
137 class_signature_t* registry_getintclass() {return registry_safefindclass("", "int");}
138 class_signature_t* registry_getuintclass() {return registry_safefindclass("", "uint");}
139 class_signature_t* registry_getbooleanclass() {return registry_safefindclass("", "Boolean");}
140 class_signature_t* registry_getnumberclass() {return registry_safefindclass("", "Number");}
141 class_signature_t* registry_getMovieClip() {return registry_safefindclass("flash.display", "MovieClip");}
143 // ----------------------- builtin dummy types -------------------------
144 class_signature_t nullclass = {
145 ACCESS_PACKAGE, "", "null", 0, 0, 0,
147 class_signature_t* registry_getnullclass() {