Skip to content

Commit 2cdf028

Browse files
committed
Context Value types are now done via Class's
1 parent 9d9ef44 commit 2cdf028

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

mustang/Context.ooc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import text/StringTokenizer
33

44

55
Value: abstract class {
6-
type: abstract func -> String
6+
type: abstract func -> Class
77
toString: abstract func -> String
88
}
99

@@ -12,7 +12,7 @@ StringValue: class extends Value {
1212

1313
init: func(=value) {}
1414

15-
type: func -> String { "String" }
15+
type: func -> Class { String }
1616
toString: func -> String { value }
1717
}
1818

@@ -21,7 +21,7 @@ BoolValue: class extends Value {
2121

2222
init: func(=value) {}
2323

24-
type: func -> String { "Bool" }
24+
type: func -> Class { Bool }
2525
toString: func -> String { value toString() }
2626

2727
isTrue: func -> Bool { value }
@@ -32,7 +32,7 @@ ListValue: class extends Value {
3232

3333
init: func(=list) {}
3434

35-
type: func -> String { "List" }
35+
type: func -> Class { List }
3636
toString: func -> String { "List size=%d" format(list size()) }
3737

3838
list: func -> List<Value> { list }
@@ -43,7 +43,7 @@ HashValue: class extends Value {
4343

4444
init: func(=hash) {}
4545

46-
type: func -> String { "Hash" }
46+
type: func -> Class { HashMap }
4747
toString: func -> String { "Hash" }
4848

4949
hash: func -> HashMap<Value> { hash }
@@ -90,7 +90,7 @@ Context: class {
9090
tokenizer := StringTokenizer new(expression, ' ')
9191
for(name: String in tokenizer) {
9292
next = currentHash get(name)
93-
if(!next || next type() != "Hash") break
93+
if(!next || next type() != HashMap) break
9494

9595
currentHash = (next as HashValue) hash()
9696
}

mustang/Node.ooc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import io/Writer
2+
import structs/[List, HashMap]
23
import mustang/[Context, Renderer]
34

45
/**
@@ -55,11 +56,11 @@ SectionNode: class extends TNode {
5556
Exception new("Variable '%s' not found in context!" format(variableName)) throw()
5657
}
5758

58-
if(variable type() == "List") {
59+
if(variable type() == List) {
5960
itemContext: Context
6061

6162
for(item: Value in (variable as ListValue) list()) {
62-
if(item type() == "Hash") {
63+
if(item type() == HashMap) {
6364
itemContext = (item as HashValue) toContext()
6465
}
6566
else {
@@ -70,7 +71,7 @@ SectionNode: class extends TNode {
7071
Renderer new(this firstChild) render(itemContext, out)
7172
}
7273
}
73-
else if(variable type() == "Bool") {
74+
else if(variable type() == Bool) {
7475
if((variable as BoolValue) isTrue()) {
7576
Renderer new(this firstChild) render(context, out)
7677
}

0 commit comments

Comments
 (0)