Skip to content

Commit

Permalink
[vm/ffi] Migrate pkg/front_end tests to Allocator
Browse files Browse the repository at this point in the history
New API landed in: https://dart-review.googlesource.com/c/sdk/+/177705

Issue: #44621
Issue: #38721

Change-Id: Id45274313edbb3842438b66b9c0917a86884c8ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178993
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
  • Loading branch information
dcharkes authored and commit-bot@chromium.org committed Jan 14, 2021
1 parent e7f1c03 commit 9922491
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 27 deletions.
1 change: 1 addition & 0 deletions pkg/front_end/test/spell_checking_list_code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ alexmarkov
aligned
alive
allocate
allocator
altered
analogous
analogy
Expand Down
5 changes: 3 additions & 2 deletions pkg/front_end/testcases/general_nnbd_opt_out/ffi_sample.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ class Coordinate extends Struct {

Pointer<Coordinate> next;

factory Coordinate.allocate(double x, double y, Pointer<Coordinate> next) {
return allocate<Coordinate>().ref
factory Coordinate.allocate(
Allocator allocator, double x, double y, Pointer<Coordinate> next) {
return allocator<Coordinate>().ref
..x = x
..y = y
..next = next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class Coordinate extends Struct {
@Double()
double y;
Pointer<Coordinate> next;
factory Coordinate.allocate(double x, double y, Pointer<Coordinate> next) {}
factory Coordinate.allocate(
Allocator allocator, double x, double y, Pointer<Coordinate> next) {}
}

main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class Coordinate extends Struct {
double x;
@Double()
double y;
factory Coordinate.allocate(double x, double y, Pointer<Coordinate> next) {}
factory Coordinate.allocate(
Allocator allocator, double x, double y, Pointer<Coordinate> next) {}
}

main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ library;
import self as self;
import "dart:ffi" as ffi;
import "dart:core" as core;
import "package:ffi/src/allocation.dart" as all;

import "dart:ffi";
import "package:ffi/ffi.dart";
Expand All @@ -13,8 +12,8 @@ class Coordinate extends ffi::Struct {
@#C1
field core::double* y = null;
field ffi::Pointer<self::Coordinate*>* next = null;
static factory allocate(core::double* x, core::double* y, ffi::Pointer<self::Coordinate*>* next) → self::Coordinate* {
return let final self::Coordinate* #t1 = ffi::StructPointer|get#ref<self::Coordinate*>(all::allocate<self::Coordinate*>()) in block {
static factory allocate(ffi::Allocator* allocator, core::double* x, core::double* y, ffi::Pointer<self::Coordinate*>* next) → self::Coordinate* {
return let final self::Coordinate* #t1 = ffi::StructPointer|get#ref<self::Coordinate*>(ffi::AllocatorAlloc|call<self::Coordinate*>(allocator)) in block {
#t1.{self::Coordinate::x} = x;
#t1.{self::Coordinate::y} = y;
#t1.{self::Coordinate::next} = next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ library;
import self as self;
import "dart:core" as core;
import "dart:ffi" as ffi;
import "package:ffi/src/allocation.dart" as all;

import "dart:ffi";
import "package:ffi/ffi.dart";
Expand All @@ -16,8 +15,8 @@ class Coordinate extends ffi::Struct {
constructor #fromTypedDataBase(dynamic #pointer) → dynamic
: super ffi::Struct::_fromPointer(#pointer)
;
static factory allocate(core::double* x, core::double* y, ffi::Pointer<self::Coordinate*>* next) → self::Coordinate* {
return let final self::Coordinate* #t1 = ffi::StructPointer|get#ref<self::Coordinate*>(all::allocate<self::Coordinate*>()) in block {
static factory allocate(ffi::Allocator* allocator, core::double* x, core::double* y, ffi::Pointer<self::Coordinate*>* next) → self::Coordinate* {
return let final self::Coordinate* #t1 = ffi::StructPointer|get#ref<self::Coordinate*>(ffi::AllocatorAlloc|call<self::Coordinate*>(allocator)) in block {
#t1.{self::Coordinate::x} = x;
#t1.{self::Coordinate::y} = y;
#t1.{self::Coordinate::next} = next;
Expand Down
5 changes: 3 additions & 2 deletions pkg/front_end/testcases/nnbd/ffi_sample.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ class Coordinate extends Struct {

external Pointer<Coordinate> next;

factory Coordinate.allocate(double x, double y, Pointer<Coordinate> next) {
return allocate<Coordinate>().ref
factory Coordinate.allocate(
Allocator allocator, double x, double y, Pointer<Coordinate> next) {
return allocator<Coordinate>().ref
..x = x
..y = y
..next = next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Coordinate extends ffi::Struct {
external set y(core::double #externalFieldValue) → void;
external get next() → ffi::Pointer<self::Coordinate>;
external set next(ffi::Pointer<self::Coordinate> #externalFieldValue) → void;
static factory allocate(core::double x, core::double y, ffi::Pointer<self::Coordinate> next) → self::Coordinate
static factory allocate(ffi::Allocator allocator, core::double x, core::double y, ffi::Pointer<self::Coordinate> next) → self::Coordinate
;
}
static method main() → dynamic
Expand Down
5 changes: 2 additions & 3 deletions pkg/front_end/testcases/nnbd/ffi_sample.dart.strong.expect
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ library /*isNonNullableByDefault*/;
import self as self;
import "dart:ffi" as ffi;
import "dart:core" as core;
import "package:ffi/src/allocation.dart" as all;

import "dart:ffi";
import "package:ffi/ffi.dart";
Expand All @@ -18,8 +17,8 @@ class Coordinate extends ffi::Struct {
external set y(core::double #externalFieldValue) → void;
external get next() → ffi::Pointer<self::Coordinate>;
external set next(ffi::Pointer<self::Coordinate> #externalFieldValue) → void;
static factory allocate(core::double x, core::double y, ffi::Pointer<self::Coordinate> next) → self::Coordinate {
return let final self::Coordinate #t1 = ffi::StructPointer|get#ref<self::Coordinate>(all::allocate<self::Coordinate>()) in block {
static factory allocate(ffi::Allocator allocator, core::double x, core::double y, ffi::Pointer<self::Coordinate> next) → self::Coordinate {
return let final self::Coordinate #t1 = ffi::StructPointer|get#ref<self::Coordinate>(ffi::AllocatorAlloc|call<self::Coordinate>(allocator)) in block {
#t1.{self::Coordinate::x} = x;
#t1.{self::Coordinate::y} = y;
#t1.{self::Coordinate::next} = next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:ffi" as ffi;
import "package:ffi/src/allocation.dart" as all;

import "dart:ffi";
import "package:ffi/ffi.dart";
Expand Down Expand Up @@ -32,8 +31,8 @@ class Coordinate extends ffi::Struct {
return ffi::_fromAddress<self::Coordinate>(ffi::_loadIntPtr(this.{ffi::Struct::_addressOf}, (#C18).{core::List::[]}(ffi::_abi())));
set next(ffi::Pointer<self::Coordinate> #externalFieldValue) → void
return ffi::_storeIntPtr(this.{ffi::Struct::_addressOf}, (#C18).{core::List::[]}(ffi::_abi()), #externalFieldValue.{ffi::Pointer::address});
static factory allocate(core::double x, core::double y, ffi::Pointer<self::Coordinate> next) → self::Coordinate {
return let final self::Coordinate #t1 = ffi::StructPointer|get#ref<self::Coordinate>(all::allocate<self::Coordinate>()) in block {
static factory allocate(ffi::Allocator allocator, core::double x, core::double y, ffi::Pointer<self::Coordinate> next) → self::Coordinate {
return let final self::Coordinate #t1 = ffi::StructPointer|get#ref<self::Coordinate>(ffi::AllocatorAlloc|call<self::Coordinate>(allocator)) in block {
#t1.{self::Coordinate::x} = x;
#t1.{self::Coordinate::y} = y;
#t1.{self::Coordinate::next} = next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class Coordinate extends Struct {
@Double()
external double y;
external Pointer<Coordinate> next;
factory Coordinate.allocate(double x, double y, Pointer<Coordinate> next) {}
factory Coordinate.allocate(
Allocator allocator, double x, double y, Pointer<Coordinate> next) {}
}

main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class Coordinate extends Struct {
external double x;
@Double()
external double y;
factory Coordinate.allocate(double x, double y, Pointer<Coordinate> next) {}
factory Coordinate.allocate(
Allocator allocator, double x, double y, Pointer<Coordinate> next) {}
}

main() {}
5 changes: 2 additions & 3 deletions pkg/front_end/testcases/nnbd/ffi_sample.dart.weak.expect
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ library /*isNonNullableByDefault*/;
import self as self;
import "dart:ffi" as ffi;
import "dart:core" as core;
import "package:ffi/src/allocation.dart" as all;

import "dart:ffi";
import "package:ffi/ffi.dart";
Expand All @@ -18,8 +17,8 @@ class Coordinate extends ffi::Struct {
external set y(core::double #externalFieldValue) → void;
external get next() → ffi::Pointer<self::Coordinate>;
external set next(ffi::Pointer<self::Coordinate> #externalFieldValue) → void;
static factory allocate(core::double x, core::double y, ffi::Pointer<self::Coordinate> next) → self::Coordinate {
return let final self::Coordinate #t1 = ffi::StructPointer|get#ref<self::Coordinate>(all::allocate<self::Coordinate>()) in block {
static factory allocate(ffi::Allocator allocator, core::double x, core::double y, ffi::Pointer<self::Coordinate> next) → self::Coordinate {
return let final self::Coordinate #t1 = ffi::StructPointer|get#ref<self::Coordinate>(ffi::AllocatorAlloc|call<self::Coordinate>(allocator)) in block {
#t1.{self::Coordinate::x} = x;
#t1.{self::Coordinate::y} = y;
#t1.{self::Coordinate::next} = next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:ffi" as ffi;
import "package:ffi/src/allocation.dart" as all;

import "dart:ffi";
import "package:ffi/ffi.dart";
Expand Down Expand Up @@ -32,8 +31,8 @@ class Coordinate extends ffi::Struct {
return ffi::_fromAddress<self::Coordinate>(ffi::_loadIntPtr(this.{ffi::Struct::_addressOf}, (#C18).{core::List::[]}(ffi::_abi())));
set next(ffi::Pointer<self::Coordinate> #externalFieldValue) → void
return ffi::_storeIntPtr(this.{ffi::Struct::_addressOf}, (#C18).{core::List::[]}(ffi::_abi()), #externalFieldValue.{ffi::Pointer::address});
static factory allocate(core::double x, core::double y, ffi::Pointer<self::Coordinate> next) → self::Coordinate {
return let final self::Coordinate #t1 = ffi::StructPointer|get#ref<self::Coordinate>(all::allocate<self::Coordinate>()) in block {
static factory allocate(ffi::Allocator allocator, core::double x, core::double y, ffi::Pointer<self::Coordinate> next) → self::Coordinate {
return let final self::Coordinate #t1 = ffi::StructPointer|get#ref<self::Coordinate>(ffi::AllocatorAlloc|call<self::Coordinate>(allocator)) in block {
#t1.{self::Coordinate::x} = x;
#t1.{self::Coordinate::y} = y;
#t1.{self::Coordinate::next} = next;
Expand Down

0 comments on commit 9922491

Please sign in to comment.