2024-03-01 08:50:50 +00:00
|
|
|
//! # The Conlang Standard Library
|
|
|
|
|
cl-typeck: Computer! Define "types!"
WARNING: The type checker is still a MAJOR work in progress. You'll be unable to ignore the stringly-typed error handling, effort duplication, and general poor code quality all around. However, this makes leaps and bounds toward a functional, if primitive, type checker.
Definitions now borrow their data from the AST, reducing needless copies.
- This unfortunately means the REPL has to keep around old ASTs, but... Eh. Probably have to keep those around anyway.
The "char" primitive type has been added. Semantics TBD.
Modules definition, type_kind, and value_kind have been consolidated into one.
Project now keeps track of the set of unnamed (anonymous) types (i.e. tuples, function pointers, references) and will yield them freely.
- Project can now also evaluate arbitrary type expressions via the EvaluableTypeExpression trait.
The NameCollector has been replaced with trait NameCollectable.
- This pass visits each node in the AST which can have an item declaration inside it, and constructs an unevaluated module tree.
The TypeResolver has been replaced with trait TypeResolvable and the function resolve()
- This pass visits each *Def* in the project, and attempts to derive all subtypes.
- It's important to note that for Items, unlike EvaluableTypeExpression, the ID passed into resolve_type is the ID of `self`, not of the parent!
typeck.rs:
- The Conlang "standard library" is included in the binary
- There's a main menu now! Type "help" for options.
- Queries have been upgraded from paths to full type expressions!
- Querying doesn't currently trigger resolution, but it could!
2024-04-17 04:45:24 +00:00
|
|
|
#[intrinsic = "bool"]
|
|
|
|
pub type bool;
|
|
|
|
|
|
|
|
#[intrinsic = "char"]
|
|
|
|
pub type char;
|
|
|
|
|
|
|
|
#[intrinsic = "i8"]
|
|
|
|
pub type i8;
|
|
|
|
|
|
|
|
#[intrinsic = "i16"]
|
|
|
|
pub type i16;
|
|
|
|
|
2024-03-01 08:50:50 +00:00
|
|
|
#[intrinsic = "i32"]
|
cl-typeck: Computer! Define "types!"
WARNING: The type checker is still a MAJOR work in progress. You'll be unable to ignore the stringly-typed error handling, effort duplication, and general poor code quality all around. However, this makes leaps and bounds toward a functional, if primitive, type checker.
Definitions now borrow their data from the AST, reducing needless copies.
- This unfortunately means the REPL has to keep around old ASTs, but... Eh. Probably have to keep those around anyway.
The "char" primitive type has been added. Semantics TBD.
Modules definition, type_kind, and value_kind have been consolidated into one.
Project now keeps track of the set of unnamed (anonymous) types (i.e. tuples, function pointers, references) and will yield them freely.
- Project can now also evaluate arbitrary type expressions via the EvaluableTypeExpression trait.
The NameCollector has been replaced with trait NameCollectable.
- This pass visits each node in the AST which can have an item declaration inside it, and constructs an unevaluated module tree.
The TypeResolver has been replaced with trait TypeResolvable and the function resolve()
- This pass visits each *Def* in the project, and attempts to derive all subtypes.
- It's important to note that for Items, unlike EvaluableTypeExpression, the ID passed into resolve_type is the ID of `self`, not of the parent!
typeck.rs:
- The Conlang "standard library" is included in the binary
- There's a main menu now! Type "help" for options.
- Queries have been upgraded from paths to full type expressions!
- Querying doesn't currently trigger resolution, but it could!
2024-04-17 04:45:24 +00:00
|
|
|
pub type i32;
|
|
|
|
|
|
|
|
#[intrinsic = "i64"]
|
|
|
|
pub type i64;
|
|
|
|
|
|
|
|
#[intrinsic = "u8"]
|
|
|
|
pub type u8;
|
|
|
|
|
|
|
|
#[intrinsic = "u16"]
|
|
|
|
pub type u16;
|
2024-03-01 08:50:50 +00:00
|
|
|
|
|
|
|
#[intrinsic = "u32"]
|
cl-typeck: Computer! Define "types!"
WARNING: The type checker is still a MAJOR work in progress. You'll be unable to ignore the stringly-typed error handling, effort duplication, and general poor code quality all around. However, this makes leaps and bounds toward a functional, if primitive, type checker.
Definitions now borrow their data from the AST, reducing needless copies.
- This unfortunately means the REPL has to keep around old ASTs, but... Eh. Probably have to keep those around anyway.
The "char" primitive type has been added. Semantics TBD.
Modules definition, type_kind, and value_kind have been consolidated into one.
Project now keeps track of the set of unnamed (anonymous) types (i.e. tuples, function pointers, references) and will yield them freely.
- Project can now also evaluate arbitrary type expressions via the EvaluableTypeExpression trait.
The NameCollector has been replaced with trait NameCollectable.
- This pass visits each node in the AST which can have an item declaration inside it, and constructs an unevaluated module tree.
The TypeResolver has been replaced with trait TypeResolvable and the function resolve()
- This pass visits each *Def* in the project, and attempts to derive all subtypes.
- It's important to note that for Items, unlike EvaluableTypeExpression, the ID passed into resolve_type is the ID of `self`, not of the parent!
typeck.rs:
- The Conlang "standard library" is included in the binary
- There's a main menu now! Type "help" for options.
- Queries have been upgraded from paths to full type expressions!
- Querying doesn't currently trigger resolution, but it could!
2024-04-17 04:45:24 +00:00
|
|
|
pub type u32;
|
|
|
|
|
|
|
|
#[intrinsic = "u64"]
|
|
|
|
pub type u64;
|
|
|
|
|
|
|
|
impl bool {
|
|
|
|
const MIN: Self = false;
|
|
|
|
const MAX: Self = {
|
|
|
|
fn ret_true() -> Self {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
ret_true()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn if_else() -> i32 {
|
|
|
|
// block 1
|
|
|
|
let x = 10;
|
|
|
|
let y = x + 2;
|
|
|
|
|
|
|
|
if x > 10
|
|
|
|
// compare x and 10
|
|
|
|
// end block 1, goto block 2 else goto block 3
|
|
|
|
{
|
|
|
|
// block 2
|
|
|
|
4
|
|
|
|
// end block 2, goto block 4
|
|
|
|
} else {
|
|
|
|
// block 3
|
|
|
|
5
|
|
|
|
// end block 3, goto block 4
|
|
|
|
}
|
|
|
|
// block 4
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg("test")]
|
|
|
|
mod test {
|
|
|
|
//! Tests for funky behavior
|
|
|
|
|
|
|
|
struct UnitLike;
|
|
|
|
|
|
|
|
struct TupleLike(super::i32, super::self::test::super::char)
|
|
|
|
|
|
|
|
struct StructLike {
|
|
|
|
pub member1: UnitLike,
|
|
|
|
member2: TupleLike,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum NeverLike;
|
2024-03-01 08:50:50 +00:00
|
|
|
|
cl-typeck: Computer! Define "types!"
WARNING: The type checker is still a MAJOR work in progress. You'll be unable to ignore the stringly-typed error handling, effort duplication, and general poor code quality all around. However, this makes leaps and bounds toward a functional, if primitive, type checker.
Definitions now borrow their data from the AST, reducing needless copies.
- This unfortunately means the REPL has to keep around old ASTs, but... Eh. Probably have to keep those around anyway.
The "char" primitive type has been added. Semantics TBD.
Modules definition, type_kind, and value_kind have been consolidated into one.
Project now keeps track of the set of unnamed (anonymous) types (i.e. tuples, function pointers, references) and will yield them freely.
- Project can now also evaluate arbitrary type expressions via the EvaluableTypeExpression trait.
The NameCollector has been replaced with trait NameCollectable.
- This pass visits each node in the AST which can have an item declaration inside it, and constructs an unevaluated module tree.
The TypeResolver has been replaced with trait TypeResolvable and the function resolve()
- This pass visits each *Def* in the project, and attempts to derive all subtypes.
- It's important to note that for Items, unlike EvaluableTypeExpression, the ID passed into resolve_type is the ID of `self`, not of the parent!
typeck.rs:
- The Conlang "standard library" is included in the binary
- There's a main menu now! Type "help" for options.
- Queries have been upgraded from paths to full type expressions!
- Querying doesn't currently trigger resolution, but it could!
2024-04-17 04:45:24 +00:00
|
|
|
enum EmptyLike {
|
|
|
|
Empty,
|
|
|
|
}
|
2024-03-01 08:50:50 +00:00
|
|
|
|
cl-typeck: Computer! Define "types!"
WARNING: The type checker is still a MAJOR work in progress. You'll be unable to ignore the stringly-typed error handling, effort duplication, and general poor code quality all around. However, this makes leaps and bounds toward a functional, if primitive, type checker.
Definitions now borrow their data from the AST, reducing needless copies.
- This unfortunately means the REPL has to keep around old ASTs, but... Eh. Probably have to keep those around anyway.
The "char" primitive type has been added. Semantics TBD.
Modules definition, type_kind, and value_kind have been consolidated into one.
Project now keeps track of the set of unnamed (anonymous) types (i.e. tuples, function pointers, references) and will yield them freely.
- Project can now also evaluate arbitrary type expressions via the EvaluableTypeExpression trait.
The NameCollector has been replaced with trait NameCollectable.
- This pass visits each node in the AST which can have an item declaration inside it, and constructs an unevaluated module tree.
The TypeResolver has been replaced with trait TypeResolvable and the function resolve()
- This pass visits each *Def* in the project, and attempts to derive all subtypes.
- It's important to note that for Items, unlike EvaluableTypeExpression, the ID passed into resolve_type is the ID of `self`, not of the parent!
typeck.rs:
- The Conlang "standard library" is included in the binary
- There's a main menu now! Type "help" for options.
- Queries have been upgraded from paths to full type expressions!
- Querying doesn't currently trigger resolution, but it could!
2024-04-17 04:45:24 +00:00
|
|
|
enum Hodgepodge {
|
|
|
|
Empty,
|
|
|
|
UnitLike (),
|
|
|
|
Tuple (TupleLike),
|
|
|
|
StructEmpty {},
|
|
|
|
StructLike { member1: UnitLike, member2: TupleLike },
|
|
|
|
}
|
2024-04-19 02:10:11 +00:00
|
|
|
|
|
|
|
fn noop () -> bool {
|
|
|
|
loop if false {
|
|
|
|
|
|
|
|
} else break loop if false {
|
|
|
|
|
|
|
|
} else break loop if false {
|
|
|
|
|
|
|
|
} else break true;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn while_else() -> i32 {
|
|
|
|
while conditional {
|
|
|
|
pass
|
|
|
|
} else {
|
|
|
|
fail
|
|
|
|
}
|
|
|
|
}
|
cl-typeck: Computer! Define "types!"
WARNING: The type checker is still a MAJOR work in progress. You'll be unable to ignore the stringly-typed error handling, effort duplication, and general poor code quality all around. However, this makes leaps and bounds toward a functional, if primitive, type checker.
Definitions now borrow their data from the AST, reducing needless copies.
- This unfortunately means the REPL has to keep around old ASTs, but... Eh. Probably have to keep those around anyway.
The "char" primitive type has been added. Semantics TBD.
Modules definition, type_kind, and value_kind have been consolidated into one.
Project now keeps track of the set of unnamed (anonymous) types (i.e. tuples, function pointers, references) and will yield them freely.
- Project can now also evaluate arbitrary type expressions via the EvaluableTypeExpression trait.
The NameCollector has been replaced with trait NameCollectable.
- This pass visits each node in the AST which can have an item declaration inside it, and constructs an unevaluated module tree.
The TypeResolver has been replaced with trait TypeResolvable and the function resolve()
- This pass visits each *Def* in the project, and attempts to derive all subtypes.
- It's important to note that for Items, unlike EvaluableTypeExpression, the ID passed into resolve_type is the ID of `self`, not of the parent!
typeck.rs:
- The Conlang "standard library" is included in the binary
- There's a main menu now! Type "help" for options.
- Queries have been upgraded from paths to full type expressions!
- Querying doesn't currently trigger resolution, but it could!
2024-04-17 04:45:24 +00:00
|
|
|
}
|