Skip to content

Commit 2ef535a

Browse files
committed
0.33.1
1 parent 13c814a commit 2ef535a

6 files changed

Lines changed: 26 additions & 9 deletions

File tree

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.33.1
4+
5+
- (Fix) procedure execution from dot notation didn't enter the scope of the accessed dictionaries.
6+
37
## 0.33.0
48

59
- Added the 'alpha?', 'digit?', 'alphadigit?', 'sb-init', 'sb-addstr', 'sb-addbyte', and 'sb-build' operators to the 'strings' internal library

contrib.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ Basically, be polite to everyone and use common sense.
77
## Repository structure
88

99
- `examples/` - the language examples; just various snippets I wrote to show off the language.
10-
- `out/`, `dist/` - the binary output folders, these contains the resulting executables and the zip files created from them, respectively; these should **always** be gitignored.
10+
- `bin/`, `dist/` - the binary output folders, these contains the resulting executables and the zip files created from them, respectively; these should **always** be gitignored.
1111
- `src/builtins.nim` - the builtin functions that are always available without importing.
1212
- `src/builtinlibs/` - the internal libraries that come built into Page, such as `strings` and `http`.
13-
- `src/valueimpls` - the implementations for the individual value objects, which get `include`'d into `src/values.nim`; this folder may get removed in the future, see item No. 1 of [todo.md](/todo.md)
1413
- `src/std/` - the parts of the standard library implementated in Page that are written to `~/.page/std/`.
1514
- `src/data/` - miscellaneous data that gets included into the binary at compile-time.
1615

@@ -22,7 +21,7 @@ Differences and/or specifics are:
2221

2322
- Imports, type definitions, and functions should be separated by two lines instead of one. See [parser.nim](/src/parser.nim) for an example.
2423

25-
- If an import is from a different namespace, it should be prefixed with `pkg/` and `std/`, respectively. See [builtins.nim](/src/builtins.nim) for an example.
24+
- If an import is from a different namespace, it should be prefixed with `pkg/` or `std/`. See [builtins.nim](/src/builtins.nim) for an example.
2625

2726
- Single item imports/exports should be on a single line. See [builtins.nim](/src/builtins.nim) for an example.
2827

page.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "0.33.0"
3+
version = "0.33.1"
44
author = "Nuclear Pasta"
55
description = "A PostScript-like language"
66
license = "Apache-2.0"

src/builtinlibs/common.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ proc literalize*(s: State, nodes: seq[Node]): seq[Value] =
7676
result[i] = newProcedure(@[], proc(sptr: pointer, ps: ProcState) =
7777
let
7878
s = cast[State](sptr)
79-
(literal, v) = s.nestedGet(n)
79+
(literal, _, v) = s.nestedGet(n)
8080

8181
if v.typ == tProcedure and not literal:
8282
s.check(v.args)

src/interpreter.nim

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,16 @@ proc exec(self: Interpreter, n: Node) =
103103
logger.logdv("Word is not a function")
104104
self.state.push(v)
105105
of nDot:
106-
let (literal, v) = self.state.nestedGet(n)
106+
let
107+
origScopeCount = self.state.dicts.len
108+
(literal, scopes, v) = self.state.nestedGet(n)
109+
110+
for d in scopes:
111+
self.state.dbegin(d)
112+
113+
defer:
114+
for _ in 0..<scopes.len - (self.state.dicts.len - origScopeCount):
115+
discard self.state.dend(self.pstate)
107116

108117
if v.typ == tProcedure and not literal:
109118
self.state.check(v.args)

src/state.nim

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,15 @@ proc unset*(self: State, name: string): bool =
122122
result = d.hasKey(name)
123123
d.del(name)
124124

125-
proc nestedGet*(self: State, node: Node): tuple[literal: bool, val: Value] =
125+
proc nestedGet*(self: State, node: Node): tuple[literal: bool, scopes: seq[Dict], val: Value] =
126126
if node.typ != nDot:
127127
panic("Node is not nDot")
128128

129129
let d =
130130
if node.left.typ == nDot:
131-
self.nestedGet(node.left).val
131+
let (_, scopes, v) = self.nestedGet(node.left)
132+
result.scopes.add(scopes)
133+
v
132134
else:
133135
self.get(node.left.tok.lit)
134136

@@ -143,12 +145,15 @@ proc nestedGet*(self: State, node: Node): tuple[literal: bool, val: Value] =
143145
t = d.dictv
144146
name = node.right.tok.lit
145147

148+
result.scopes.add(t)
149+
146150
if not t.hasKey(name):
147151
let e = newPgError(fmt"Undefined symbol '{name}'")
148152
e.addTrace(node.right.trace())
149153
raise e
150154

151-
result = (node.right.typ == nSymbol, t[name])
155+
result.literal = node.right.typ == nSymbol
156+
result.val = t[name]
152157

153158
proc push*(self: State, val: Value) =
154159
self.stack.add(val)

0 commit comments

Comments
 (0)