rename corelib -> core, update readme

This commit is contained in:
collin 2022-06-02 11:22:08 -04:00
parent ace7005ea7
commit 85eb1adcce
28 changed files with 97 additions and 42 deletions

4
Cargo.lock generated
View File

@ -1236,7 +1236,7 @@ dependencies = [
]
[[package]]
name = "leo-corelib"
name = "leo-core"
version = "1.5.3"
dependencies = [
"indexmap",
@ -1334,7 +1334,7 @@ version = "1.5.3"
dependencies = [
"indexmap",
"leo-ast",
"leo-corelib",
"leo-core",
"leo-errors",
"leo-parser",
"leo-span",

View File

@ -30,7 +30,7 @@ use std::{
hash::{Hash, Hasher},
};
/// An identifier in the constrained program.
/// An identifier in a program.
///
/// Attention - When adding or removing fields from this struct,
/// please remember to update its Serialize and Deserialize implementation

View File

@ -1,5 +1,5 @@
[package]
name = "leo-corelib"
name = "leo-core"
version = "1.5.3"
authors = [ "The Aleo Team <hello@aleo.org>" ]
description = "The Leo programming language"

74
compiler/core/README.md Normal file
View File

@ -0,0 +1,74 @@
# leo-core
[![Crates.io](https://img.shields.io/crates/v/leo-ast.svg?color=neon)](https://crates.io/crates/leo-ast)
[![Authors](https://img.shields.io/badge/authors-Aleo-orange.svg)](../AUTHORS)
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE.md)
This directory includes the core library for Leo.
## Usage
Leo's core library is statically built into the compiler.
All modules in the `leo-core` rust module will be automatically included in a `core` Leo module that can be imported into a Leo program.
## Implementations
For a full explanation of core library functions, see the [Aleo developer documentation](https://developer.aleo.org/)
### Core Library (Account)
#### Compute Key
```ts
import core.account.ComputeKey;
function foo(public compute_key: ComputeKey);
function foo(compute_key: ComputeKey);
```
#### Private Key
```ts
import core.account.PrivateKey;
function foo(public private_key: PrivateKey);
function foo(private_key: PrivateKey);
```
#### Record
```ts
import core.account.Record;
function foo(public record: Record);
function foo(record: Record);
```
#### Signature
```ts
import core.account.Signature;
function foo(public signature: Signature);
function foo(signature: Signature);
```
#### View Key
```ts
import core.account.ViewKey;
function foo(public view_key: ViewKey);
function foo(view_key: ViewKey);
```
### Core Library (Algorithms)
#### Poseidon
```ts
import core.algorithms.Poseidon;
function foo(public poseidon: Poseidon);
function foo(poseidon: Poseidon);
```

View File

@ -1,32 +0,0 @@
# leo-stdlib
[![Crates.io](https://img.shields.io/crates/v/leo-ast.svg?color=neon)](https://crates.io/crates/leo-ast)
[![Authors](https://img.shields.io/badge/authors-Aleo-orange.svg)](../AUTHORS)
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE.md)
This directory includes the standard library for Leo.
## Usage
The src directory is the Rust code that makes the Leo folders and files statically built into the compiler. So any added Leo folders and files under the `stdlib` directory will be automatically included at compile time.
See the [Structure](#structure) section for more info.
## Structure
The structure for this repository is a bit special.
One important thing to note is the prelude directory. Any Leo files defined in this directory will have all importable objects automatically imported to every Leo program. For example, the following program is valid without any imports:
```typescript
function main() {
let s: string = "Hello, string type alias!";
}
```
The above type alias is auto imported from `stdlib/prelude/string.leo`.
The other directories must have explicit imports.
[//]: # (For example, the unstable Blake2s can be imported with `import std.unstable.blake2s.Blake2s`. Which imports the `Blake2s` circuit defined in `stdlib/unstable/blake2s.leo`.)

View File

@ -40,6 +40,6 @@ version = "1.5.3"
path = "../../leo/span"
version = "1.5.3"
[dependencies.leo-corelib]
path = "../corelib"
[dependencies.leo-core]
path = "../core"
version = "1.5.3"

View File

@ -16,7 +16,7 @@
use leo_ast::Program;
use leo_errors::{Result, Span};
use leo_corelib::resolve_corelib_module;
use leo_core::resolve_core_module;
use indexmap::IndexMap;

View File

@ -22,7 +22,7 @@ pub use canonicalization::*;
*/
// Temporarily disable import resolution
// until we migrate corelib and then import resolution.
// until we migrate core and then import resolution.
/* pub mod import_resolution;
pub use import_resolution::*; */

View File

@ -16,7 +16,7 @@
use indexmap::IndexSet;
use leo_ast::{IntegerType, Node, Type};
use leo_corelib::*;
use leo_core::*;
use leo_errors::{emitter::Handler, TypeCheckerError};
use leo_span::{Span, Symbol};

View File

@ -137,7 +137,20 @@ pub fn run_tests<T: Runner>(runner: &T, expectation_category: &str) {
.unwrap()
.to_string();
let expectations: Option<TestExpectation> = None;
let expectations: Option<TestExpectation> = if expectation_path.exists() {
if !std::env::var("CLEAR_LEO_TEST_EXPECTATIONS")
.unwrap_or_default()
.trim()
.is_empty()
{
None
} else {
let raw = std::fs::read_to_string(&expectation_path).expect("failed to read expectations file");
Some(serde_yaml::from_str(&raw).expect("invalid yaml in expectations file"))
}
} else {
None
};
let end_of_header = content.find("*/").expect("failed to find header block in test");
let content = &content[end_of_header + 2..];