Commit graph

103 commits

Author SHA1 Message Date
Leonardo de Moura
7c76a19885 chore: fix includes 2020-05-22 14:17:25 -07:00
Leonardo de Moura
8bdca35282 chore: use #include <lean/runtime/...> for runtime .h files 2020-05-18 11:30:07 -07:00
Leonardo de Moura
269f20efe8 fix: ensure C++ and Lean use the same hash for Name 2019-11-18 19:54:05 -08:00
Leonardo de Moura
46adfcfdb6 refactor: Name fully implemented in Lean 2019-11-18 19:54:05 -08:00
Leonardo de Moura
70a90ca73e feat(library/init/lean/parser/identifier): allow ! and ? in the identifiers 2019-10-01 14:45:07 -07:00
Leonardo de Moura
0d5ac5288a feat(runtime): increase small nat size
In 64-bit machines, the max small nat value should now be (2^63 - 1), and on 32-bit
machines (2^32 - 1).

The main motivation for this modification are the array indexing
operations. With the new representation, if a Nat index is not small,
then it must not be a valid index. This was not true in 64-bit
machines. Example: an array of size 2^33 would fit in memory, and but
an index `i` > 2^32 - 1 would not be a small nat value.
2019-03-26 14:21:03 -07:00
Leonardo de Moura
4627929a83 refactor(boot,runtime,util): move name runtime implementation to util/name, and use "extern C" ABI 2019-02-13 08:27:23 -08:00
Leonardo de Moura
2058d33d07 feat(runtime,library/compiler): add name.dec_eq builtin 2019-02-05 14:36:02 -08:00
Leonardo de Moura
eb57a904af chore(runtime): avoid overloads 2019-02-05 14:04:29 -08:00
Leonardo de Moura
3444a295e7 feat(library/compiler,runtime): builtin support for lean.name 2019-02-05 12:57:46 -08:00
Leonardo de Moura
01ea596aea refactor(kernel/expr): implement expr using runtime/object 2018-06-21 16:05:33 -07:00
Leonardo de Moura
13c532d0d4 fix(*): truncation bugs
- Lean strings (like std::string) may contain null characters. The
  codebase was ignoring this issue.

- We now have a wrapper `string_ref` for wrapping Lean string objects in
  C++. This wrapper also implements correctly the coercions std::string <-> string_ref.
  Remark: I also found a few places where the code relies on the
  following property which is not true
  Forall s : std::string, std::string(s.c_str()) == s

- `name` object wrapper was assuming that all numerals were small
  `nat` values. This is true in most cases, but the system would
  crash when processing if it is a big number.

- The commit tries to make sure runtime/util/kernel are correct.
  Modules that will be deleted contain many `TODO` comments
  indicating they may crash and/or produce incorrect results
  when strings contain null characters and numerals are big.

cc @kha

@kha: I thought about using `string` instead of `string_ref`.
We consistently use `std::string`. So, it should be fine, but I
was concerned about code readability.

After we bootstrap Lean4, we will be able to delete `lean::list`
template, and rename `lean::list_ref` to `lean::list`.

I am going to add `pair_ref` for wrapping Lean pair objects.
If we use `lean::string` instead of `lean::string_ref`, then
we should also use `lean::pair` instead of `lean::pair_ref`.
But, there is a problem in this case since we have
https://github.com/leanprover/lean4/blob/master/src/util/pair.h#L13
:(
2018-06-15 16:05:11 -07:00
Leonardo de Moura
fe2d416cde fix(runtime,util,kernel): should not use strcmp to compare Lean string objects
Reason:
- UTF8 encoding
- Lean strings may contain null char. That is, null char is not an end
  of string delimiter like in C. Lean string objects are similar to std::string
2018-06-15 16:05:11 -07:00
Leonardo de Moura
017e1d7a5f fix(util/name): strcmp does not implement Lean string equality 2018-06-13 11:43:05 -07:00
Leonardo de Moura
ef8bbccf9f chore(util/object_ref): disable automatic coercion from object_ref to object * 2018-05-23 13:12:40 -07:00
Leonardo de Moura
5b17a30203 feat(runtime): add object serializer
Any type implemented on top of `object` gets the serializer/deserializer for free
2018-05-22 16:34:41 -07:00
Leonardo de Moura
67b59a0a3c fix(util): memory leaks 2018-05-22 11:05:51 -07:00
Leonardo de Moura
df26e10609 fix(util): assertion violations 2018-05-20 13:42:22 -07:00
Leonardo de Moura
ce29de1b49 chore(util): style 2018-05-20 13:26:59 -07:00
Leonardo de Moura
256a1f720c refactor(util/name): implement name using object 2018-05-20 13:22:34 -07:00
Leonardo de Moura
8ee2f4fea1 feat(*): basic runtime string support 2018-05-14 16:52:55 -07:00
Leonardo de Moura
0556412f8d refactor(*): add runtime folder
@kha The runtime folder includes what is needed to link a
standalone Lean program. It is still contains some unnecessary files.
We will be able to remove them after we release Lean4.
2018-05-14 14:23:56 -07:00
Leonardo de Moura
39ef7aeee2 chore(util): remove memory_pool
memory_pool object introduces memory contention and unnecessary
complexity. Moreover, it actually reduces performance when we compile
Lean using JEMALLOC.

Here are the numbers for corelib

jemalloc with memory_pool:    13.83 secs
jemalloc without memory_pool: 13.60 secs
2018-04-12 16:43:10 -07:00
Leonardo de Moura
6bb592caf0 perf(util/name): avoid unnecessary memory allocations 2018-02-21 16:04:53 -08:00
Leonardo de Moura
cc8eb83507 refactor(library/util,util): move is_internal_name to util/ 2018-02-21 15:04:19 -08:00
Nuno Lopes
5cee9f8279 fix(crash) due to calling isalpha/isalnum with signed char in is_id_first() and is_id_rest() 2018-02-06 10:11:10 -08:00
Nuno Lopes
59b5a4a07a feat(build): add preliminary MSVC support
Still doesn't build fully, but at least Intellisense sort of works now
2018-02-06 10:11:09 -08:00
matt rice
1538615e8c feat(util): allow some math alphanum symbol latin letter variations
Add the Script, Double-struck, and Fractur blocks from,
https://unicode.org/charts/PDF/U1D400.pdf
to is_letter_like() so they may be bound to variables.
2018-01-23 11:20:05 -08:00
Gabriel Ebner
2804a0ea27 fix(util/name): escape empty name components using french quotes 2017-07-31 16:01:46 +01:00
Sebastian Ullrich
426f1afb4e feat(util/name): accept more subscripts in identifiers 2017-06-28 10:43:19 -07:00
Sebastian Ullrich
f53fa97c4a feat(frontends/lean): escape identifiers when pretty-printing 2017-06-28 10:43:19 -07:00
Sebastian Ullrich
7ac2f1be89 fix(util/name): segfault on name() == "foo"
Fixes #1505
2017-04-03 12:32:35 +02:00
Sebastian Ullrich
3f87755a2a fix(frontends/lean/pp): qualify constant shadowed by local 2017-03-31 09:40:49 -07:00
Sebastian Ullrich
7e67b48b2d chore(util/name): avoid parameter name confusing CLion
The overloading of `name` makes it error out on the _entire_ remaining file.
2017-01-11 15:27:37 +01:00
Gabriel Ebner
ec0aa6d248 refactor(*): integrate emscripten build 2016-10-16 14:41:35 -07:00
Gabriel Ebner
4dac796337 feat(library/local_context): make get_unused_name O(log(n)) 2016-09-19 16:38:03 -07:00
Leonardo de Moura
1b528ba327 chore(util/name): remove assertion
The procedure get_tagged_name_suffix violates the assertion.
Alternative solution: change return type of get_tagged_name_suffix to
optional<std::string> since it is only used for pretty printing.
2016-07-30 19:53:58 -07:00
Leonardo de Moura
f67181baf3 chore(*): remove support for Lua 2016-02-11 17:17:55 -08:00
Leonardo de Moura
a9cb9ff912 perf(util/name): more inlining 2016-02-02 09:49:50 -08:00
Leonardo de Moura
187bce307e perf(src/util/name): inline hash 2016-02-02 09:21:01 -08:00
Leonardo de Moura
a2ef818ff3 chore(*): remove old tracing framework 2015-12-08 09:06:10 -08:00
Leonardo de Moura
656b642c4a fix(frontends/lean): identifier size when using unicode
see issue #756
2015-07-30 11:32:24 -07:00
Leonardo de Moura
f1e915a188 feat(frontends/lean): add 'find_decl' command 2014-11-23 23:00:59 -08:00
Leonardo de Moura
516c0c73b9 refactor(*): remove dependency to thread_local C++11 keyword, the
current compilers have several bugs associated with it

We use the simpler __thread (gcc and clang) and
__declspec(thread) (visual studio).
2014-09-24 12:51:04 -07:00
Leonardo de Moura
ca1b8ca80f refactor(util/memory_pool): simplify memory_pool, it is not a template anymore 2014-09-24 10:48:32 -07:00
Leonardo de Moura
7e84d5df3d refactor(util): explicit initialization/finalization 2014-09-24 10:12:29 -07:00
Leonardo de Moura
b6781711b1 refactor(*): explicit initialization/finalization for serialization
modules, expression annotations, and tactics
2014-09-22 15:26:41 -07:00
Leonardo de Moura
d75a4739e4 refactor(util/name): move string_to_name to name module 2014-09-04 13:09:42 -07:00
Leonardo de Moura
0d97fff280 feat(library/module): include name of corrupted .olean file
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-08-14 11:28:44 -07:00
Leonardo de Moura
9a6df02683 fix(util/name): avoid assertion violation when reading numeric names
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-08-07 08:32:43 -07:00