Skip to content

Commit 364d13f

Browse files
committed
Declaration lookup and lookup of function return name.
1 parent b930fe7 commit 364d13f

File tree

8 files changed

+809
-579
lines changed

8 files changed

+809
-579
lines changed

regression-tests/pure2-autodiff-higher-order.cpp2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ ad_test: @autodiff<"order=6"> @print type = {
5252
r = x + x * y;
5353
}
5454

55-
func: (x: double, y: double) -> (r: double) = {
56-
r = x + y;
55+
func: (x: double, y: double) -> (ret: double) = {
56+
ret = x + y;
5757
}
5858

5959
func_call: (x: double, y: double) -> (r: double) = {

regression-tests/pure2-autodiff.cpp2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ ad_test: @autodiff @print type = {
4949
r = x + x * y;
5050
}
5151

52-
func: (x: double, y: double) -> (r: double) = {
53-
r = x + y;
52+
func: (x: double, y: double) -> (ret: double) = {
53+
ret = x + y;
5454
}
5555

5656
func_call: (x: double, y: double) -> (r: double) = {

regression-tests/test-results/pure2-autodiff-higher-order.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ struct add_mul_d_ret { double r; cpp2::taylor<double,6> r_d; };
199199

200200
public: [[nodiscard]] static auto add_mul_d(cpp2::impl::in<double> x, cpp2::impl::in<cpp2::taylor<double,6>> x_d, cpp2::impl::in<double> y, cpp2::impl::in<cpp2::taylor<double,6>> y_d) -> add_mul_d_ret;
201201

202-
struct func_d_ret { double r; cpp2::taylor<double,6> r_d; };
202+
struct func_d_ret { double ret; cpp2::taylor<double,6> ret_d; };
203203

204204
public: [[nodiscard]] static auto func_d(cpp2::impl::in<double> x, cpp2::impl::in<cpp2::taylor<double,6>> x_d, cpp2::impl::in<double> y, cpp2::impl::in<cpp2::taylor<double,6>> y_d) -> func_d_ret;
205205

@@ -358,10 +358,10 @@ auto main() -> int;
358358

359359
#line 55 "pure2-autodiff-higher-order.cpp2"
360360
[[nodiscard]] auto ad_test::func(cpp2::impl::in<double> x, cpp2::impl::in<double> y) -> func_ret{
361-
cpp2::impl::deferred_init<double> r;
361+
cpp2::impl::deferred_init<double> ret;
362362
#line 56 "pure2-autodiff-higher-order.cpp2"
363-
r.construct(x + y);
364-
return std::move(r.value()); }
363+
ret.construct(x + y);
364+
return std::move(ret.value()); }
365365

366366
#line 59 "pure2-autodiff-higher-order.cpp2"
367367
[[nodiscard]] auto ad_test::func_call(cpp2::impl::in<double> x, cpp2::impl::in<double> y) -> func_call_ret{
@@ -597,20 +597,20 @@ auto temp_1_d {CPP2_UFCS(mul)(x_d, y_d, x, y)};
597597
}
598598

599599
[[nodiscard]] auto ad_test::func_d(cpp2::impl::in<double> x, cpp2::impl::in<cpp2::taylor<double,6>> x_d, cpp2::impl::in<double> y, cpp2::impl::in<cpp2::taylor<double,6>> y_d) -> func_d_ret{
600-
double r {0.0};
601-
cpp2::taylor<double,6> r_d {0.0};r_d = x_d + y_d;
602-
r = x + y;
603-
return { std::move(r), std::move(r_d) };
600+
double ret {0.0};
601+
cpp2::taylor<double,6> ret_d {0.0};ret_d = x_d + y_d;
602+
ret = x + y;
603+
return { std::move(ret), std::move(ret_d) };
604604
}
605605

606606
[[nodiscard]] auto ad_test::func_call_d(cpp2::impl::in<double> x, cpp2::impl::in<cpp2::taylor<double,6>> x_d, cpp2::impl::in<double> y, cpp2::impl::in<cpp2::taylor<double,6>> y_d) -> func_call_d_ret{
607607
double r {0.0};
608608
cpp2::taylor<double,6> r_d {0.0};
609609
auto temp_2 {func_d(x, x_d, y, y_d)};
610610

611-
auto temp_1 {temp_2.r};
611+
auto temp_1 {temp_2.ret};
612612

613-
auto temp_1_d {cpp2::move(temp_2).r_d};
613+
auto temp_1_d {cpp2::move(temp_2).ret_d};
614614
r_d = CPP2_UFCS(mul)(x_d, cpp2::move(temp_1_d), x, temp_1);
615615
r = x * cpp2::move(temp_1);
616616
return { std::move(r), std::move(r_d) };

regression-tests/test-results/pure2-autodiff-higher-order.cpp2.output

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ ad_test:/* @autodiff<"order=6"> @print */ type =
113113
func:(
114114
in x: double,
115115
in y: double,
116-
) -> (out r: double, ) =
116+
) -> (out ret: double, ) =
117117
{
118-
r = x + y;
118+
ret = x + y;
119119
return;
120120
}
121121

@@ -473,12 +473,12 @@ ad_test:/* @autodiff<"order=6"> @print */ type =
473473
in y: double,
474474
in y_d: cpp2::taylor<double, 6>,
475475
) -> (
476-
out r: double = 0.0,
477-
out r_d: cpp2::taylor<double, 6> = 0.0,
476+
out ret: double = 0.0,
477+
out ret_d: cpp2::taylor<double, 6> = 0.0,
478478
) =
479479
{
480-
r_d = x_d + y_d;
481-
r = x + y;
480+
ret_d = x_d + y_d;
481+
ret = x + y;
482482
return;
483483
}
484484

@@ -493,8 +493,8 @@ ad_test:/* @autodiff<"order=6"> @print */ type =
493493
) =
494494
{
495495
temp_2: _ = func_d(x, x_d, y, y_d);
496-
temp_1: _ = temp_2.r;
497-
temp_1_d: _ = temp_2.r_d;
496+
temp_1: _ = temp_2.ret;
497+
temp_1_d: _ = temp_2.ret_d;
498498
r_d = x_d.mul(temp_1_d, x, temp_1);
499499
r = x * temp_1;
500500
return;

regression-tests/test-results/pure2-autodiff.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ struct add_mul_d_ret { double r; double r_d; };
198198

199199
public: [[nodiscard]] static auto add_mul_d(cpp2::impl::in<double> x, cpp2::impl::in<double> x_d, cpp2::impl::in<double> y, cpp2::impl::in<double> y_d) -> add_mul_d_ret;
200200

201-
struct func_d_ret { double r; double r_d; };
201+
struct func_d_ret { double ret; double ret_d; };
202202

203203
public: [[nodiscard]] static auto func_d(cpp2::impl::in<double> x, cpp2::impl::in<double> x_d, cpp2::impl::in<double> y, cpp2::impl::in<double> y_d) -> func_d_ret;
204204

@@ -383,10 +383,10 @@ auto main() -> int;
383383

384384
#line 52 "pure2-autodiff.cpp2"
385385
[[nodiscard]] auto ad_test::func(cpp2::impl::in<double> x, cpp2::impl::in<double> y) -> func_ret{
386-
cpp2::impl::deferred_init<double> r;
386+
cpp2::impl::deferred_init<double> ret;
387387
#line 53 "pure2-autodiff.cpp2"
388-
r.construct(x + y);
389-
return std::move(r.value()); }
388+
ret.construct(x + y);
389+
return std::move(ret.value()); }
390390

391391
#line 56 "pure2-autodiff.cpp2"
392392
[[nodiscard]] auto ad_test::func_call(cpp2::impl::in<double> x, cpp2::impl::in<double> y) -> func_call_ret{
@@ -622,20 +622,20 @@ auto temp_1_d {x * y_d + y * x_d};
622622
}
623623

624624
[[nodiscard]] auto ad_test::func_d(cpp2::impl::in<double> x, cpp2::impl::in<double> x_d, cpp2::impl::in<double> y, cpp2::impl::in<double> y_d) -> func_d_ret{
625-
double r {0.0};
626-
double r_d {0.0};r_d = x_d + y_d;
627-
r = x + y;
628-
return { std::move(r), std::move(r_d) };
625+
double ret {0.0};
626+
double ret_d {0.0};ret_d = x_d + y_d;
627+
ret = x + y;
628+
return { std::move(ret), std::move(ret_d) };
629629
}
630630

631631
[[nodiscard]] auto ad_test::func_call_d(cpp2::impl::in<double> x, cpp2::impl::in<double> x_d, cpp2::impl::in<double> y, cpp2::impl::in<double> y_d) -> func_call_d_ret{
632632
double r {0.0};
633633
double r_d {0.0};
634634
auto temp_2 {func_d(x, x_d, y, y_d)};
635635

636-
auto temp_1 {temp_2.r};
636+
auto temp_1 {temp_2.ret};
637637

638-
auto temp_1_d {cpp2::move(temp_2).r_d};
638+
auto temp_1_d {cpp2::move(temp_2).ret_d};
639639
r_d = x * cpp2::move(temp_1_d) + temp_1 * x_d;
640640
r = x * cpp2::move(temp_1);
641641
return { std::move(r), std::move(r_d) };

regression-tests/test-results/pure2-autodiff.cpp2.output

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ ad_test:/* @autodiff @print */ type =
113113
func:(
114114
in x: double,
115115
in y: double,
116-
) -> (out r: double, ) =
116+
) -> (out ret: double, ) =
117117
{
118-
r = x + y;
118+
ret = x + y;
119119
return;
120120
}
121121

@@ -473,12 +473,12 @@ ad_test:/* @autodiff @print */ type =
473473
in y: double,
474474
in y_d: double,
475475
) -> (
476-
out r: double = 0.0,
477-
out r_d: double = 0.0,
476+
out ret: double = 0.0,
477+
out ret_d: double = 0.0,
478478
) =
479479
{
480-
r_d = x_d + y_d;
481-
r = x + y;
480+
ret_d = x_d + y_d;
481+
ret = x + y;
482482
return;
483483
}
484484

@@ -493,8 +493,8 @@ ad_test:/* @autodiff @print */ type =
493493
) =
494494
{
495495
temp_2: _ = func_d(x, x_d, y, y_d);
496-
temp_1: _ = temp_2.r;
497-
temp_1_d: _ = temp_2.r_d;
496+
temp_1: _ = temp_2.ret;
497+
temp_1_d: _ = temp_2.ret_d;
498498
r_d = x * temp_1_d + temp_1 * x_d;
499499
r = x * temp_1;
500500
return;

0 commit comments

Comments
 (0)