Skip to content

Commit

Permalink
Merge pull request #289 from DanielGavin/poly
Browse files Browse the repository at this point in the history
New poly resolve system
  • Loading branch information
DanielGavin authored Feb 3, 2024
2 parents d7531bd + b7145b0 commit 1e87c5b
Show file tree
Hide file tree
Showing 12 changed files with 1,301 additions and 757 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*.ll
*.sublime-project
*.sublime-workspace
*.vscode
*.lib
*.exp
*.sqlite
Expand Down
2 changes: 1 addition & 1 deletion editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "git://github.com/DanielGavin/ols.git"
},
"version": "0.1.16",
"version": "0.1.23",
"engines": {
"vscode": "^1.66.0"
},
Expand Down
35 changes: 27 additions & 8 deletions src/common/ast.odin
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ get_attribute_objc_is_class_method :: proc(
return false
}

unwrap_pointer :: proc(expr: ^ast.Expr) -> (ast.Ident, int, bool) {
unwrap_pointer_ident :: proc(expr: ^ast.Expr) -> (ast.Ident, int, bool) {
n := 0
expr := expr
for expr != nil {
Expand All @@ -186,6 +186,25 @@ unwrap_pointer :: proc(expr: ^ast.Expr) -> (ast.Ident, int, bool) {
return {}, n, false
}

unwrap_pointer_expr :: proc(expr: ^ast.Expr) -> (^ast.Expr, int, bool) {
n := 0
expr := expr
for expr != nil {
if pointer, ok := expr.derived.(^ast.Pointer_Type); ok {
expr = pointer.elem
n += 1
} else {
break
}
}

if expr == nil {
return {}, n, false
}

return expr, n, true
}

is_expr_basic_lit :: proc(expr: ^ast.Expr) -> bool {
_, ok := expr.derived.(^ast.Basic_Lit)
return ok
Expand All @@ -198,10 +217,10 @@ collect_value_decl :: proc(
skip_private: bool,
) {
if value_decl, ok := stmt.derived.(^ast.Value_Decl); ok {
is_deprecated := false
is_deprecated := false
is_private_file := false
is_private_pkg := false
is_builtin := false
is_private_pkg := false
is_builtin := false

for attribute in value_decl.attributes {
for elem in attribute.elems {
Expand Down Expand Up @@ -238,7 +257,7 @@ collect_value_decl :: proc(
if is_private_file && skip_private {
return
}

// If a private status is not explicitly set with an attribute above the declaration
// check the file comment.
if !is_private_file && !is_private_pkg && file.docs != nil {
Expand All @@ -247,7 +266,7 @@ collect_value_decl :: proc(
if strings.has_prefix(txt, "//+private") {
txt = strings.trim_prefix(txt, "//+private")
is_private_pkg = true

if strings.has_prefix(txt, " ") {
txt = strings.trim_space(txt)
if txt == "file" {
Expand All @@ -264,7 +283,7 @@ collect_value_decl :: proc(
if value_decl.type != nil {
append(
exprs,
GlobalExpr{
GlobalExpr {
name = str,
name_expr = name,
expr = value_decl.type,
Expand All @@ -280,7 +299,7 @@ collect_value_decl :: proc(
if len(value_decl.values) > i {
append(
exprs,
GlobalExpr{
GlobalExpr {
name = str,
name_expr = name,
expr = value_decl.values[i],
Expand Down
Loading

0 comments on commit 1e87c5b

Please sign in to comment.