Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Questions about the generated codes #6

Open
EhsanAramide opened this issue Oct 13, 2021 · 1 comment
Open

Some Questions about the generated codes #6

EhsanAramide opened this issue Oct 13, 2021 · 1 comment

Comments

@EhsanAramide
Copy link

EhsanAramide commented Oct 13, 2021

Hi, dear Vandad!

I have some questions about the dart compilers that I thought this repository would be a great place to speak about it and document for others.

  1. As you know in the dart JIT/AOT compiler we can pass definitions via --define=<key>=<value> option. Now my question is the below code snnipts.
// JIT compiler
// $ dart --define=name=ehsan main.dart
var definition = String.fromEnvironment('name');
print(definition); // ehsan

but in AOT compilation value isn't accessible, if the variable type qualifier be var and should be const

// AOT compiler
// $ dart compile exe --define=name=ehsan -o main main.dart; ./main
var definition = String.fromEnvironment('name'); // also `bool.hasEnvironment('name')` returns false
print(definition); // '' empty String, false boolean, 0 int

Actully my question is what happen in generated code that makes this difference in AOT and JIT compilation?

  1. Is platform checking will happen in runtime? (in AOT compilation)
// the is<platform> static variables also use this getter
 switch (Platform.operatingSystem) {
   case 'linux':
     // do something linux
     break;
   case 'macos':
     // do something in mac
     break;
   // and so on...
 }
@EhsanAramide
Copy link
Author

EhsanAramide commented Oct 14, 2021

Hi!
In the dart-lang/language repository I found an issue which is related to my question (I think second one). I will put it here ti make it more clear for others and maybe in documentations.

dart-lang/language#1889

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant