soooo many thigns in need to commit more often
also, types exist in the ast, but are interned after parsing refs and typerefs are resolved true and false in the intern pool, need to add them to primaryexpr structs in the internpool take a decl to differentiate struct types of the same name field access postfix expr? also nesting postfix expr (e.g. var[1][2]) arrays can only be specified with integral constants as length fixes: sinttype and uinttype store bits inline in item.index correctly mut/var decl assignment? have correct doc strings let/var symbol is inserted after the assignment expr, so that the expr can still use now-shadowed variables structs can have fields of type pointer-to-self (ast) lots of wrong-cases in node children getting
This commit is contained in:
parent
a565c1e1e9
commit
888517f2ea
1233
src/ast2/mod.rs
1233
src/ast2/mod.rs
File diff suppressed because it is too large
Load diff
|
@ -8,6 +8,7 @@
|
||||||
iter_intersperse,
|
iter_intersperse,
|
||||||
iter_array_chunks,
|
iter_array_chunks,
|
||||||
int_roundings,
|
int_roundings,
|
||||||
|
if_let_guard,
|
||||||
debug_closure_helpers
|
debug_closure_helpers
|
||||||
)]
|
)]
|
||||||
#![allow(unused_macros)]
|
#![allow(unused_macros)]
|
||||||
|
|
|
@ -430,6 +430,7 @@ pub mod syms2 {
|
||||||
Const,
|
Const,
|
||||||
Function,
|
Function,
|
||||||
Type,
|
Type,
|
||||||
|
__TypeScope,
|
||||||
Scope,
|
Scope,
|
||||||
ParentScope,
|
ParentScope,
|
||||||
Local(SourceLocation),
|
Local(SourceLocation),
|
||||||
|
@ -547,6 +548,40 @@ pub mod syms2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn find_type_symbol(
|
||||||
|
&self,
|
||||||
|
scope: AstIndex,
|
||||||
|
name: InternIndex,
|
||||||
|
loc: SourceLocation,
|
||||||
|
) -> Option<AstIndex> {
|
||||||
|
use SymbolKind::*;
|
||||||
|
let range = self.inner.range(
|
||||||
|
Key::Symbol {
|
||||||
|
scope,
|
||||||
|
name,
|
||||||
|
kind: __First,
|
||||||
|
}..=Key::Symbol {
|
||||||
|
scope,
|
||||||
|
name,
|
||||||
|
kind: __TypeScope,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if let Some((_, payload)) = range.rev().next() {
|
||||||
|
Some(payload.as_ast())
|
||||||
|
} else {
|
||||||
|
if let Some(parent) = self.inner.get(&Key::Symbol {
|
||||||
|
scope,
|
||||||
|
name: InternIndex::invalid(),
|
||||||
|
kind: ParentScope,
|
||||||
|
}) {
|
||||||
|
self.find_symbol(parent.as_ast(), name, loc)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn insert_symbol(
|
pub fn insert_symbol(
|
||||||
&mut self,
|
&mut self,
|
||||||
scope: AstIndex,
|
scope: AstIndex,
|
||||||
|
|
4
tests/legal/array.sea
Normal file
4
tests/legal/array.sea
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
fn main() {
|
||||||
|
var arr: [4] u8;
|
||||||
|
arr[0] = 1;
|
||||||
|
}
|
|
@ -1,8 +1,12 @@
|
||||||
type MyStruct = struct {
|
type MyStruct = struct {
|
||||||
i: i32,
|
i: i32,
|
||||||
b: bool,
|
b: bool,
|
||||||
|
next: *MyStruct,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn square_if_true(arg: MyStruct) -> i32 {
|
fn square_if_true(arg: MyStruct) -> i32 {
|
||||||
|
if (arg.b)
|
||||||
|
arg.i * arg.i
|
||||||
|
else
|
||||||
0
|
0
|
||||||
}
|
}
|
Loading…
Reference in a new issue