iv-phonic 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ // Copyright 2006-2008 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef V8_CONVERSIONS_H_
29
+ #define V8_CONVERSIONS_H_
30
+
31
+ namespace v8 {
32
+ namespace internal {
33
+
34
+ // Converts a double to a string value according to ECMA-262 9.8.1.
35
+ // The buffer should be large enough for any floating point number.
36
+ // 100 characters is enough.
37
+ const char* DoubleToCString(double value, char* buffer, int buflen);
38
+
39
+ } } // namespace v8::internal
40
+
41
+ #endif // V8_CONVERSIONS_H_
@@ -28,7 +28,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
28
28
 
29
29
  void Visit(const Block* stmt) {
30
30
  VALUE hash = rb_hash_new();
31
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("Block"));
31
+ rb_hash_aset(hash, SYM("type"), SYM("Block"));
32
32
  VALUE array = rb_ary_new();
33
33
  for (Statements::const_iterator it = stmt->body().begin(),
34
34
  last = stmt->body().end(); it != last; ++it) {
@@ -42,7 +42,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
42
42
 
43
43
  void Visit(const FunctionStatement* stmt) {
44
44
  VALUE hash = rb_hash_new();
45
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("FunctionStatement"));
45
+ rb_hash_aset(hash, SYM("type"), SYM("FunctionStatement"));
46
46
  Visit(stmt->function());
47
47
  rb_hash_aset(hash, SYM("body"), ret_);
48
48
  SetLocation(hash, stmt);
@@ -51,7 +51,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
51
51
 
52
52
  void Visit(const FunctionDeclaration* decl) {
53
53
  VALUE hash = rb_hash_new();
54
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("FunctionDeclaration"));
54
+ rb_hash_aset(hash, SYM("type"), SYM("FunctionDeclaration"));
55
55
  Visit(decl->function());
56
56
  rb_hash_aset(hash, SYM("body"), ret_);
57
57
  SetLocation(hash, decl);
@@ -60,7 +60,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
60
60
 
61
61
  void Visit(const VariableStatement* stmt) {
62
62
  VALUE hash = rb_hash_new();
63
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("VariableStatement"));
63
+ rb_hash_aset(hash, SYM("type"), SYM("VariableStatement"));
64
64
  rb_hash_aset(hash, SYM("const"), stmt->IsConst() ? Qtrue : Qfalse);
65
65
  VALUE array = rb_ary_new();
66
66
  for (Declarations::const_iterator it = stmt->decls().begin(),
@@ -75,7 +75,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
75
75
 
76
76
  void Visit(const Declaration* decl) {
77
77
  VALUE hash = rb_hash_new();
78
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("Declaration"));
78
+ rb_hash_aset(hash, SYM("type"), SYM("Declaration"));
79
79
  Visit(decl->name());
80
80
  rb_hash_aset(hash, SYM("name"), ret_);
81
81
  if (decl->expr()) {
@@ -88,14 +88,14 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
88
88
 
89
89
  void Visit(const EmptyStatement* stmt) {
90
90
  VALUE hash = rb_hash_new();
91
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("EmptyStatement"));
91
+ rb_hash_aset(hash, SYM("type"), SYM("EmptyStatement"));
92
92
  SetLocation(hash, stmt);
93
93
  ret_ = hash;
94
94
  }
95
95
 
96
96
  void Visit(const IfStatement* stmt) {
97
97
  VALUE hash = rb_hash_new();
98
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("IfStatement"));
98
+ rb_hash_aset(hash, SYM("type"), SYM("IfStatement"));
99
99
  stmt->cond()->Accept(this);
100
100
  rb_hash_aset(hash, SYM("cond"), ret_);
101
101
  stmt->then_statement()->Accept(this);
@@ -110,7 +110,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
110
110
 
111
111
  void Visit(const DoWhileStatement* stmt) {
112
112
  VALUE hash = rb_hash_new();
113
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("DoWhileStatement"));
113
+ rb_hash_aset(hash, SYM("type"), SYM("DoWhileStatement"));
114
114
  stmt->cond()->Accept(this);
115
115
  rb_hash_aset(hash, SYM("cond"), ret_);
116
116
  stmt->body()->Accept(this);
@@ -121,7 +121,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
121
121
 
122
122
  void Visit(const WhileStatement* stmt) {
123
123
  VALUE hash = rb_hash_new();
124
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("WhileStatement"));
124
+ rb_hash_aset(hash, SYM("type"), SYM("WhileStatement"));
125
125
  stmt->cond()->Accept(this);
126
126
  rb_hash_aset(hash, SYM("cond"), ret_);
127
127
  stmt->body()->Accept(this);
@@ -132,7 +132,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
132
132
 
133
133
  void Visit(const ForStatement* stmt) {
134
134
  VALUE hash = rb_hash_new();
135
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("ForStatement"));
135
+ rb_hash_aset(hash, SYM("type"), SYM("ForStatement"));
136
136
  if (stmt->init()) {
137
137
  stmt->init()->Accept(this);
138
138
  rb_hash_aset(hash, SYM("init"), ret_);
@@ -153,7 +153,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
153
153
 
154
154
  void Visit(const ForInStatement* stmt) {
155
155
  VALUE hash = rb_hash_new();
156
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("ForInStatement"));
156
+ rb_hash_aset(hash, SYM("type"), SYM("ForInStatement"));
157
157
  stmt->each()->Accept(this);
158
158
  rb_hash_aset(hash, SYM("each"), ret_);
159
159
  stmt->enumerable()->Accept(this);
@@ -166,7 +166,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
166
166
 
167
167
  void Visit(const ContinueStatement* stmt) {
168
168
  VALUE hash = rb_hash_new();
169
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("ContinueStatement"));
169
+ rb_hash_aset(hash, SYM("type"), SYM("ContinueStatement"));
170
170
  if (stmt->label()) {
171
171
  stmt->label()->Accept(this);
172
172
  rb_hash_aset(hash, SYM("label"), ret_);
@@ -177,7 +177,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
177
177
 
178
178
  void Visit(const BreakStatement* stmt) {
179
179
  VALUE hash = rb_hash_new();
180
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("BreakStatement"));
180
+ rb_hash_aset(hash, SYM("type"), SYM("BreakStatement"));
181
181
  if (stmt->label()) {
182
182
  stmt->label()->Accept(this);
183
183
  rb_hash_aset(hash, SYM("label"), ret_);
@@ -188,7 +188,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
188
188
 
189
189
  void Visit(const ReturnStatement* stmt) {
190
190
  VALUE hash = rb_hash_new();
191
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("ReturnStatement"));
191
+ rb_hash_aset(hash, SYM("type"), SYM("ReturnStatement"));
192
192
  stmt->expr()->Accept(this);
193
193
  rb_hash_aset(hash, SYM("expr"), ret_);
194
194
  SetLocation(hash, stmt);
@@ -197,7 +197,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
197
197
 
198
198
  void Visit(const WithStatement* stmt) {
199
199
  VALUE hash = rb_hash_new();
200
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("WithStatement"));
200
+ rb_hash_aset(hash, SYM("type"), SYM("WithStatement"));
201
201
  stmt->context()->Accept(this);
202
202
  rb_hash_aset(hash, SYM("context"), ret_);
203
203
  stmt->body()->Accept(this);
@@ -208,7 +208,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
208
208
 
209
209
  void Visit(const LabelledStatement* stmt) {
210
210
  VALUE hash = rb_hash_new();
211
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("LabelledStatement"));
211
+ rb_hash_aset(hash, SYM("type"), SYM("LabelledStatement"));
212
212
  stmt->label()->Accept(this);
213
213
  rb_hash_aset(hash, SYM("label"), ret_);
214
214
  stmt->body()->Accept(this);
@@ -219,7 +219,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
219
219
 
220
220
  void Visit(const SwitchStatement* stmt) {
221
221
  VALUE hash = rb_hash_new();
222
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("SwitchStatement"));
222
+ rb_hash_aset(hash, SYM("type"), SYM("SwitchStatement"));
223
223
  stmt->expr()->Accept(this);
224
224
  rb_hash_aset(hash, SYM("cond"), ret_);
225
225
  VALUE array = rb_ary_new();
@@ -235,10 +235,11 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
235
235
 
236
236
  void Visit(const CaseClause* cl) {
237
237
  VALUE hash = rb_hash_new();
238
+ rb_hash_aset(hash, SYM("type"), SYM("CaseClause"));
238
239
  if (cl->IsDefault()) {
239
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("Default"));
240
+ rb_hash_aset(hash, SYM("kind"), SYM("Default"));
240
241
  } else {
241
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("Case"));
242
+ rb_hash_aset(hash, SYM("kind"), SYM("Case"));
242
243
  cl->expr()->Accept(this);
243
244
  rb_hash_aset(hash, SYM("expr"), ret_);
244
245
  }
@@ -255,28 +256,28 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
255
256
 
256
257
  void Visit(const ThrowStatement* stmt) {
257
258
  VALUE hash = rb_hash_new();
258
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("ThrowStatement"));
259
+ rb_hash_aset(hash, SYM("type"), SYM("ThrowStatement"));
259
260
  SetLocation(hash, stmt);
260
261
  ret_ = hash;
261
262
  }
262
263
 
263
264
  void Visit(const TryStatement* stmt) {
264
265
  VALUE hash = rb_hash_new();
265
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("TryStatement"));
266
+ rb_hash_aset(hash, SYM("type"), SYM("TryStatement"));
266
267
  SetLocation(hash, stmt);
267
268
  ret_ = hash;
268
269
  }
269
270
 
270
271
  void Visit(const DebuggerStatement* stmt) {
271
272
  VALUE hash = rb_hash_new();
272
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("DebuggerStatement"));
273
+ rb_hash_aset(hash, SYM("type"), SYM("DebuggerStatement"));
273
274
  SetLocation(hash, stmt);
274
275
  ret_ = hash;
275
276
  }
276
277
 
277
278
  void Visit(const ExpressionStatement* stmt) {
278
279
  VALUE hash = rb_hash_new();
279
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("ExpressionStatement"));
280
+ rb_hash_aset(hash, SYM("type"), SYM("ExpressionStatement"));
280
281
  stmt->expr()->Accept(this);
281
282
  rb_hash_aset(hash, SYM("body"), ret_);
282
283
  SetLocation(hash, stmt);
@@ -285,7 +286,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
285
286
 
286
287
  void Visit(const Assignment* expr) {
287
288
  VALUE hash = rb_hash_new();
288
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("Assignment"));
289
+ rb_hash_aset(hash, SYM("type"), SYM("Assignment"));
289
290
  rb_hash_aset(hash, SYM("op"),
290
291
  rb_str_new_cstr(core::Token::ToString(expr->op())));
291
292
  expr->left()->Accept(this);
@@ -298,7 +299,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
298
299
 
299
300
  void Visit(const BinaryOperation* expr) {
300
301
  VALUE hash = rb_hash_new();
301
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("BinaryOperation"));
302
+ rb_hash_aset(hash, SYM("type"), SYM("BinaryOperation"));
302
303
  rb_hash_aset(hash, SYM("op"),
303
304
  rb_str_new_cstr(core::Token::ToString(expr->op())));
304
305
  expr->left()->Accept(this);
@@ -311,7 +312,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
311
312
 
312
313
  void Visit(const ConditionalExpression* expr) {
313
314
  VALUE hash = rb_hash_new();
314
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("ConditionalExpression"));
315
+ rb_hash_aset(hash, SYM("type"), SYM("ConditionalExpression"));
315
316
  expr->cond()->Accept(this);
316
317
  rb_hash_aset(hash, SYM("cond"), ret_);
317
318
  expr->left()->Accept(this);
@@ -324,7 +325,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
324
325
 
325
326
  void Visit(const UnaryOperation* expr) {
326
327
  VALUE hash = rb_hash_new();
327
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("UnaryOperation"));
328
+ rb_hash_aset(hash, SYM("type"), SYM("UnaryOperation"));
328
329
  rb_hash_aset(hash, SYM("op"),
329
330
  rb_str_new_cstr(core::Token::ToString(expr->op())));
330
331
  expr->expr()->Accept(this);
@@ -335,7 +336,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
335
336
 
336
337
  void Visit(const PostfixExpression* expr) {
337
338
  VALUE hash = rb_hash_new();
338
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("PostfixExpression"));
339
+ rb_hash_aset(hash, SYM("type"), SYM("PostfixExpression"));
339
340
  rb_hash_aset(hash, SYM("op"),
340
341
  rb_str_new_cstr(core::Token::ToString(expr->op())));
341
342
  expr->expr()->Accept(this);
@@ -346,7 +347,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
346
347
 
347
348
  void Visit(const StringLiteral* literal) {
348
349
  VALUE hash = rb_hash_new();
349
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("StringLiteral"));
350
+ rb_hash_aset(hash, SYM("type"), SYM("StringLiteral"));
350
351
  const StringLiteral::value_type& str = literal->value();
351
352
  rb_hash_aset(hash, SYM("value"),
352
353
  Encoding::ConvertToDefaultInternal(
@@ -360,7 +361,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
360
361
 
361
362
  void Visit(const NumberLiteral* literal) {
362
363
  VALUE hash = rb_hash_new();
363
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("NumberLiteral"));
364
+ rb_hash_aset(hash, SYM("type"), SYM("NumberLiteral"));
364
365
  rb_hash_aset(hash, SYM("value"), rb_float_new(literal->value()));
365
366
  SetLocation(hash, literal);
366
367
  ret_ = hash;
@@ -368,8 +369,15 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
368
369
 
369
370
  void Visit(const Identifier* literal) {
370
371
  VALUE hash = rb_hash_new();
371
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("Identifier"));
372
+ rb_hash_aset(hash, SYM("type"), SYM("Identifier"));
372
373
  const Identifier::value_type& str = literal->value();
374
+ if (literal->type() == core::Token::IDENTIFIER) {
375
+ rb_hash_aset(hash, SYM("kind"), SYM("Identifier"));
376
+ } else if (literal->type() == core::Token::NUMBER) {
377
+ rb_hash_aset(hash, SYM("kind"), SYM("Number"));
378
+ } else {
379
+ rb_hash_aset(hash, SYM("kind"), SYM("String"));
380
+ }
373
381
  rb_hash_aset(hash, SYM("value"),
374
382
  Encoding::ConvertToDefaultInternal(
375
383
  rb_enc_str_new(
@@ -382,28 +390,28 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
382
390
 
383
391
  void Visit(const ThisLiteral* literal) {
384
392
  VALUE hash = rb_hash_new();
385
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("ThisLiteral"));
393
+ rb_hash_aset(hash, SYM("type"), SYM("ThisLiteral"));
386
394
  SetLocation(hash, literal);
387
395
  ret_ = hash;
388
396
  }
389
397
 
390
398
  void Visit(const NullLiteral* literal) {
391
399
  VALUE hash = rb_hash_new();
392
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("NullLiteral"));
400
+ rb_hash_aset(hash, SYM("type"), SYM("NullLiteral"));
393
401
  SetLocation(hash, literal);
394
402
  ret_ = hash;
395
403
  }
396
404
 
397
405
  void Visit(const TrueLiteral* literal) {
398
406
  VALUE hash = rb_hash_new();
399
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("TrueLiteral"));
407
+ rb_hash_aset(hash, SYM("type"), SYM("TrueLiteral"));
400
408
  SetLocation(hash, literal);
401
409
  ret_ = hash;
402
410
  }
403
411
 
404
412
  void Visit(const FalseLiteral* literal) {
405
413
  VALUE hash = rb_hash_new();
406
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("FalseLiteral"));
414
+ rb_hash_aset(hash, SYM("type"), SYM("FalseLiteral"));
407
415
  SetLocation(hash, literal);
408
416
  ret_ = hash;
409
417
  }
@@ -411,13 +419,13 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
411
419
  void Visit(const Undefined* literal) {
412
420
  // Undefined has no location
413
421
  VALUE hash = rb_hash_new();
414
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("Undefined"));
422
+ rb_hash_aset(hash, SYM("type"), SYM("Undefined"));
415
423
  ret_ = hash;
416
424
  }
417
425
 
418
426
  void Visit(const RegExpLiteral* literal) {
419
427
  VALUE hash = rb_hash_new();
420
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("RegExpLiteral"));
428
+ rb_hash_aset(hash, SYM("type"), SYM("RegExpLiteral"));
421
429
  const RegExpLiteral::value_type& content = literal->value();
422
430
  rb_hash_aset(hash, SYM("value"),
423
431
  Encoding::ConvertToDefaultInternal(
@@ -438,7 +446,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
438
446
 
439
447
  void Visit(const ArrayLiteral* literal) {
440
448
  VALUE hash = rb_hash_new();
441
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("ArrayLiteral"));
449
+ rb_hash_aset(hash, SYM("type"), SYM("ArrayLiteral"));
442
450
  VALUE array = rb_ary_new();
443
451
  for (Expressions::const_iterator it = literal->items().begin(),
444
452
  last = literal->items().end(); it != last; ++it) {
@@ -453,28 +461,22 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
453
461
  void Visit(const ObjectLiteral* literal) {
454
462
  using std::tr1::get;
455
463
  VALUE hash = rb_hash_new();
456
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("ObjectLiteral"));
464
+ rb_hash_aset(hash, SYM("type"), SYM("ObjectLiteral"));
457
465
  VALUE array = rb_ary_new();
458
466
  for (ObjectLiteral::Properties::const_iterator it = literal->properties().begin(),
459
467
  last = literal->properties().end(); it != last; ++it) {
460
468
  VALUE item = rb_hash_new();
461
469
  switch (get<0>(*it)) {
462
470
  case ObjectLiteral::DATA:
463
- rb_hash_aset(item,
464
- SYM("type"),
465
- rb_str_new_cstr("DataProperty"));
471
+ rb_hash_aset(item, SYM("kind"), SYM("Data"));
466
472
  break;
467
473
 
468
474
  case ObjectLiteral::SET:
469
- rb_hash_aset(item,
470
- SYM("type"),
471
- rb_str_new_cstr("SetterProperty"));
475
+ rb_hash_aset(item, SYM("kind"), SYM("Setter"));
472
476
  break;
473
477
 
474
478
  case ObjectLiteral::GET:
475
- rb_hash_aset(item,
476
- SYM("type"),
477
- rb_str_new_cstr("GetterProperty"));
479
+ rb_hash_aset(item, SYM("kind"), SYM("Getter"));
478
480
  break;
479
481
  }
480
482
  get<1>(*it)->Accept(this);
@@ -494,7 +496,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
494
496
 
495
497
  void Visit(const FunctionLiteral* literal) {
496
498
  VALUE hash = rb_hash_new();
497
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("FunctionLiteral"));
499
+ rb_hash_aset(hash, SYM("type"), SYM("FunctionLiteral"));
498
500
  if (literal->name()) {
499
501
  Visit(literal->name());
500
502
  rb_hash_aset(hash, SYM("name"), ret_);
@@ -523,7 +525,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
523
525
 
524
526
  void Visit(const IndexAccess* expr) {
525
527
  VALUE hash = rb_hash_new();
526
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("IndexAccess"));
528
+ rb_hash_aset(hash, SYM("type"), SYM("IndexAccess"));
527
529
  expr->target()->Accept(this);
528
530
  rb_hash_aset(hash, SYM("target"), ret_);
529
531
  expr->key()->Accept(this);
@@ -534,7 +536,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
534
536
 
535
537
  void Visit(const IdentifierAccess* expr) {
536
538
  VALUE hash = rb_hash_new();
537
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("IdentifierAccess"));
539
+ rb_hash_aset(hash, SYM("type"), SYM("IdentifierAccess"));
538
540
  expr->target()->Accept(this);
539
541
  rb_hash_aset(hash, SYM("target"), ret_);
540
542
  Visit(expr->key());
@@ -545,7 +547,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
545
547
 
546
548
  void Visit(const FunctionCall* call) {
547
549
  VALUE hash = rb_hash_new();
548
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("FunctionCall"));
550
+ rb_hash_aset(hash, SYM("type"), SYM("FunctionCall"));
549
551
  call->target()->Accept(this);
550
552
  rb_hash_aset(hash, SYM("target"), ret_);
551
553
  VALUE args = rb_ary_new();
@@ -561,7 +563,7 @@ class Creator : public iv::core::ast::AstVisitor<AstFactory>::const_type {
561
563
 
562
564
  void Visit(const ConstructorCall* call) {
563
565
  VALUE hash = rb_hash_new();
564
- rb_hash_aset(hash, SYM("type"), rb_str_new_cstr("ConstructorCall"));
566
+ rb_hash_aset(hash, SYM("type"), SYM("ConstructorCall"));
565
567
  call->target()->Accept(this);
566
568
  rb_hash_aset(hash, SYM("target"), ret_);
567
569
  VALUE args = rb_ary_new();
@@ -0,0 +1,58 @@
1
+ // Copyright 2010 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #include "v8.h"
29
+
30
+ #include "diy-fp.h"
31
+
32
+ namespace v8 {
33
+ namespace internal {
34
+
35
+ void DiyFp::Multiply(const DiyFp& other) {
36
+ // Simply "emulates" a 128 bit multiplication.
37
+ // However: the resulting number only contains 64 bits. The least
38
+ // significant 64 bits are only used for rounding the most significant 64
39
+ // bits.
40
+ const uint64_t kM32 = 0xFFFFFFFFu;
41
+ uint64_t a = f_ >> 32;
42
+ uint64_t b = f_ & kM32;
43
+ uint64_t c = other.f_ >> 32;
44
+ uint64_t d = other.f_ & kM32;
45
+ uint64_t ac = a * c;
46
+ uint64_t bc = b * c;
47
+ uint64_t ad = a * d;
48
+ uint64_t bd = b * d;
49
+ uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32);
50
+ // By adding 1U << 31 to tmp we round the final result.
51
+ // Halfway cases will be round up.
52
+ tmp += 1U << 31;
53
+ uint64_t result_f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32);
54
+ e_ += other.e_ + 64;
55
+ f_ = result_f;
56
+ }
57
+
58
+ } } // namespace v8::internal