annotate editor.js @ 114:f2b435509301

Work around desugaring of && and || in editor.
author Mike Pavone <pavone@retrodev.com>
date Mon, 15 Apr 2013 09:34:32 -0700
parents c0bfff39abe3
children 9cf3e0b18ecc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3d1b8e96f5dc Initial commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1
3d1b8e96f5dc Initial commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
3 object.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
4 this.up = up;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
5 var el = newEl('div', {
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
6 className: 'object'
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
7 });
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
8 this.domNode = el;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
9 node.appendChild(el);
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
10 for (var i in this.messages) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
11 this.messages[i].toHTML(el, this);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
12 }
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
13 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
14
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
15 lambda.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
16 this.up = up
28
93bbc4c8be95 Allow selection of lambda
Mike Pavone <pavone@retrodev.com>
parents: 26
diff changeset
17 var astNode = this;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
18 var el = newEl('div', {
28
93bbc4c8be95 Allow selection of lambda
Mike Pavone <pavone@retrodev.com>
parents: 26
diff changeset
19 className: 'lambda',
29
18cec540238a Prevent event bubbling so lambda click handler doesn't get called when clicking on an element inside it
Mike Pavone <pavone@retrodev.com>
parents: 28
diff changeset
20 onclick: function(event) {
104
648659961e0e Get editor working again
Mike Pavone <pavone@retrodev.com>
parents: 29
diff changeset
21 main_module.lambdaClick(this, astNode, event);
28
93bbc4c8be95 Allow selection of lambda
Mike Pavone <pavone@retrodev.com>
parents: 26
diff changeset
22 }
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
23 });
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
24 this.domNode = el;
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
25 var args = newEl('div', {
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
26 className: 'args'
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
27 });
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
28 for (var i in this.args) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
29 this.args[i].toHTML(args, this);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
30 }
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
31 var body = newEl('div', {
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
32 className: 'lambdabody'
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
33 });
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
34 for (var i in this.expressions) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
35 this.expressions[i].toHTML(body, this);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
36 }
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
37 el.appendChild(args);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
38 el.appendChild(body);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
39 node.appendChild(el);
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
40 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
41
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
42 assignment.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
43 this.up = up;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
44 var base = newEl('div', {
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
45 className: 'assignment'
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
46 });
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
47 var varName = newEl('span', {
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
48 textContent: this.symbol.name + ' <-'
0
3d1b8e96f5dc Initial commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
49 });
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
50 this.domNode = base;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
51 base.appendChild(varName);
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
52 node.appendChild(base);
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
53 console.log(this.expression);
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
54 this.expression.toHTML(base, this);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
55 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
56
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
57 op.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
58 this.up = up;
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
59 var base = newEl('span', {
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
60 className: 'op'
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
61 });
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
62 this.domNode = base;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
63 this.left.toHTML(base, this);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
64 base.appendChild(newEl('span', {
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
65 textContent: this.op,
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
66 className: 'opname'
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
67 }));
114
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
68 if (this.op == '&&' || this.op == '||') {
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
69 this.right.expressions[0].toHTML(base, this);
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
70 } else {
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
71 this.right.toHTML(base, this);
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
72 }
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
73 node.appendChild(base);
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
74 };
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
75
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
76 intlit.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
77 this.up = up;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
78 this.domNode = newEl('span', {
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
79 className: 'integer',
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
80 textContent: this.val
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
81 });
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
82 node.appendChild(this.domNode);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
83 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
84
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
85 floatlit.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
86 this.up = up;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
87 this.domNode = newEl('span', {
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
88 className: 'float',
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
89 textContent: this.val
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
90 });
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
91 node.appendChild(this.domNode);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
92 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
93
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
94 strlit.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
95 this.up = up;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
96 this.domNode = newEl('span', {
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
97 className: 'string',
25
4d87c38404d6 List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents: 23
diff changeset
98 contentEditable: 'true',
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
99 textContent: this.val
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
100 });
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
101 node.appendChild(this.domNode);
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
102 };
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
103
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
104 listlit.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
105 this.up = up;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
106 this.domNode = newEl('span', {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
107 className: 'list',
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
108 });
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
109 for (var i = 0; i < this.val.length; i++) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
110 this.val[i].toHTML(this.domNode, this);
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
111 }
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
112 node.appendChild(this.domNode);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
113 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
114
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
115 arraylit.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
116 this.up = up;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
117 this.domNode = newEl('span', {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
118 className: 'array',
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
119 });
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
120 for (var i = 0; i < this.val.length; i++) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
121 this.val[i].toHTML(this.domNode, this);
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
122 }
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
123 node.appendChild(this.domNode);
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
124 };
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
125
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
126 funcall.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
127 this.up = up;
25
4d87c38404d6 List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents: 23
diff changeset
128 var astNode = this;
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
129 var base = newEl('div', {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
130 className: 'funcall',
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
131 onclick: function(event) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
132 main_module.funClick(this, astNode, event);
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
133 }
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
134 });
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
135 this.domNode = base;
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
136 if (this.receiver) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
137 this.receiver.toHTML(base, this);
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
138 }
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
139 var parts = this.name.split(':');
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
140 for (var i in parts ) {
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
141 if(parts[i]) {
25
4d87c38404d6 List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents: 23
diff changeset
142 base.appendChild(newEl('span', {
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
143 textContent: parts[i] + (this.receiver && parts.length == 1 ? '' : ':'),
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
144 className: 'funpart'
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
145 }));
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
146 if (this.args[i]) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
147 this.args[i].toHTML(base, this);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
148 }
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
149 }
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
150 }
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
151 for (; i < this.args.length; i++) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
152 this.args[i].toHTML(base, this);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
153 }
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
154 node.appendChild(base);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
155 };
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
156
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
157 symbol.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
158 this.up = up;
23
068d63627b16 Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents: 15
diff changeset
159 var astNode = this;
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
160 this.domNode = newEl('span', {
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
161 className: 'symbol',
23
068d63627b16 Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents: 15
diff changeset
162 textContent: this.name,
29
18cec540238a Prevent event bubbling so lambda click handler doesn't get called when clicking on an element inside it
Mike Pavone <pavone@retrodev.com>
parents: 28
diff changeset
163 onclick: function(event) {
105
35006a6e1c47 Fixed more editor coderot and improved syntax/selection coloring a bit.
Mike Pavone <pavone@retrodev.com>
parents: 104
diff changeset
164 main_module.symbolClick(this, astNode, event);
23
068d63627b16 Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents: 15
diff changeset
165 }
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
166 })
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
167 node.appendChild(this.domNode);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
168 }
110
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
169
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
170 function getEl(from, idx)
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
171 {
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
172 return from[idx];
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
173 }
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
174
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
175 function setEl(to, idx, val)
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
176 {
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
177 to[idx] = val;
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
178 return to;
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
179 }