Mercurial > hg > CbC > CbC_gcc
comparison gcc/go/gofrontend/expressions.h @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
37 class Unsafe_type_conversion_expression; | 37 class Unsafe_type_conversion_expression; |
38 class Unary_expression; | 38 class Unary_expression; |
39 class Binary_expression; | 39 class Binary_expression; |
40 class String_concat_expression; | 40 class String_concat_expression; |
41 class Call_expression; | 41 class Call_expression; |
42 class Builtin_call_expression; | |
42 class Call_result_expression; | 43 class Call_result_expression; |
43 class Func_expression; | 44 class Func_expression; |
44 class Func_descriptor_expression; | 45 class Func_descriptor_expression; |
45 class Unknown_expression; | 46 class Unknown_expression; |
46 class Index_expression; | 47 class Index_expression; |
504 | 505 |
505 // Make a backend expression. | 506 // Make a backend expression. |
506 static Expression* | 507 static Expression* |
507 make_backend(Bexpression*, Type*, Location); | 508 make_backend(Bexpression*, Type*, Location); |
508 | 509 |
510 enum Nil_check_classification | |
511 { | |
512 // Use the default policy for deciding if this deref needs a check. | |
513 NIL_CHECK_DEFAULT, | |
514 // An explicit check is required for this dereference operation. | |
515 NIL_CHECK_NEEDED, | |
516 // No check needed for this dereference operation. | |
517 NIL_CHECK_NOT_NEEDED, | |
518 // A type error or error construct was encountered when determining | |
519 // whether this deref needs an explicit check. | |
520 NIL_CHECK_ERROR_ENCOUNTERED | |
521 }; | |
522 | |
523 // Make a dereference expression. | |
524 static Expression* | |
525 make_dereference(Expression*, Nil_check_classification, Location); | |
526 | |
509 // Return the expression classification. | 527 // Return the expression classification. |
510 Expression_classification | 528 Expression_classification |
511 classification() const | 529 classification() const |
512 { return this->classification_; } | 530 { return this->classification_; } |
513 | 531 |
849 | 867 |
850 // Return true if this is a reference to a local variable. | 868 // Return true if this is a reference to a local variable. |
851 bool | 869 bool |
852 is_local_variable() const; | 870 is_local_variable() const; |
853 | 871 |
872 // Return true if two expressions refer to the same variable or | |
873 // struct field. | |
874 static bool | |
875 is_same_variable(Expression*, Expression*); | |
876 | |
854 // Make the builtin function descriptor type, so that it can be | 877 // Make the builtin function descriptor type, so that it can be |
855 // converted. | 878 // converted. |
856 static void | 879 static void |
857 make_func_descriptor_type(); | 880 make_func_descriptor_type(); |
858 | 881 |
1296 class Var_expression : public Expression | 1319 class Var_expression : public Expression |
1297 { | 1320 { |
1298 public: | 1321 public: |
1299 Var_expression(Named_object* variable, Location location) | 1322 Var_expression(Named_object* variable, Location location) |
1300 : Expression(EXPRESSION_VAR_REFERENCE, location), | 1323 : Expression(EXPRESSION_VAR_REFERENCE, location), |
1301 variable_(variable), in_lvalue_pos_(VE_rvalue) | 1324 variable_(variable) |
1302 { } | 1325 { } |
1303 | 1326 |
1304 // Return the variable. | 1327 // Return the variable. |
1305 Named_object* | 1328 Named_object* |
1306 named_object() const | 1329 named_object() const |
1307 { return this->variable_; } | 1330 { return this->variable_; } |
1308 | 1331 |
1309 // Does this var expression appear in an lvalue (assigned-to) context? | |
1310 bool | |
1311 in_lvalue_pos() const | |
1312 { return this->in_lvalue_pos_ == VE_lvalue; } | |
1313 | |
1314 // Mark a var_expression as appearing in an lvalue context. | |
1315 void | |
1316 set_in_lvalue_pos() | |
1317 { this->in_lvalue_pos_ = VE_lvalue; } | |
1318 | |
1319 protected: | 1332 protected: |
1320 Expression* | 1333 Expression* |
1321 do_lower(Gogo*, Named_object*, Statement_inserter*, int); | 1334 do_lower(Gogo*, Named_object*, Statement_inserter*, int); |
1322 | 1335 |
1323 Type* | 1336 Type* |
1344 do_dump_expression(Ast_dump_context*) const; | 1357 do_dump_expression(Ast_dump_context*) const; |
1345 | 1358 |
1346 private: | 1359 private: |
1347 // The variable we are referencing. | 1360 // The variable we are referencing. |
1348 Named_object* variable_; | 1361 Named_object* variable_; |
1349 // Set to TRUE if var expression appears in lvalue context | |
1350 Varexpr_context in_lvalue_pos_; | |
1351 }; | 1362 }; |
1352 | 1363 |
1353 // A reference to a variable within an enclosing function. | 1364 // A reference to a variable within an enclosing function. |
1354 | 1365 |
1355 class Enclosed_var_expression : public Expression | 1366 class Enclosed_var_expression : public Expression |
1656 | 1667 |
1657 void | 1668 void |
1658 do_check_types(Gogo*); | 1669 do_check_types(Gogo*); |
1659 | 1670 |
1660 Expression* | 1671 Expression* |
1661 do_copy() | 1672 do_copy(); |
1662 { | |
1663 return new Type_conversion_expression(this->type_, this->expr_->copy(), | |
1664 this->location()); | |
1665 } | |
1666 | 1673 |
1667 Bexpression* | 1674 Bexpression* |
1668 do_get_backend(Translate_context* context); | 1675 do_get_backend(Translate_context* context); |
1669 | 1676 |
1670 void | 1677 void |
1712 void | 1719 void |
1713 do_determine_type(const Type_context*) | 1720 do_determine_type(const Type_context*) |
1714 { this->expr_->determine_type_no_context(); } | 1721 { this->expr_->determine_type_no_context(); } |
1715 | 1722 |
1716 Expression* | 1723 Expression* |
1717 do_copy() | 1724 do_copy(); |
1718 { | |
1719 return new Unsafe_type_conversion_expression(this->type_, | |
1720 this->expr_->copy(), | |
1721 this->location()); | |
1722 } | |
1723 | 1725 |
1724 Bexpression* | 1726 Bexpression* |
1725 do_get_backend(Translate_context*); | 1727 do_get_backend(Translate_context*); |
1726 | 1728 |
1727 void | 1729 void |
1740 { | 1742 { |
1741 public: | 1743 public: |
1742 Unary_expression(Operator op, Expression* expr, Location location) | 1744 Unary_expression(Operator op, Expression* expr, Location location) |
1743 : Expression(EXPRESSION_UNARY, location), | 1745 : Expression(EXPRESSION_UNARY, location), |
1744 op_(op), escapes_(true), create_temp_(false), is_gc_root_(false), | 1746 op_(op), escapes_(true), create_temp_(false), is_gc_root_(false), |
1745 is_slice_init_(false), expr_(expr), issue_nil_check_(false) | 1747 is_slice_init_(false), expr_(expr), |
1748 issue_nil_check_(NIL_CHECK_DEFAULT) | |
1746 { } | 1749 { } |
1747 | 1750 |
1748 // Return the operator. | 1751 // Return the operator. |
1749 Operator | 1752 Operator |
1750 op() const | 1753 op() const |
1802 Location, Numeric_constant* nc, bool *issued_error); | 1805 Location, Numeric_constant* nc, bool *issued_error); |
1803 | 1806 |
1804 static Expression* | 1807 static Expression* |
1805 do_import(Import*); | 1808 do_import(Import*); |
1806 | 1809 |
1810 // Declare that this deref does or does not require an explicit nil check. | |
1811 void | |
1812 set_requires_nil_check(bool needed) | |
1813 { | |
1814 go_assert(this->op_ == OPERATOR_MULT); | |
1815 if (needed) | |
1816 this->issue_nil_check_ = NIL_CHECK_NEEDED; | |
1817 else | |
1818 this->issue_nil_check_ = NIL_CHECK_NOT_NEEDED; | |
1819 } | |
1820 | |
1807 protected: | 1821 protected: |
1808 int | 1822 int |
1809 do_traverse(Traverse* traverse) | 1823 do_traverse(Traverse* traverse) |
1810 { return Expression::traverse(&this->expr_, traverse); } | 1824 { return Expression::traverse(&this->expr_, traverse); } |
1811 | 1825 |
1857 void | 1871 void |
1858 do_dump_expression(Ast_dump_context*) const; | 1872 do_dump_expression(Ast_dump_context*) const; |
1859 | 1873 |
1860 void | 1874 void |
1861 do_issue_nil_check() | 1875 do_issue_nil_check() |
1862 { this->issue_nil_check_ = (this->op_ == OPERATOR_MULT); } | 1876 { |
1877 if (this->op_ == OPERATOR_MULT) | |
1878 this->set_requires_nil_check(true); | |
1879 } | |
1863 | 1880 |
1864 private: | 1881 private: |
1865 static bool | 1882 static bool |
1866 base_is_static_initializer(Expression*); | 1883 base_is_static_initializer(Expression*); |
1884 | |
1885 // Return a determination as to whether this dereference expression | |
1886 // requires a nil check. | |
1887 Nil_check_classification | |
1888 requires_nil_check(Gogo*); | |
1867 | 1889 |
1868 // The unary operator to apply. | 1890 // The unary operator to apply. |
1869 Operator op_; | 1891 Operator op_; |
1870 // Normally true. False if this is an address expression which does | 1892 // Normally true. False if this is an address expression which does |
1871 // not escape the current function. | 1893 // not escape the current function. |
1884 bool is_slice_init_; | 1906 bool is_slice_init_; |
1885 // The operand. | 1907 // The operand. |
1886 Expression* expr_; | 1908 Expression* expr_; |
1887 // Whether or not to issue a nil check for this expression if its address | 1909 // Whether or not to issue a nil check for this expression if its address |
1888 // is being taken. | 1910 // is being taken. |
1889 bool issue_nil_check_; | 1911 Nil_check_classification issue_nil_check_; |
1890 }; | 1912 }; |
1891 | 1913 |
1892 // A binary expression. | 1914 // A binary expression. |
1893 | 1915 |
1894 class Binary_expression : public Expression | 1916 class Binary_expression : public Expression |
2218 | 2240 |
2219 // Note this call is used as a multi-valued argument. | 2241 // Note this call is used as a multi-valued argument. |
2220 void | 2242 void |
2221 set_is_multi_value_arg() | 2243 set_is_multi_value_arg() |
2222 { this->is_multi_value_arg_ = true; } | 2244 { this->is_multi_value_arg_ = true; } |
2245 | |
2246 // Whether this is a call to builtin function. | |
2247 virtual bool | |
2248 is_builtin() | |
2249 { return false; } | |
2250 | |
2251 // Convert to a Builtin_call_expression, or return NULL. | |
2252 inline Builtin_call_expression* | |
2253 builtin_call_expression(); | |
2223 | 2254 |
2224 protected: | 2255 protected: |
2225 int | 2256 int |
2226 do_traverse(Traverse*); | 2257 do_traverse(Traverse*); |
2227 | 2258 |
2324 bool is_multi_value_arg_; | 2355 bool is_multi_value_arg_; |
2325 // True if this expression has already been flattened. | 2356 // True if this expression has already been flattened. |
2326 bool is_flattened_; | 2357 bool is_flattened_; |
2327 }; | 2358 }; |
2328 | 2359 |
2360 // A call expression to a builtin function. | |
2361 | |
2362 class Builtin_call_expression : public Call_expression | |
2363 { | |
2364 public: | |
2365 Builtin_call_expression(Gogo* gogo, Expression* fn, Expression_list* args, | |
2366 bool is_varargs, Location location); | |
2367 | |
2368 // The builtin functions. | |
2369 enum Builtin_function_code | |
2370 { | |
2371 BUILTIN_INVALID, | |
2372 | |
2373 // Predeclared builtin functions. | |
2374 BUILTIN_APPEND, | |
2375 BUILTIN_CAP, | |
2376 BUILTIN_CLOSE, | |
2377 BUILTIN_COMPLEX, | |
2378 BUILTIN_COPY, | |
2379 BUILTIN_DELETE, | |
2380 BUILTIN_IMAG, | |
2381 BUILTIN_LEN, | |
2382 BUILTIN_MAKE, | |
2383 BUILTIN_NEW, | |
2384 BUILTIN_PANIC, | |
2385 BUILTIN_PRINT, | |
2386 BUILTIN_PRINTLN, | |
2387 BUILTIN_REAL, | |
2388 BUILTIN_RECOVER, | |
2389 | |
2390 // Builtin functions from the unsafe package. | |
2391 BUILTIN_ALIGNOF, | |
2392 BUILTIN_OFFSETOF, | |
2393 BUILTIN_SIZEOF | |
2394 }; | |
2395 | |
2396 Builtin_function_code | |
2397 code() | |
2398 { return this->code_; } | |
2399 | |
2400 // This overrides Call_expression::is_builtin. | |
2401 bool | |
2402 is_builtin() | |
2403 { return true; } | |
2404 | |
2405 // Return whether EXPR, of array type, is a constant if passed to | |
2406 // len or cap. | |
2407 static bool | |
2408 array_len_is_constant(Expression* expr); | |
2409 | |
2410 Expression* | |
2411 flatten_append(Gogo*, Named_object*, Statement_inserter*, Expression*, | |
2412 Block*); | |
2413 | |
2414 protected: | |
2415 // This overrides Call_expression::do_lower. | |
2416 Expression* | |
2417 do_lower(Gogo*, Named_object*, Statement_inserter*, int); | |
2418 | |
2419 Expression* | |
2420 do_flatten(Gogo*, Named_object*, Statement_inserter*); | |
2421 | |
2422 bool | |
2423 do_is_constant() const; | |
2424 | |
2425 bool | |
2426 do_numeric_constant_value(Numeric_constant*) const; | |
2427 | |
2428 bool | |
2429 do_discarding_value(); | |
2430 | |
2431 Type* | |
2432 do_type(); | |
2433 | |
2434 void | |
2435 do_determine_type(const Type_context*); | |
2436 | |
2437 void | |
2438 do_check_types(Gogo*); | |
2439 | |
2440 Expression* | |
2441 do_copy(); | |
2442 | |
2443 Bexpression* | |
2444 do_get_backend(Translate_context*); | |
2445 | |
2446 void | |
2447 do_export(Export*) const; | |
2448 | |
2449 virtual bool | |
2450 do_is_recover_call() const; | |
2451 | |
2452 virtual void | |
2453 do_set_recover_arg(Expression*); | |
2454 | |
2455 private: | |
2456 Expression* | |
2457 one_arg() const; | |
2458 | |
2459 bool | |
2460 check_one_arg(); | |
2461 | |
2462 static Type* | |
2463 real_imag_type(Type*); | |
2464 | |
2465 static Type* | |
2466 complex_type(Type*); | |
2467 | |
2468 Expression* | |
2469 lower_make(Statement_inserter*); | |
2470 | |
2471 bool | |
2472 check_int_value(Expression*, bool is_length, bool* small); | |
2473 | |
2474 // A pointer back to the general IR structure. This avoids a global | |
2475 // variable, or passing it around everywhere. | |
2476 Gogo* gogo_; | |
2477 // The builtin function being called. | |
2478 Builtin_function_code code_; | |
2479 // Used to stop endless loops when the length of an array uses len | |
2480 // or cap of the array itself. | |
2481 mutable bool seen_; | |
2482 // Whether the argument is set for calls to BUILTIN_RECOVER. | |
2483 bool recover_arg_is_set_; | |
2484 }; | |
2485 | |
2486 inline Builtin_call_expression* | |
2487 Call_expression::builtin_call_expression() | |
2488 { | |
2489 return (this->is_builtin() | |
2490 ? static_cast<Builtin_call_expression*>(this) | |
2491 : NULL); | |
2492 } | |
2493 | |
2329 // A single result from a call which returns multiple results. | 2494 // A single result from a call which returns multiple results. |
2330 | 2495 |
2331 class Call_result_expression : public Expression | 2496 class Call_result_expression : public Expression |
2332 { | 2497 { |
2333 public: | 2498 public: |
2611 ? NULL | 2776 ? NULL |
2612 : this->cap_->copy()), | 2777 : this->cap_->copy()), |
2613 this->location()); | 2778 this->location()); |
2614 } | 2779 } |
2615 | 2780 |
2616 bool | 2781 // This shouldn't be called--we don't know yet. |
2617 do_must_eval_subexpressions_in_order(int* skip) const | 2782 bool |
2618 { | 2783 do_must_eval_subexpressions_in_order(int*) const |
2619 *skip = 1; | 2784 { go_unreachable(); } |
2620 return true; | |
2621 } | |
2622 | 2785 |
2623 void | 2786 void |
2624 do_dump_expression(Ast_dump_context*) const; | 2787 do_dump_expression(Ast_dump_context*) const; |
2625 | 2788 |
2626 void | 2789 void |
2722 : this->cap_->copy()), | 2885 : this->cap_->copy()), |
2723 this->location()); | 2886 this->location()); |
2724 } | 2887 } |
2725 | 2888 |
2726 bool | 2889 bool |
2727 do_must_eval_subexpressions_in_order(int* skip) const | 2890 do_must_eval_subexpressions_in_order(int* skip) const; |
2728 { | |
2729 *skip = 1; | |
2730 return true; | |
2731 } | |
2732 | 2891 |
2733 bool | 2892 bool |
2734 do_is_addressable() const; | 2893 do_is_addressable() const; |
2735 | 2894 |
2736 void | 2895 void |
2737 do_address_taken(bool escapes) | 2896 do_address_taken(bool escapes); |
2738 { this->array_->address_taken(escapes); } | |
2739 | 2897 |
2740 void | 2898 void |
2741 do_issue_nil_check() | 2899 do_issue_nil_check() |
2742 { this->array_->issue_nil_check(); } | 2900 { this->array_->issue_nil_check(); } |
2743 | 2901 |
2806 : this->end_->copy()), | 2964 : this->end_->copy()), |
2807 this->location()); | 2965 this->location()); |
2808 } | 2966 } |
2809 | 2967 |
2810 bool | 2968 bool |
2811 do_must_eval_subexpressions_in_order(int* skip) const | 2969 do_must_eval_subexpressions_in_order(int*) const |
2812 { | 2970 { return true; } |
2813 *skip = 1; | |
2814 return true; | |
2815 } | |
2816 | 2971 |
2817 Bexpression* | 2972 Bexpression* |
2818 do_get_backend(Translate_context*); | 2973 do_get_backend(Translate_context*); |
2819 | 2974 |
2820 void | 2975 void |
2893 this->index_->copy(), | 3048 this->index_->copy(), |
2894 this->location()); | 3049 this->location()); |
2895 } | 3050 } |
2896 | 3051 |
2897 bool | 3052 bool |
2898 do_must_eval_subexpressions_in_order(int* skip) const | 3053 do_must_eval_subexpressions_in_order(int*) const |
2899 { | 3054 { return true; } |
2900 *skip = 1; | |
2901 return true; | |
2902 } | |
2903 | 3055 |
2904 // A map index expression is an lvalue but it is not addressable. | 3056 // A map index expression is an lvalue but it is not addressable. |
2905 | 3057 |
2906 Bexpression* | 3058 Bexpression* |
2907 do_get_backend(Translate_context*); | 3059 do_get_backend(Translate_context*); |
3262 | 3414 |
3263 Expression* | 3415 Expression* |
3264 do_lower(Gogo*, Named_object*, Statement_inserter*, int); | 3416 do_lower(Gogo*, Named_object*, Statement_inserter*, int); |
3265 | 3417 |
3266 Expression* | 3418 Expression* |
3267 do_copy() | 3419 do_copy(); |
3268 { | |
3269 Composite_literal_expression *ret = | |
3270 new Composite_literal_expression(this->type_, this->depth_, | |
3271 this->has_keys_, | |
3272 (this->vals_ == NULL | |
3273 ? NULL | |
3274 : this->vals_->copy()), | |
3275 this->all_are_names_, | |
3276 this->location()); | |
3277 ret->key_path_ = this->key_path_; | |
3278 return ret; | |
3279 } | |
3280 | 3420 |
3281 void | 3421 void |
3282 do_dump_expression(Ast_dump_context*) const; | 3422 do_dump_expression(Ast_dump_context*) const; |
3283 | 3423 |
3284 private: | 3424 private: |
3388 | 3528 |
3389 void | 3529 void |
3390 do_check_types(Gogo*); | 3530 do_check_types(Gogo*); |
3391 | 3531 |
3392 Expression* | 3532 Expression* |
3393 do_copy() | 3533 do_copy(); |
3394 { | |
3395 Struct_construction_expression* ret = | |
3396 new Struct_construction_expression(this->type_, | |
3397 (this->vals() == NULL | |
3398 ? NULL | |
3399 : this->vals()->copy()), | |
3400 this->location()); | |
3401 if (this->traverse_order() != NULL) | |
3402 ret->set_traverse_order(this->traverse_order()); | |
3403 return ret; | |
3404 } | |
3405 | 3534 |
3406 Expression* | 3535 Expression* |
3407 do_flatten(Gogo*, Named_object*, Statement_inserter*); | 3536 do_flatten(Gogo*, Named_object*, Statement_inserter*); |
3408 | 3537 |
3409 Bexpression* | 3538 Bexpression* |
3503 const std::vector<unsigned long>* indexes, | 3632 const std::vector<unsigned long>* indexes, |
3504 Expression_list* vals, Location location); | 3633 Expression_list* vals, Location location); |
3505 | 3634 |
3506 protected: | 3635 protected: |
3507 Expression* | 3636 Expression* |
3508 do_copy() | 3637 do_copy(); |
3509 { | |
3510 return new Fixed_array_construction_expression(this->type(), | |
3511 this->indexes(), | |
3512 (this->vals() == NULL | |
3513 ? NULL | |
3514 : this->vals()->copy()), | |
3515 this->location()); | |
3516 } | |
3517 | 3638 |
3518 Bexpression* | 3639 Bexpression* |
3519 do_get_backend(Translate_context*); | 3640 do_get_backend(Translate_context*); |
3520 }; | 3641 }; |
3521 | 3642 |
3544 | 3665 |
3545 int | 3666 int |
3546 do_traverse(Traverse* traverse); | 3667 do_traverse(Traverse* traverse); |
3547 | 3668 |
3548 Expression* | 3669 Expression* |
3549 do_copy() | 3670 do_copy(); |
3550 { | |
3551 return new Slice_construction_expression(this->type(), this->indexes(), | |
3552 (this->vals() == NULL | |
3553 ? NULL | |
3554 : this->vals()->copy()), | |
3555 this->location()); | |
3556 } | |
3557 | 3671 |
3558 Bexpression* | 3672 Bexpression* |
3559 do_get_backend(Translate_context*); | 3673 do_get_backend(Translate_context*); |
3560 | 3674 |
3561 void | 3675 void |
3610 | 3724 |
3611 void | 3725 void |
3612 do_check_types(Gogo*); | 3726 do_check_types(Gogo*); |
3613 | 3727 |
3614 Expression* | 3728 Expression* |
3615 do_copy() | 3729 do_copy(); |
3616 { | |
3617 return new Map_construction_expression(this->type_, | |
3618 (this->vals_ == NULL | |
3619 ? NULL | |
3620 : this->vals_->copy()), | |
3621 this->location()); | |
3622 } | |
3623 | 3730 |
3624 Bexpression* | 3731 Bexpression* |
3625 do_get_backend(Translate_context*); | 3732 do_get_backend(Translate_context*); |
3626 | 3733 |
3627 void | 3734 void |
3678 | 3785 |
3679 void | 3786 void |
3680 do_check_types(Gogo*); | 3787 do_check_types(Gogo*); |
3681 | 3788 |
3682 Expression* | 3789 Expression* |
3683 do_copy() | 3790 do_copy(); |
3684 { | |
3685 return new Type_guard_expression(this->expr_->copy(), this->type_, | |
3686 this->location()); | |
3687 } | |
3688 | 3791 |
3689 Bexpression* | 3792 Bexpression* |
3690 do_get_backend(Translate_context*); | 3793 do_get_backend(Translate_context*); |
3691 | 3794 |
3692 void | 3795 void |
3707 class Heap_expression : public Expression | 3810 class Heap_expression : public Expression |
3708 { | 3811 { |
3709 public: | 3812 public: |
3710 Heap_expression(Expression* expr, Location location) | 3813 Heap_expression(Expression* expr, Location location) |
3711 : Expression(EXPRESSION_HEAP, location), | 3814 : Expression(EXPRESSION_HEAP, location), |
3712 expr_(expr) | 3815 expr_(expr), allocate_on_stack_(false) |
3713 { } | 3816 { } |
3714 | 3817 |
3715 Expression* | 3818 Expression* |
3716 expr() const | 3819 expr() const |
3717 { return this->expr_; } | 3820 { return this->expr_; } |
3821 | |
3822 void | |
3823 set_allocate_on_stack() | |
3824 { this->allocate_on_stack_ = true; } | |
3718 | 3825 |
3719 protected: | 3826 protected: |
3720 int | 3827 int |
3721 do_traverse(Traverse* traverse) | 3828 do_traverse(Traverse* traverse) |
3722 { return Expression::traverse(&this->expr_, traverse); } | 3829 { return Expression::traverse(&this->expr_, traverse); } |
3747 do_dump_expression(Ast_dump_context*) const; | 3854 do_dump_expression(Ast_dump_context*) const; |
3748 | 3855 |
3749 private: | 3856 private: |
3750 // The expression which is being put on the heap. | 3857 // The expression which is being put on the heap. |
3751 Expression* expr_; | 3858 Expression* expr_; |
3859 // Whether or not this is a stack allocation. | |
3860 bool allocate_on_stack_; | |
3752 }; | 3861 }; |
3753 | 3862 |
3754 // A receive expression. | 3863 // A receive expression. |
3755 | 3864 |
3756 class Receive_expression : public Expression | 3865 class Receive_expression : public Expression |
3928 void | 4037 void |
3929 do_determine_type(const Type_context*) | 4038 do_determine_type(const Type_context*) |
3930 { } | 4039 { } |
3931 | 4040 |
3932 Expression* | 4041 Expression* |
3933 do_copy() | 4042 do_copy(); |
3934 { | |
3935 return new Backend_expression(this->bexpr_, this->type_, this->location()); | |
3936 } | |
3937 | 4043 |
3938 Bexpression* | 4044 Bexpression* |
3939 do_get_backend(Translate_context*) | 4045 do_get_backend(Translate_context*) |
3940 { return this->bexpr_; } | 4046 { return this->bexpr_; } |
3941 | 4047 |
4106 bool | 4212 bool |
4107 check_float_type(Float_type*, bool, Location); | 4213 check_float_type(Float_type*, bool, Location); |
4108 | 4214 |
4109 bool | 4215 bool |
4110 check_complex_type(Complex_type*, bool, Location); | 4216 check_complex_type(Complex_type*, bool, Location); |
4217 | |
4218 static bool | |
4219 is_float_neg_zero(const mpfr_t, int bits); | |
4111 | 4220 |
4112 // The kinds of constants. | 4221 // The kinds of constants. |
4113 enum Classification | 4222 enum Classification |
4114 { | 4223 { |
4115 NC_INVALID, | 4224 NC_INVALID, |