Skip to content

Commit

Permalink
ast: basic scope (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Dec 3, 2024
1 parent 8112b18 commit 541fbd5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions compiler/ast/File.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub:
content string
mod_name string
pub mut:
scope &Scope = unsafe { nil }

Check failure on line 16 in compiler/ast/File.v

View workflow job for this annotation

GitHub Actions / ubuntu-gcc

unknown type `compiler.ast.Scope`
errors int
mut:
lines ?[]string
Expand Down
14 changes: 7 additions & 7 deletions compiler/ast/FilePos.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

module ast

pub struct FileLoc {
pub:
pos int
line int
col int
}

pub struct FilePos {
pub mut:
file &File = unsafe { nil }
Expand All @@ -30,10 +37,3 @@ pub fn (fp &FilePos) str() string {
}
return '${fp.file.filename}:${fp.begin.line + 1}:${fp.begin.col}-${fp.end.line + 1}:${fp.end.col}'
}

pub struct FileLoc {
pub:
pos int
line int
col int
}
4 changes: 2 additions & 2 deletions compiler/context/mod.v
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ pub fn push(ctx &CContext) {

pub fn get() &CContext {
if stack == [] {
panic('empty ccontext stack')
panic('empty CContext stack')
}
return stack.last()
}

pub fn pop() {
if stack == [] {
panic('empty ccontext stack')
panic('empty CContext stack')
}
unsafe {
_ = stack.pop()
Expand Down

0 comments on commit 541fbd5

Please sign in to comment.