From 541fbd5c5b167eafca96c9b72d6cf982e523e869 Mon Sep 17 00:00:00 2001 From: StunxFS Date: Tue, 3 Dec 2024 12:01:43 -0400 Subject: [PATCH] ast: basic scope (wip) --- compiler/ast/File.v | 1 + compiler/ast/FilePos.v | 14 +++++++------- compiler/context/mod.v | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/compiler/ast/File.v b/compiler/ast/File.v index 4953d5d9..df87bd94 100644 --- a/compiler/ast/File.v +++ b/compiler/ast/File.v @@ -13,6 +13,7 @@ pub: content string mod_name string pub mut: + scope &Scope = unsafe { nil } errors int mut: lines ?[]string diff --git a/compiler/ast/FilePos.v b/compiler/ast/FilePos.v index 17d2623a..6513495d 100644 --- a/compiler/ast/FilePos.v +++ b/compiler/ast/FilePos.v @@ -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 } @@ -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 -} diff --git a/compiler/context/mod.v b/compiler/context/mod.v index 573e5ac8..17b132cb 100644 --- a/compiler/context/mod.v +++ b/compiler/context/mod.v @@ -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()