diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-02-19 21:17:46 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-02-19 21:17:53 +0000 |
| commit | e62ef99244bb3aa906810a5cfd53c0dac68b0f37 (patch) | |
| tree | e7379e2add7014e7124f678f4a7a8edc699fe914 /core/scope.moon | |
| parent | major refactoring: Const, Stream + ResultNode (diff) | |
| download | alive-e62ef99244bb3aa906810a5cfd53c0dac68b0f37.tar.gz alive-e62ef99244bb3aa906810a5cfd53c0dac68b0f37.zip | |
merge Const and Stream into Value; Dataflow logic
lib not fully ported / functonial
Diffstat (limited to 'core/scope.moon')
| -rw-r--r-- | core/scope.moon | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/core/scope.moon b/core/scope.moon index aaa38f2..f795f97 100644 --- a/core/scope.moon +++ b/core/scope.moon @@ -1,12 +1,16 @@ -import Value from require 'core.value' +import Result, Value from require 'core.value' class Scope new: (@node, @parent) => @values = {} - set_raw: (key, val) => @values[key] = Value.wrap val, key + set_raw: (key, val) => + value = Value.wrap val, key + @values[key] = Result :value + set: (key, val) => L\trace "setting #{key} = #{val} in #{@}" + assert val.__class == Result, "expected #{key}=#{val} to be Result" @values[key] = val get: (key, prefix='') => @@ -20,9 +24,9 @@ class Scope if not start return @parent and L\push -> @parent\get key - scope = @get start - assert scope and scope.type == 'scope', "cant find '#{prefix}#{start}' for '#{prefix}#{key}'" - scope\unwrap!\get rest, "#{prefix}#{start}/" + child = @get start + assert child and child.value.type == 'scope', "#{start} is not a scope (looking for #{key})" + child.value\unwrap!\get rest, "#{prefix}#{start}/" use: (other) => L\trace "using defs from #{other} in #{@}" @@ -31,7 +35,8 @@ class Scope from_table: (tbl) -> with Scope! - .values = { k, Value.wrap v, k for k,v in pairs tbl } + for k, v in pairs tbl + \set_raw k, v __tostring: => buf = "<Scope" |
