| 1 |
// { dg-do compile } |
| 2 |
// { dg-additional-options "-Wno-return-type" } |
| 3 |
// { dg-additional-options "-mcpu=970 -maltivec" { target powerpc*-*-* } } |
| 4 |
|
| 5 |
typedef union { |
| 6 |
long int asBits; |
| 7 |
} jsval_layout; |
| 8 |
static jsval_layout STRING_TO_JSVAL_IMPL() {} |
| 9 |
|
| 10 |
typedef __attribute__ ((aligned(sizeof (long int)))) long int jsval; |
| 11 |
class Value { |
| 12 |
public: |
| 13 |
void setString() { |
| 14 |
data = STRING_TO_JSVAL_IMPL(); |
| 15 |
} |
| 16 |
jsval_layout data; |
| 17 |
} __attribute__ ((aligned(8))); |
| 18 |
|
| 19 |
static Value StringValue() |
| 20 |
{ |
| 21 |
Value v; |
| 22 |
v.setString(); |
| 23 |
return v; |
| 24 |
} |
| 25 |
|
| 26 |
static const jsval & Jsvalify(const Value & v) |
| 27 |
{ |
| 28 |
return (const jsval &)v; |
| 29 |
} |
| 30 |
|
| 31 |
static Value *Valueify(jsval *v) |
| 32 |
{ |
| 33 |
return (Value *) v; |
| 34 |
} |
| 35 |
|
| 36 |
struct JSObject { |
| 37 |
void getQNameLocalName(); |
| 38 |
}; |
| 39 |
static Value IdToValue(int id) |
| 40 |
{ |
| 41 |
if (id) |
| 42 |
return StringValue(); |
| 43 |
} |
| 44 |
|
| 45 |
static jsval IdToJsval(int id) |
| 46 |
{ |
| 47 |
return Jsvalify(IdToValue(id)); |
| 48 |
} |
| 49 |
|
| 50 |
class AutoGCRooter; |
| 51 |
struct JSContext { |
| 52 |
AutoGCRooter *autoGCRooters; |
| 53 |
}; |
| 54 |
class AutoGCRooter { |
| 55 |
public: |
| 56 |
AutoGCRooter(JSContext *cx) {} |
| 57 |
}; |
| 58 |
class AutoArrayRooter:AutoGCRooter { |
| 59 |
public: |
| 60 |
AutoArrayRooter(JSContext *cx, Value *vec):AutoGCRooter(cx) |
| 61 |
{ |
| 62 |
array = vec; |
| 63 |
cx->autoGCRooters = this; |
| 64 |
} |
| 65 |
Value *array; |
| 66 |
}; |
| 67 |
|
| 68 |
static void PutProperty(JSContext *cx, int id, jsval *vp) |
| 69 |
{ |
| 70 |
JSObject *nameobj; |
| 71 |
jsval roots[3]; |
| 72 |
roots[1] = IdToJsval(id); |
| 73 |
roots[2] = *vp; |
| 74 |
AutoArrayRooter tvr(cx, Valueify(roots)); |
| 75 |
nameobj->getQNameLocalName(); |
| 76 |
} |
| 77 |
|
| 78 |
void xml_defineProperty(JSContext *cx, int id, const Value *v) |
| 79 |
{ |
| 80 |
jsval tmp = Jsvalify(*v); |
| 81 |
PutProperty(cx, id, &tmp); |
| 82 |
} |