Commit graph

249 commits

Author SHA1 Message Date
Leonardo de Moura
2996d306c9 feat(library/init): add more general modify: modifyGet
This commit also adds a few helper elaboration functions.
2019-09-16 15:14:02 -07:00
Sebastian Ullrich
560e7af128 fix(library/init/lean/compiler/ir/compilerm): borrow annotations on extern decls do not do anything right now 2019-09-12 18:26:15 +02:00
Sebastian Ullrich
9015fc1e34 chore(library/compiler/ir_interpreter): add step-level trace 2019-09-12 18:26:15 +02:00
Sebastian Ullrich
1a99fc5c5d feat(init/lean/compiler): export some internals 2019-09-12 18:22:02 +02:00
Leonardo de Moura
8e47b6396f chore(library/init/lean/compiler/ir): simplify mkCase, the xType field is set by explicitBoxing 2019-09-12 08:55:09 -07:00
Leonardo de Moura
ca54240843 fix(library/init/lean/compiler/ir): the xType field at FnBody.case must be set by explicitBoxing 2019-09-12 08:47:58 -07:00
Leonardo de Moura
0284d4a7a2 chore(library/compiler/ir): use new mkCase 2019-09-12 08:23:29 -07:00
Leonardo de Moura
a16d3f09cf feat(library/init/lean/compiler/ir): store scrutinee type at FnBody.case 2019-09-12 08:07:47 -07:00
Leonardo de Moura
56e0c0efae chore(library/init/lean/compiler/ir/boxing): apply elimDead 2019-09-11 11:55:38 -07:00
Leonardo de Moura
3aeeadd255 chore(library/init/lean/compiler/ir/boxing): cleanup 2019-09-11 11:11:33 -07:00
Leonardo de Moura
f39220ac01 feat(library/init/lean/compiler/ir/boxing): ignore "cheap" cases when caching boxing operations 2019-09-11 10:56:37 -07:00
Leonardo de Moura
61a3ea61c4 perf(library/init/lean/compiler/ir/boxing): create auxiliary constants for caching the value of boxed/unboxed literals and constants
For example, in the new test `qsort64.lean`, the new optimization
prevents the repeated execution of `box UInt64.inhabited`.
On my machine
```
./run.sh qsort64.lean 2000000
```
Goes from 1.22s to 0.355s
2019-09-11 10:37:35 -07:00
Leonardo de Moura
e8cdd2b29f fix(library/init/lean/compiler/ir/default): missing explicitRC 2019-09-09 10:53:34 -07:00
Leonardo de Moura
f7af9a73bd chore(library/init/lean/compiler/ir): move addBoxedVersion to entry point file 2019-09-09 10:35:52 -07:00
Leonardo de Moura
7dfec3c724 feat(library/init/lean/compiler/ir): add persistent field to inc/dec
If `persistent == true`, then object is known to be persistent at
compilation time. `emitc` omits `inc/dec` operations to
persistent objects. The interpreter does not to avoid memory leaks.
2019-09-09 07:42:06 -07:00
Leonardo de Moura
a188bb8497 chore(library/init/lean/compiler/ir): remove emitcpp 2019-09-07 19:46:22 -07:00
Leonardo de Moura
09d8dd536c fix(library/init/lean/compiler/ir/emitc): invisible unicode character 2019-08-24 07:40:55 -07:00
Leonardo de Moura
db83a52748 chore(library/init/lean/compiler/ir/emitc): cleanup 2019-08-24 07:40:55 -07:00
Leonardo de Moura
70f3537a29 feat(runtime): add lean_panic and variants 2019-08-24 07:40:39 -07:00
Leonardo de Moura
5124ab07c0 feat(library/init/lean/compiler/ir/emitcpp): use extern "C" { in generated files 2019-08-24 07:40:38 -07:00
Leonardo de Moura
b020ca3259 feat(library/init/lean/compiler/ir/emitcpp): allow C++ backend to use @[extern c ...] when @[extern cpp ...] is missing 2019-08-24 07:40:38 -07:00
Leonardo de Moura
41a4eaacd3 fix(runtime, library/init/lean/compiler/ir/emitc): missing export, ensure we can compile with C++ compiler 2019-08-24 07:40:38 -07:00
Leonardo de Moura
78d87cf4cd fix(library/init/lean/compiler/ir/emitcpp): add missing lean::
@kha It is unclear why the C++ compilers were accepting our generated
files without `lean::`. I found the issue by accident while working on
the new C backend.
2019-08-21 09:51:01 -07:00
Leonardo de Moura
25481d5cef chore(runtime/object): preparing for implementing object.h using lean.h 2019-08-20 13:00:18 -07:00
Leonardo de Moura
4405b30cc8 fix(library/init/lean/compiler/ir/emitc): lean_inc 2019-08-20 12:19:31 -07:00
Leonardo de Moura
dbabee0711 fix(library/init): missing "extern c" 2019-08-20 12:02:46 -07:00
Leonardo de Moura
98e6e0c09a feat(library/init): add "extern c" attributes 2019-08-20 11:53:46 -07:00
Leonardo de Moura
6d6cb14f9e feat(library/init/lean/compiler/ir/emitc,shell/lean): add --c=<filename> option 2019-08-20 10:13:40 -07:00
Leonardo de Moura
66304d83a0 chore(library/init/lean/compiler): export as C functions 2019-08-17 06:58:36 -07:00
Leonardo de Moura
4429aac0b3 chore(library/compiler/ir): remove box(13) hack 2019-08-16 20:58:30 -07:00
Leonardo de Moura
ec0e74f5f8 chore(library/init/lean): export as C functions 2019-08-16 20:52:10 -07:00
Leonardo de Moura
8a3522c8e5 chore(library/init/lean/compiler/ir/emitcpp): small hack for exporting functions as C functions instead of C++ 2019-08-16 19:26:03 -07:00
Leonardo de Moura
deecda22bd feat(library/init/lean/compiler/ir/emitc): C code emitter
It will eventually replace emitcpp.lean
2019-08-15 20:29:06 -07:00
Leonardo de Moura
dfa9ca5dc5 chore(library/init/lean/compiler/ir/basic): style 2019-08-09 10:19:35 -07:00
Leonardo de Moura
d00019f57e chore(library/init): fix whitspaces before => 2019-08-09 09:13:49 -07:00
Leonardo de Moura
4d913370a7 chore(library/init): eliminate whitespaces using another patch script 2019-08-09 09:01:39 -07:00
Sebastian Ullrich
3ed67138d5 chore(*): update equation syntax in files and old parser
for f in ../../**/*.lean; do echo $f; ./patch.lean.out $f > tmp && cat tmp > $f; done
2019-08-09 11:11:34 +02:00
Leonardo de Moura
ff88c35fc1 refactor(library/init): move io and platform to system subdir 2019-07-25 17:29:33 -07:00
Leonardo de Moura
f6d3fc881d feat(library/init): add platform.cpp 2019-07-25 17:19:50 -07:00
Leonardo de Moura
27e0ad0d9e chore(library/init/lean/compiler/ir/emitcpp): remove constant registration 2019-07-19 10:52:18 -07:00
Leonardo de Moura
a8c36d4c29 feat(library/init/lean/syntax): remove MacroScopes
We are going to use a simpler approach to help users writing hygienic
macros. Suppose we have a syntax quotation such as
```
`(let x := %%a;
  ite x x %%b)
```
We will parse this quotation, and during elaboration, we must create
code (i.e., an `Expr`) such that given `a` and `b`, it constructs
a (new) syntax object, and we want to guarantee that there is no accidental name capture.
So, given the syntax object `S` representing the quotation above, we
first pre-resolve the identifiers in `S`. In this step, we annotate the
identifier `ite` with the global declaration `_root_.ite`.
Then, we create a fresh identifier for each identifier, but we would
preserve the pre-resolved information.
Assume the monadic action `mkFresh <id>` creates a fresh identifier with
prefix `<id>`, and `mkFreshWithPreresolved <id> <pre-list>` creates a
fresh identifier with prefix <id> and pre-resolved list `<pre-list>`.
Then, the quotation above would be transformed into:
```
let x := mkFresh `x;
let ite := mkFreshWith `ite [`_root_.ite];
`(let %%x := %%a;
 %%ite %%x %%x %%b)
```
Here, the new quotation is just syntax sugar for a sequence of `Syntax`
constructor applications. Now, whenever we want to create a syntax
object using the quotation above, we guarantee there is no accidental
name capture because we are creating a fresh identifier for all
identifiers in the quotation. Global references are preserved using the
field preresolved that we already have.
It is straightforward to implement the transformation above using a
mapping. Note that if we use the same mapping to elaborate two different
quotations, we are essentially saying they share the same scope.
For example, suppose we have
```
let c := `(ite x x %%b);
`(let x := %%a; %%c)
```
If we use the same mapping, we produce
```
let x := mkFresh `x;
let ite := mkFreshWith `ite [`_root_.ite];
let c := `(%%ite %%x %%x %%b);
`(let %%x := %%a; %%c)
```
If we create a new mapping when compiling each quotation, we get
```
let x := mkFresh `x;
let ite := mkFreshWith `ite [`_root_.ite];
let c := `(%%ite %%x %%x %%b);
let x1 := mkFresh `x;
`(let %%x1 := %%a; %%c)
```
which is probably not what the user wants.
We can provide a simple notation for users specifying which behavior
they want. The default may be super simple. Example: we have a new mapping (aka scope) per declaration.
The approach above is simple and efficient. It is also great for
users that want to create syntax objects during the elaboration phase
and want to avoid name capture.
2019-07-15 10:00:27 -07:00
Leonardo de Moura
295cabed2e chore(library/init): remove unnecessary notations 2019-07-11 10:27:16 -07:00
Leonardo de Moura
c00788a982 fix(library/init/lean/compiler/ir/emitcpp): header of big boxed functions 2019-07-08 21:52:01 -07:00
Leonardo de Moura
324a053f4c fix(library/init/lean/compiler/ir/resetreuse): bug at Dmain 2019-07-08 20:37:54 -07:00
Leonardo de Moura
1a81d60820 chore(frontends/lean/parser): simplify binder notation
The `<ident> : <expr>` now requires explicit brackets.
2019-07-08 08:54:19 -07:00
Leonardo de Moura
ea6eee516b chore(frontends/lean): use => instead of := in match-expressions
Motivation: use same separator used in lambda expressions as in
other programming languages.
2019-07-04 11:38:38 -07:00
Leonardo de Moura
92466272ed fix(library/init/lean/compiler/ir/emitcpp): incorrectly emitting unicode characters in the range [128, 255]
For example, "·" was being stored as `\xb7` which is not the valid UTF8.
2019-07-02 15:56:32 -07:00
Leonardo de Moura
a02443d23d chore(frontends/lean): fun x, e ==> fun x => e 2019-07-02 13:22:11 -07:00
Leonardo de Moura
6841e47aa4 chore(frontends/lean/builtin_exprs): remove support for (<infix>) and (<infix> <expr>) notations
In Lean 4, we will support the more general

`a + ·` ==> `fun x, a + x`
`· + b` ==> `fun x, x + b`
`· + ·` ==> `fun x y, x + y`
`f · y` ==> `fun x, f a y`
`g · · b` ==> `fun x y, g x y b`
2019-07-02 08:06:06 -07:00
Leonardo de Moura
91e1d30cf8 feat(frontends/lean/builtin_exprs): use ; in do-notation 2019-06-27 18:00:43 -07:00