This commit is contained in:
Alon Zakai 2012-09-05 12:17:23 -07:00
Родитель ef417d0e7f
Коммит 41d10c114d
2 изменённых файлов: 104 добавлений и 17 удалений

Просмотреть файл

@ -4755,10 +4755,19 @@ LibraryManager.library = {
__cxa_is_number_type: function(type) {
var isNumber = false;
try { if (type == __ZTIi) isNumber = true } catch(e){}
try { if (type == __ZTIj) isNumber = true } catch(e){}
try { if (type == __ZTIl) isNumber = true } catch(e){}
try { if (type == __ZTIm) isNumber = true } catch(e){}
try { if (type == __ZTIx) isNumber = true } catch(e){}
try { if (type == __ZTIy) isNumber = true } catch(e){}
try { if (type == __ZTIf) isNumber = true } catch(e){}
try { if (type == __ZTId) isNumber = true } catch(e){}
try { if (type == __ZTIe) isNumber = true } catch(e){}
try { if (type == __ZTIc) isNumber = true } catch(e){}
try { if (type == __ZTIa) isNumber = true } catch(e){}
try { if (type == __ZTIh) isNumber = true } catch(e){}
try { if (type == __ZTIs) isNumber = true } catch(e){}
try { if (type == __ZTIt) isNumber = true } catch(e){}
return isNumber;
},
@ -4839,22 +4848,22 @@ LibraryManager.library = {
// RTTI hacks for exception handling, defining type_infos for common types.
// The values are dummies. We simply use the addresses of these statically
// allocated variables as unique identifiers.
// type_info for int.
_ZTIi: [0],
// type_info for long.
_ZTIl: [0],
// type_info for long long.
_ZTIx: [0],
// type_info for float.
_ZTIf: [0],
// type_info for double.
_ZTId: [0],
// type_info for char.
_ZTIc: [0],
// type_info for void.
_ZTIv: [0],
// type_info for void*.
_ZTIPv: [0],
_ZTIi: [0], // int
_ZTIj: [0], // unsigned int
_ZTIl: [0], // long
_ZTIm: [0], // unsigned long
_ZTIx: [0], // long long
_ZTIy: [0], // unsigned long long
_ZTIf: [0], // float
_ZTId: [0], // double
_ZTIe: [0], // long double
_ZTIc: [0], // char
_ZTIa: [0], // signed char
_ZTIh: [0], // unsigned char
_ZTIs: [0], // short
_ZTIt: [0], // signed short
_ZTIv: [0], // void
_ZTIPv: [0], // void*
llvm_uadd_with_overflow_i8: function(x, y) {
x = x & 0xff;

Просмотреть файл

@ -5219,7 +5219,85 @@ int main(int argc, char **argv) {
return 1;
}
''', 'hello world');
def test_typeid(self):
self.do_run(r'''
#include <stdio.h>
#include <string.h>
#include <typeinfo>
int main() {
printf("*\n");
#define MAX 100
int ptrs[MAX];
int groups[MAX];
memset(ptrs, 0, MAX*sizeof(int));
memset(groups, 0, MAX*sizeof(int));
int next_group = 1;
#define TEST(X) { \
int ptr = (int)&typeid(X); \
int group = 0; \
int i; \
for (i = 0; i < MAX; i++) { \
if (!groups[i]) break; \
if (ptrs[i] == ptr) { \
group = groups[i]; \
break; \
} \
} \
if (!group) { \
groups[i] = group = next_group++; \
ptrs[i] = ptr; \
} \
printf("%s:%d\n", #X, group); \
}
TEST(int);
TEST(unsigned int);
TEST(unsigned);
TEST(signed int);
TEST(long);
TEST(unsigned long);
TEST(signed long);
TEST(long long);
TEST(unsigned long long);
TEST(signed long long);
TEST(short);
TEST(unsigned short);
TEST(signed short);
TEST(char);
TEST(unsigned char);
TEST(signed char);
TEST(float);
TEST(double);
TEST(long double);
TEST(void);
TEST(void*);
printf("*\n");
}
''', '''*
int:1
unsigned int:2
unsigned:2
signed int:1
long:3
unsigned long:4
signed long:3
long long:5
unsigned long long:6
signed long long:5
short:7
unsigned short:8
signed short:7
char:9
unsigned char:10
signed char:11
float:12
double:13
long double:14
void:15
void*:16
*
''');
def test_static_variable(self):
if self.emcc_args is None: Settings.SAFE_HEAP = 0 # LLVM mixes i64 and i8 in the guard check
src = '''