Commit Graph

99 Commits

Author SHA1 Message Date
John Messerly 8f4db8f514 expose strong checker API, for use by analyzer_cli
most of the changes here are around making options sane(r), which fixes #204

R=vsm@google.com

Review URL: https://codereview.chromium.org/1174643003.
2015-06-11 07:47:12 -07:00
John Messerly 01d39ba3f2 cleanup: simplify creation of AnalysisContext
removes TypeResolver class, introduces function to create analysis context, simplifies a few other things around mock vs real SDK sources.

R=vsm@google.com

Review URL: https://codereview.chromium.org/1143683002
2015-05-18 10:20:29 -07:00
John Messerly f728691ac8 Fixes #179 -- compile error if editing files during server mode
this avoids reloading file contents many times during a compile. `.contents.data` == bad!
also fixes #73, using Analyzer's LineInfo instead of FileSpan to avoid finding line breaks over and over
I did some manual testing on sunflower as well as diffing SDK messages before and after

The one baseline change (23 -> 22) seems more accurate than it was before.

R=vsm@google.com

Review URL: https://codereview.chromium.org/1141013002
2015-05-14 16:42:33 -07:00
Sigmund Cherem 6d9564b4ff Support browser caching using hashes in serverMode (fixes #93, fixes #92).
Now the HTML can include a hash in the URL for cachable resources, and the serve knows how to include cache-control headers.

In the process of doing so, I had to change a couple things that made it possible to fix #92 as well (producing different output in the command-line than in server mode).

R=vsm@google.com

Review URL: https://codereview.chromium.org/993213003
2015-03-10 18:27:23 -07:00
Sigmund Cherem 4e4dd98e6b Add widget to display errors, and report graph errors correctly.
This fixes the compiler so that all error messages in dependency_graph are reported via the reporter and unifies how errors are constructed in other places as well. With all errors reported together, we use a widget (adapted from polymer) to display the error messages as part of the app in server mode.

R=vsm@google.com

Review URL: https://codereview.chromium.org/988483006
2015-03-09 11:37:22 -07:00
John Messerly 6e824067a3 rename ddc -> dev_compiler, fixes #84
R=sigmund@google.com

Review URL: https://codereview.chromium.org/967933005
2015-03-04 11:12:19 -08:00
Sigmund Cherem 7dd29efd8f Initial cut for a development server
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/973433003
2015-03-04 09:40:06 -08:00
Sigmund Cherem 9b00a0ecd2 Move argument parsing also to the options.dart file, adds fields for flags we were not storing in the CompilerOptions object.
R=vsm@google.com

Review URL: https://codereview.chromium.org/961503002
2015-02-25 16:40:20 -08:00
Sigmund Cherem e57c960817 rename package:ddc to package:dev_compiler
BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/954773003
2015-02-24 17:01:15 -08:00
Vijay Menon 5c1c9c2381 Add LICENSE and corresponding headers
Fix expectations where line number has changed.

R=dgrove@google.com

Review URL: https://chromereviews.googleplex.com/158257013
2015-02-24 15:02:26 -08:00
Vijay Menon ee887b1ed9 Flag to ignore types during codegen
R=jmesserly@google.com, leafp@google.com

Review URL: https://chromereviews.googleplex.com/161647013
2015-02-20 17:06:01 -08:00
Vijay Menon ddce235e3d Set nonnullable types by flag
R=sigmund@google.com

Review URL: https://chromereviews.googleplex.com/156397013
2015-02-20 14:34:44 -08:00
Sigmund Cherem c1f84cfada Add more flags, fix missing initialization of a couple flags
BUG=
R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/150577015
2015-02-19 16:13:21 -08:00
Sigmund Cherem d78ecd3241 Infer consts and final fields based on RHS
R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/142457013
2015-02-19 08:34:01 -08:00
Sigmund Cherem 34fd717c0a Minor changes to fix up edit_files, which broke when we moved the multi-package
options from -D to flags.

BUG=
R=jmesserly@google.com

Review URL: https://chromereviews.googleplex.com/151567013
2015-02-19 08:28:55 -08:00
Sigmund Cherem ae910f2860 Infer return types and field types based on overrides
R=jmesserly@google.com, vsm@google.com

Review URL: https://chromereviews.googleplex.com/145247013
2015-02-13 16:53:58 -08:00
Sigmund Cherem c08003a36e Add options and move the multi-package options to normal flags
R=jmesserly@google.com

Review URL: https://chromereviews.googleplex.com/149487013
2015-02-13 13:04:16 -08:00
John Messerly 73adf003e6 use cli_utils to get SDK dir
also a small cleanup to make it easier to construct TypeResolver (fixes a TODO) and fix a couple of typos

R=leafp@google.com

Review URL: https://chromereviews.googleplex.com/145437014
2015-02-09 11:25:17 -08:00
Leaf Petersen 7685506b1f Bug fixes
Guard against calling override checking directly with Object while checking the SDK, and fix up the exit status code when compiling.

BUG=
R=jmesserly@google.com

Review URL: https://chromereviews.googleplex.com/145227013
2015-01-27 13:31:33 -08:00
Sigmund Cherem 763e61f4d3 Compile library-by-library. This is a step closer to our incremental compile.
As part of this change I made codegen synchronous. Technically is not necessary,
but I think it reduces complexity a lot. For example, keeping it async would
have required more changes to the testing infrastructure. Let me know if you
want to keep that change separate though.

With this change, I'm removing one more use of element.node, which is necessary
to achileve our goal. There is only one more use of this API, for which John has
a CL out.

BUG=
R=jmesserly@google.com

Review URL: https://chromereviews.googleplex.com/145167013
2015-01-27 09:49:26 -08:00
Sigmund Cherem 33e1aa1313 Rerun formatter, remove unused import
BUG=
R=leafp@google.com

Review URL: https://chromereviews.googleplex.com/137587013
2015-01-16 08:34:24 -08:00
Leaf Petersen fcf7a98525 Call method subtyping
Allow objects with an appropriately typed call method to subtype function types.  Fixes #19.

BUG=
R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/140757013
2015-01-13 16:10:48 -08:00
Leaf Petersen b0a7024e5d Formatter run
Run the formatter on the repository

BUG=
R=jacobr@google.com

Review URL: https://chromereviews.googleplex.com/138207013
2015-01-12 13:16:35 -08:00
Leaf Petersen 37752f763c Relaxed casts
Allow implicit sideways casts between types that are assignable in regular dart.

BUG=
R=jacobr@google.com, vsm@google.com

Review URL: https://chromereviews.googleplex.com/135247013
2015-01-09 10:22:29 -08:00
Leaf Petersen d44e64d22a Covariant generic support
Add support for full covariant generics, under a flag.  Using --covariant-generics will make the checker use full covariance for generics.

BUG=
R=jacobr@google.com

Review URL: https://chromereviews.googleplex.com/140607013
2015-01-08 12:39:32 -08:00
Leaf Petersen efa7876cf2 Coercion reification, dart codegen URI rewriting, import fixups.
This CL adds a general reification pass which makes abstract coercions concrete by modifiying the ast.  Casts are reified as "as" expressions, and wrappers are reified by creating functions which take the old function as arguments and produce a new wrapped function.  There are a number of known issues not yet addressed:

1) No distinction between dart "as" and our special "as" is made yet.
2) Wrapper generation functions do not check for null arguments yet.
3) Types introduced via wrappers and "as" expressions are not yet added to the set of types for which new imports may be required.
4) Wrapper functions for non-literals can't be guaranteed not to change the runtime type without more backend support, since we only have their static type.

This CL also adds support for rewriting import directives in the dart backend to reflect the directory structure that we currently use for output.  Probably this should be rethought.  Currently I just use absolute file URIs, which is not what we want.

This CL also adds support for adding in the import directives needed to account for type names added via inference.  This is not yet correct for "part of" files, since we need to add the imports to the main library file.

BUG=
R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/137957013
2015-01-07 13:53:16 -08:00
Jacob Richman 5114b93cc4 Include error messages
Merge branch 'master' of github.com:dart-lang/dart-dev-compiler

change git dependency so that the ssh keychain can save your username and password.

BUG=
R=sigmund@google.com

Review URL: https://chromereviews.googleplex.com/136707014
2015-01-07 07:51:15 -08:00
Jacob Richman b4999ee290 Support writing error messages directly to file.
BUG=
R=sigmund@google.com

Review URL: https://chromereviews.googleplex.com/134137013
2015-01-05 16:18:45 -08:00
Sigmund Cherem c95d72647a Run latest formatter
Review URL: https://chromereviews.googleplex.com/131387013
2014-12-29 13:01:35 -08:00
Sigmund Cherem 4448f18cea Add a reporter, remove caching of source files and recording of info (in progress)
R=leafp@google.com, vsm@google.com

Review URL: https://chromereviews.googleplex.com/132767014
2014-12-19 15:10:38 -08:00
Sigmund Cherem 93bf92812e Add support for hierarchical packages and multiple package locations
BUG=
R=jmesserly@google.com

Review URL: https://chromereviews.googleplex.com/129377013
2014-12-18 14:26:29 -08:00
John Messerly 0493ac3271 initial sunflower changes
still some things unimplemented, but since we're all hitting the same paths figured I'd land what I have so far

R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/125537013
2014-12-16 14:10:08 -08:00
Sigmund Cherem 706c749203 Initial changes to report some summary data from the checker.
R=jmesserly@google.com, vsm@google.com

Review URL: https://chromereviews.googleplex.com/130017014
2014-12-16 10:38:17 -08:00
John Messerly d8863611dc adds command line help to dartdevc
BUG=
R=sigmund@google.com

Review URL: https://chromereviews.googleplex.com/125447013
2014-12-12 14:15:01 -08:00
Sigmund Cherem 2abc79389f Random cleanups
BUG=
R=jmesserly@google.com

Review URL: https://chromereviews.googleplex.com/130857013
2014-12-11 18:17:06 -08:00
Sigmund Cherem 1c6787f47c Run the latest formatter on all files.
R=jmesserly@google.com

Review URL: https://chromereviews.googleplex.com/130817013
2014-12-11 16:33:01 -08:00
Sigmund Cherem 02a4650a24 Refactor: move code around a bit
- bin/
    devc.dart

- lib/
    devc.dart

    src/
       info.dart # static info we compute, used by checker & backends
       checker/  # implementation details for the checker
          checker.dart  # checking algorithm
          rules.dart    # type checking rules
          resolver.dart # same as today, type resolution via analyzer
       emitter/
          ...
- test/
     checker/    # unit tests for the checker internals
     codegen/    # left as is - maybe should rename to emitter?
     samples/    # stand alone samples that we run in the end_to_end tests.
     ...

R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/128957013
2014-12-11 15:13:54 -08:00
Leaf Petersen eef8c94795 Skeleton for new checker and dart backend
This adds a skeleton new type checker which just reuses the existing checker for now, but will be filled in with the new type rules.

It also adds a dart backend code generator which currently just spits out the original dart code unchanged (except for (lack of) formatting) into the output directory.  By default it uses the dart_style formatter to format the output.  This sometimes hits issues, so there is an option to turn this off.

There are flags to control the various options added.

BUG=
R=jmesserly@google.com, vsm@google.com

Review URL: https://chromereviews.googleplex.com/128857013
2014-12-11 13:01:01 -08:00
John Messerly 3124c7ec89 add the ability to easily test codegen by diffing against expected output
this makes changes easy to spot

some of this code was taken from old polymer.dart test scripts :)

R=sigmund@google.com

Review URL: https://chromereviews.googleplex.com/121567013
2014-12-09 16:52:05 -08:00
John Messerly 5d4f190e63 autoformat with dartfmt. This CL is entire automated.
I filed a few issues:
https://github.com/dart-lang/dart_style/issues/61
https://github.com/dart-lang/dart_style/issues/62

...but they aren't blocking, so I left our long comments (62) and one slightly odd formatting (61) as is.

R=sigmund@google.com, vsm@google.com

Review URL: https://chromereviews.googleplex.com/120127014
2014-12-08 19:58:35 -08:00
Vijay Menon e6b1853c40 Flesh out more codegen
R=jmesserly@google.com

Review URL: https://chromereviews.googleplex.com/126787013
2014-12-02 09:02:17 -08:00
Sigmund Cherem d2a729cd68 Run resolver on every library, as we walk through them
R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/115197015
2014-11-25 12:54:37 -08:00
Sigmund Cherem 971e551b6d Use analyzer as a library, enable mock sdks, refactor to start testing
R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/118577013
2014-11-21 14:24:06 -08:00
Sigmund Cherem 4c67c961ff All minor nits: split some files up, fix comments in walker to remove references
to spec, make them more darty, run formatter on the rest of the files

R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/117397013
2014-11-20 15:36:20 -08:00
Sigmund Cherem 560aa1f632 Fix span location to skip comments
R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/120837013
2014-11-20 13:00:08 -08:00
Vijay Menon 8522221df4 Initial codegen skeleton
Invoke with:
> dart bin/checker.dart -o out tests/fieldtest.dart

Run with (node.js installed):
> node runtime/run.js runtime/dart_runtime.js runtime/dart_core.js out/fieldtest/fieldtest.dart.js fieldtest

Here's the output of fieldtest.dart.js:

var fieldtest;
(function (fieldtest) {
  // Class A
  var A = (function () {
    var _initializer = (function (_this) {
      _this.x = 42;
    });
    function A() {
      _initializer(this);
    }
    return A;
  })();
  fieldtest.A = A;

  // Function foo: (A) → void
  function foo(a) {
    dart_core.print(a.x);
  }
  fieldtest.foo = foo;

  // Function bar: (dynamic) → void
  function bar(a) {
    dart_core.print(dart_runtime.dload(a, "x"));
  }
  fieldtest.bar = bar;

  // Function main: () → void
  function main() {
    var a = new A();
    fieldtest.foo(a);
    fieldtest.bar(a);
  }
  fieldtest.main = main;

})(fieldtest || (fieldtest = {}));

R=sigmund@google.com

Review URL: https://chromereviews.googleplex.com/119897013
2014-11-20 12:15:55 -08:00
Vijay Menon c298d19d4b Add flag to check sdk code
R=sigmund@google.com

Review URL: https://chromereviews.googleplex.com/119797013
2014-11-18 09:20:32 -08:00
Sigmund Cherem 411efe695c Use source spans for error messages. This will print error messages in red and
highlight the area of the original source that had the error.

R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/122637013
2014-11-17 17:58:13 -08:00
Vijay Menon 3f27060ad6 Initial checker 2014-11-17 08:50:19 -08:00