-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
node.go
70 lines (56 loc) · 1.41 KB
/
node.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package html_ns
import (
"github.com/inoxlang/inox/internal/core/symbolic"
"github.com/inoxlang/inox/internal/prettyprint"
pprint "github.com/inoxlang/inox/internal/prettyprint"
)
var (
HTML_NODE_PROPNAMES = []string{"first-child", "data"}
_ symbolic.Watchable = (*HTMLNode)(nil)
ANY_HTML_NODE = &HTMLNode{}
)
type HTMLNode struct {
symbolic.UnassignablePropsMixin
symbolic.SerializableMixin
}
func NewHTMLNode() *HTMLNode {
return &HTMLNode{}
}
func (n *HTMLNode) Test(v symbolic.Value, state symbolic.RecTestCallState) bool {
state.StartCall()
defer state.FinishCall()
_, ok := v.(*HTMLNode)
if !ok {
return false
}
return true
}
func (n *HTMLNode) Prop(name string) symbolic.Value {
switch name {
case "first-child":
return NewHTMLNode()
case "data":
return symbolic.ANY_STRING
default:
method, ok := n.GetGoMethod(name)
if !ok {
panic(symbolic.FormatErrPropertyDoesNotExist(name, n))
}
return method
}
}
func (n *HTMLNode) GetGoMethod(name string) (*symbolic.GoFunction, bool) {
return nil, false
}
func (n *HTMLNode) PropertyNames() []string {
return HTML_NODE_PROPNAMES
}
func (n *HTMLNode) WatcherElement() symbolic.Value {
return symbolic.ANY
}
func (n *HTMLNode) PrettyPrint(w prettyprint.PrettyPrintWriter, config *pprint.PrettyPrintConfig) {
w.WriteName("html-node")
}
func (r *HTMLNode) WidestOfType() symbolic.Value {
return &HTMLNode{}
}