1 using System;
2 using System.Collections;
3
4
5
6
7
8 namespace soulcm.scmpg
9 {
10 public class CodeEmittingVisitor : Cm.Ast.Visitor
11 {
12 public CodeEmittingVisitor(bool valueOfPtrType_, const ustring& nonterminalName_, const List<NonterminalInfo>& nonterminalInfos_, Cm.Ast.Node* returnType_,
13 bool noParserDebugSupport_, const ustring& parserName_, const Uuid& moduleId_) :
14 valueOfPtrType(valueOfPtrType_), nonterminalName(nonterminalName_), nonterminalInfos(nonterminalInfos_), returnType(returnType_),
15 noParserDebugSupport(noParserDebugSupport_), parserName(parserName_), moduleId(moduleId_)
16 {
17 }
18 public Cm.Ast.CompoundStatementNode* GetCode()
19 {
20 if (!node.IsNull() && node->GetNodeType() == NodeType.compoundStatementNode)
21 {
22 return cast<Cm.Ast.CompoundStatementNode*>(node.Release());
23 }
24 else
25 {
26 throw Exception("no code");
27 }
28 }
29 public override void Visit(Cm.Ast.IdentifierNode& identifierNode)
30 {
31 Cm.Ast.CloneContext cloneContext;
32 bool set = false;
33 for (NonterminalInfo& info : nonterminalInfos)
34 {
35 if (identifierNode.Str() == info.name)
36 {
37 if (info.ptrType)
38 {
39 node.Reset(new Cm.Ast.InvokeNode(System.Lex.Span(), moduleId, new Cm.Ast.DotNode(System.Lex.Span(), moduleId, cast<Cm.Ast.IdentifierNode*>(identifierNode.Clone(cloneContext)), new Cm.Ast.IdentifierNode(System.Lex.Span(), moduleId, u"Release"))));
40 set = true;
41 break;
42 }
43 else
44 {
45 node.Reset(new Cm.Ast.ArrowNode(System.Lex.Span(), moduleId, identifierNode.Clone(cloneContext), new Cm.Ast.IdentifierNode(System.Lex.Span(), moduleId, u"value")));
46 set = true;
47 break;
48 }
49 }
50 }
51 if (!set)
52 {
53 node.Reset(new Cm.Ast.IdentifierNode(System.Lex.Span(), moduleId, identifierNode.Str()));
54 }
55 }
56 public override void Visit(Cm.Ast.BoolNode& boolNode)
57 {
58 node.Reset(new Cm.Ast.BoolNode(System.Lex.Span(), moduleId));
59 }
60 public override void Visit(Cm.Ast.SByteNode& sbyteNode)
61 {
62 node.Reset(new Cm.Ast.SByteNode(System.Lex.Span(), moduleId));
63 }
64 public override void Visit(Cm.Ast.ByteNode& byteNode)
65 {
66 node.Reset(new Cm.Ast.ByteNode(System.Lex.Span(), moduleId));
67 }
68 public override void Visit(Cm.Ast.ShortNode& shortNode)
69 {
70 node.Reset(new Cm.Ast.ShortNode(System.Lex.Span(), moduleId));
71 }
72 public override void Visit(Cm.Ast.UShortNode& ushortNode)
73 {
74 node.Reset(new Cm.Ast.UShortNode(System.Lex.Span(), moduleId));
75 }
76 public override void Visit(Cm.Ast.IntNode& intNode)
77 {
78 node.Reset(new Cm.Ast.IntNode(System.Lex.Span(), moduleId));
79 }
80 public override void Visit(Cm.Ast.UIntNode& uintNode)
81 {
82 node.Reset(new Cm.Ast.UIntNode(System.Lex.Span(), moduleId));
83 }
84 public override void Visit(Cm.Ast.LongNode& longNode)
85 {
86 node.Reset(new Cm.Ast.LongNode(System.Lex.Span(), moduleId));
87 }
88 public override void Visit(Cm.Ast.ULongNode& ulongNode)
89 {
90 node.Reset(new Cm.Ast.ULongNode(System.Lex.Span(), moduleId));
91 }
92 public override void Visit(Cm.Ast.FloatNode& floatNode)
93 {
94 node.Reset(new Cm.Ast.FloatNode(System.Lex.Span(), moduleId));
95 }
96 public override void Visit(Cm.Ast.DoubleNode& doubleNode)
97 {
98 node.Reset(new Cm.Ast.DoubleNode(System.Lex.Span(), moduleId));
99 }
100 public override void Visit(Cm.Ast.CharNode& charNode)
101 {
102 node.Reset(new Cm.Ast.CharNode(System.Lex.Span(), moduleId));
103 }
104 public override void Visit(Cm.Ast.WCharNode& wcharNode)
105 {
106 node.Reset(new Cm.Ast.WCharNode(System.Lex.Span(), moduleId));
107 }
108 public override void Visit(Cm.Ast.UCharNode& ucharNode)
109 {
110 node.Reset(new Cm.Ast.UCharNode(System.Lex.Span(), moduleId));
111 }
112 public override void Visit(Cm.Ast.VoidNode& voidNode)
113 {
114 node.Reset(new Cm.Ast.VoidNode(System.Lex.Span(), moduleId));
115 }
116 public override void Visit(Cm.Ast.BooleanLiteralNode& booleanLiteralNode)
117 {
118 Cm.Ast.CloneContext cloneContext;
119 node.Reset(booleanLiteralNode.Clone(cloneContext));
120 }
121 public override void Visit(Cm.Ast.SByteLiteralNode& sbyteLiteralNode)
122 {
123 Cm.Ast.CloneContext cloneContext;
124 node.Reset(sbyteLiteralNode.Clone(cloneContext));
125 }
126 public override void Visit(Cm.Ast.ByteLiteralNode& byteLiteralNode)
127 {
128 Cm.Ast.CloneContext cloneContext;
129 node.Reset(byteLiteralNode.Clone(cloneContext));
130 }
131 public override void Visit(Cm.Ast.ShortLiteralNode& shortLiteralNode)
132 {
133 Cm.Ast.CloneContext cloneContext;
134 node.Reset(shortLiteralNode.Clone(cloneContext));
135 }
136 public override void Visit(Cm.Ast.UShortLiteralNode& ushortLiteralNode)
137 {
138 Cm.Ast.CloneContext cloneContext;
139 node.Reset(ushortLiteralNode.Clone(cloneContext));
140 }
141 public override void Visit(Cm.Ast.IntLiteralNode& intLiteralNode)
142 {
143 Cm.Ast.CloneContext cloneContext;
144 node.Reset(intLiteralNode.Clone(cloneContext));
145 }
146 public override void Visit(Cm.Ast.UIntLiteralNode& uintLiteralNode)
147 {
148 Cm.Ast.CloneContext cloneContext;
149 node.Reset(uintLiteralNode.Clone(cloneContext));
150 }
151 public override void Visit(Cm.Ast.LongLiteralNode& longLiteralNode)
152 {
153 Cm.Ast.CloneContext cloneContext;
154 node.Reset(longLiteralNode.Clone(cloneContext));
155 }
156 public override void Visit(Cm.Ast.ULongLiteralNode& ulongLiteralNode)
157 {
158 Cm.Ast.CloneContext cloneContext;
159 node.Reset(ulongLiteralNode.Clone(cloneContext));
160 }
161 public override void Visit(Cm.Ast.FloatLiteralNode& floatLiteralNode)
162 {
163 Cm.Ast.CloneContext cloneContext;
164 node.Reset(floatLiteralNode.Clone(cloneContext));
165 }
166 public override void Visit(Cm.Ast.DoubleLiteralNode& doubleLiteralNode)
167 {
168 Cm.Ast.CloneContext cloneContext;
169 node.Reset(doubleLiteralNode.Clone(cloneContext));
170 }
171 public override void Visit(Cm.Ast.CharLiteralNode& charLiteralNode)
172 {
173 Cm.Ast.CloneContext cloneContext;
174 node.Reset(charLiteralNode.Clone(cloneContext));
175 }
176 public override void Visit(Cm.Ast.WCharLiteralNode& wcharLiteralNode)
177 {
178 Cm.Ast.CloneContext cloneContext;
179 node.Reset(wcharLiteralNode.Clone(cloneContext));
180 }
181 public override void Visit(Cm.Ast.UCharLiteralNode& ucharLiteralNode)
182 {
183 Cm.Ast.CloneContext cloneContext;
184 node.Reset(ucharLiteralNode.Clone(cloneContext));
185 }
186 public override void Visit(Cm.Ast.StringLiteralNode& stringLiteralNode)
187 {
188 Cm.Ast.CloneContext cloneContext;
189 node.Reset(stringLiteralNode.Clone(cloneContext));
190 }
191 public override void Visit(Cm.Ast.WStringLiteralNode& wstringLiteralNode)
192 {
193 Cm.Ast.CloneContext cloneContext;
194 node.Reset(wstringLiteralNode.Clone(cloneContext));
195 }
196 public override void Visit(Cm.Ast.UStringLiteralNode& ustringLiteralNode)
197 {
198 Cm.Ast.CloneContext cloneContext;
199 node.Reset(ustringLiteralNode.Clone(cloneContext));
200 }
201 public override void Visit(Cm.Ast.NullLiteralNode& nullLiteralNode)
202 {
203 Cm.Ast.CloneContext cloneContext;
204 node.Reset(nullLiteralNode.Clone(cloneContext));
205 }
206 public override void Visit(Cm.Ast.ArrayLiteralNode& arrayLiteralNode)
207 {
208 Cm.Ast.ArrayLiteralNode* clone = new Cm.Ast.ArrayLiteralNode(System.Lex.Span(), moduleId);
209 int n = arrayLiteralNode.Values().Count();
210 for (int i = 0; i < n; ++i;)
211 {
212 arrayLiteralNode.Values()[i]->Accept(*this);
213 clone->AddValue(node.Release());
214 }
215 node.Reset(clone);
216 }
217 public override void Visit(Cm.Ast.StructuredLiteralNode& structuredLiteralNode)
218 {
219 Cm.Ast.StructuredLiteralNode* clone = new Cm.Ast.StructuredLiteralNode(System.Lex.Span(), moduleId);
220 int n = structuredLiteralNode.Members().Count();
221 for (int i = 0; i < n; ++i;)
222 {
223 structuredLiteralNode.Members()[i]->Accept(*this);
224 clone->AddMember(node.Release());
225 }
226 node.Reset(clone);
227 }
228 public override void Visit(Cm.Ast.UuidLiteralNode& uuidLiteralNode)
229 {
230 Cm.Ast.CloneContext cloneContext;
231 node.Reset(uuidLiteralNode.Clone(cloneContext));
232 }
233 public override void Visit(Cm.Ast.LabeledStatementNode& labeledStatementNode)
234 {
235 labeledStatementNode.Stmt()->Accept(*this);
236 Cm.Ast.LabeledStatementNode* clone = new Cm.Ast.LabeledStatementNode(System.Lex.Span(), moduleId, cast<Cm.Ast.StatementNode*>(node.Release()));
237 Cm.Ast.CloneContext cloneContext;
238 clone->SetLabelNode(cast<Cm.Ast.LabelNode*>(labeledStatementNode.Label()->Clone(cloneContext)));
239 node.Reset(clone);
240 }
241 public override void Visit(Cm.Ast.CompoundStatementNode& compoundStatementNode)
242 {
243 Cm.Ast.CompoundStatementNode* clone = new Cm.Ast.CompoundStatementNode(System.Lex.Span(), moduleId);
244 int n = compoundStatementNode.Statements().Count();
245 for (int i = 0; i < n; ++i;)
246 {
247 compoundStatementNode.Statements()[i]->Accept(*this);
248 clone->AddStatement(cast<Cm.Ast.StatementNode*>(node.Release()));
249 }
250 node.Reset(clone);
251 }
252 public override void Visit(Cm.Ast.ReturnStatementNode& returnStatementNode)
253 {
254 Cm.Ast.CloneContext cloneContext;
255 Cm.Ast.Node* retVal = null;
256 if ((returnStatementNode.Expression() != null))
257 {
258 Cm.Ast.InvokeNode* returnValue = new Cm.Ast.InvokeNode(System.Lex.Span(), moduleId, new Cm.Ast.IdentifierNode(System.Lex.Span(), moduleId, u"Match"));
259 retVal = returnValue;
260 returnValue->AddArgument(new Cm.Ast.BooleanLiteralNode(System.Lex.Span(), moduleId, true));
261 returnStatementNode.Expression()->Accept(*this);
262 if (valueOfPtrType)
263 {
264 returnValue->AddArgument(node.Release());
265 }
266 else
267 {
268 Cm.Ast.TemplateIdNode* valueType = new Cm.Ast.TemplateIdNode(System.Lex.Span(), moduleId, new Cm.Ast.IdentifierNode(System.Lex.Span(), moduleId, u"Value"));
269 valueType->AddTemplateArgument(returnType->Clone(cloneContext));
270 Cm.Ast.NewNode* newNode = new Cm.Ast.NewNode(System.Lex.Span(), moduleId, valueType);
271 newNode->AddArgument(node.Release());
272 returnValue->AddArgument(newNode);
273 }
274 }
275 node.Reset(new Cm.Ast.ReturnStatementNode(System.Lex.Span(), moduleId, retVal));
276 if (!noParserDebugSupport)
277 {
278 Cm.Ast.CompoundStatementNode* debugBlock = new Cm.Ast.CompoundStatementNode(System.Lex.Span(), moduleId);
279 Cm.Ast.ConditionalCompilationStatementNode* ccstmt = new Cm.Ast.ConditionalCompilationStatementNode(System.Lex.Span(), moduleId, new Cm.Ast.ConditionalCompilationPrimaryNode(System.Lex.Span(), moduleId, u"DEBUG"));
280 Cm.Ast.InvokeNode* writeSuccessToLog = new Cm.Ast.InvokeNode(System.Lex.Span(), moduleId, new Cm.Ast.DotNode(System.Lex.Span(), moduleId, new Cm.Ast.DotNode(System.Lex.Span(), moduleId, new Cm.Ast.IdentifierNode(System.Lex.Span(), moduleId, u"System"), new Cm.Ast.IdentifierNode(System.Lex.Span(), moduleId, u"Lex")), new Cm.Ast.IdentifierNode(System.Lex.Span(), moduleId, u"WriteSuccessToLog")));
281 writeSuccessToLog->AddArgument(new Cm.Ast.IdentifierNode(System.Lex.Span(), moduleId, u"lexer"));
282 writeSuccessToLog->AddArgument(new Cm.Ast.IdentifierNode(System.Lex.Span(), moduleId, u"debugSpan"));
283 writeSuccessToLog->AddArgument(new Cm.Ast.UStringLiteralNode(System.Lex.Span(), moduleId, parserName));
284 Cm.Ast.ExpressionStatementNode* expressionStmt = new Cm.Ast.ExpressionStatementNode(System.Lex.Span(), moduleId, writeSuccessToLog);
285 Cm.Ast.IfStatementNode* ifS = new Cm.Ast.IfStatementNode(System.Lex.Span(), moduleId, new Cm.Ast.IdentifierNode(System.Lex.Span(), moduleId, u"writeToLog"), expressionStmt, null);
286 ccstmt->AddIfStatement(ifS);
287 debugBlock->AddStatement(ccstmt);
288 debugBlock->AddStatement(cast<Cm.Ast.StatementNode*>(node.Release()));
289 node.Reset(debugBlock);
290 }
291 }
292 public override void Visit(Cm.Ast.IfStatementNode& ifStatementNode)
293 {
294 ifStatementNode.Condition()->Accept(*this);
295 Cm.Ast.Node* cond = node.Release();
296 ifStatementNode.ThenS()->Accept(*this);
297 Cm.Ast.StatementNode* thenS = cast<Cm.Ast.StatementNode*>(node.Release());
298 Cm.Ast.StatementNode* elseS = null;
299 if ((ifStatementNode.ElseS() != null))
300 {
301 ifStatementNode.ElseS()->Accept(*this);
302 elseS = cast<Cm.Ast.StatementNode*>(node.Release());
303 }
304 Cm.Ast.IfStatementNode* clone = new Cm.Ast.IfStatementNode(System.Lex.Span(), moduleId, cond, thenS, elseS);
305 node.Reset(clone);
306 }
307 public override void Visit(Cm.Ast.WhileStatementNode& whileStatementNode)
308 {
309 whileStatementNode.Condition()->Accept(*this);
310 Cm.Ast.Node* cond = node.Release();
311 whileStatementNode.Statement()->Accept(*this);
312 Cm.Ast.StatementNode* stmt = cast<Cm.Ast.StatementNode*>(node.Release());
313 Cm.Ast.WhileStatementNode* clone = new Cm.Ast.WhileStatementNode(System.Lex.Span(), moduleId, cond, stmt);
314 node.Reset(clone);
315 }
316 public override void Visit(Cm.Ast.DoStatementNode& doStatementNode)
317 {
318 doStatementNode.Statement()->Accept(*this);
319 Cm.Ast.StatementNode* stmt = cast<Cm.Ast.StatementNode*>(node.Release());
320 doStatementNode.Condition()->Accept(*this);
321 Cm.Ast.Node* cond = node.Release();
322 Cm.Ast.DoStatementNode* clone = new Cm.Ast.DoStatementNode(System.Lex.Span(), moduleId, stmt, cond);
323 node.Reset(clone);
324 }
325 public override void Visit(Cm.Ast.ForStatementNode& forStatementNode)
326 {
327 forStatementNode.InitS()->Accept(*this);
328 Cm.Ast.StatementNode* initS = cast<Cm.Ast.StatementNode*>(node.Release());
329 Cm.Ast.Node* cond = null;
330 if ((forStatementNode.Condition() != null))
331 {
332 forStatementNode.Condition()->Accept(*this);
333 cond = node.Release();
334 }
335 forStatementNode.LoopS()->Accept(*this);
336 Cm.Ast.StatementNode* loopS = cast<Cm.Ast.StatementNode*>(node.Release());
337 forStatementNode.ActionS()->Accept(*this);
338 Cm.Ast.StatementNode* actionS = cast<Cm.Ast.StatementNode*>(node.Release());
339 Cm.Ast.ForStatementNode* clone = new Cm.Ast.ForStatementNode(System.Lex.Span(), moduleId, initS, cond, loopS, actionS);
340 node.Reset(clone);
341 }
342 public override void Visit(Cm.Ast.BreakStatementNode& breakStatementNode)
343 {
344 node.Reset(new Cm.Ast.BreakStatementNode(System.Lex.Span(), moduleId));
345 }
346 public override void Visit(Cm.Ast.ContinueStatementNode& continueStatementNode)
347 {
348 node.Reset(new Cm.Ast.ContinueStatementNode(System.Lex.Span(), moduleId));
349 }
350 public override void Visit(Cm.Ast.GotoStatementNode& gotoStatementNode)
351 {
352 Cm.Ast.GotoStatementNode* clone = new Cm.Ast.GotoStatementNode(System.Lex.Span(), moduleId, gotoStatementNode.Target());
353 node.Reset(clone);
354 }
355 public override void Visit(Cm.Ast.ConstructionStatementNode& constructionStatementNode)
356 {
357 constructionStatementNode.TypeExpr()->Accept(*this);
358 Cm.Ast.Node* typeExpr = node.Release();
359 constructionStatementNode.Id()->Accept(*this);
360 Cm.Ast.IdentifierNode* id = cast<Cm.Ast.IdentifierNode*>(node.Release());
361 Cm.Ast.ConstructionStatementNode* clone = new Cm.Ast.ConstructionStatementNode(System.Lex.Span(), moduleId, typeExpr, id);
362 if (constructionStatementNode.Empty())
363 {
364 clone->SetEmpty();
365 }
366 else
367 {
368 if (constructionStatementNode.Assignment())
369 {
370 clone->SetAssignment();
371 }
372 int n = constructionStatementNode.Arguments().Count();
373 for (int i = 0; i < n; ++i;)
374 {
375 constructionStatementNode.Arguments()[i]->Accept(*this);
376 clone->AddArgument(node.Release());
377 }
378 }
379 node.Reset(clone);
380 }
381 public override void Visit(Cm.Ast.DeleteStatementNode& deleteStatementNode)
382 {
383 deleteStatementNode.Expression()->Accept(*this);
384 Cm.Ast.DeleteStatementNode* clone = new Cm.Ast.DeleteStatementNode(System.Lex.Span(), moduleId, node.Release());
385 node.Reset(clone);
386 }
387 public override void Visit(Cm.Ast.DestroyStatementNode& destroyStatementNode)
388 {
389 destroyStatementNode.Expression()->Accept(*this);
390 Cm.Ast.DestroyStatementNode* clone = new Cm.Ast.DestroyStatementNode(System.Lex.Span(), moduleId, node.Release());
391 node.Reset(clone);
392 }
393 public override void Visit(Cm.Ast.AssignmentStatementNode& assignmentStatementNode)
394 {
395 assignmentStatementNode.TargetExpr()->Accept(*this);
396 Cm.Ast.Node* targetExpr = node.Release();
397 assignmentStatementNode.SourceExpr()->Accept(*this);
398 Cm.Ast.Node* sourceExpr = node.Release();
399 node.Reset(new Cm.Ast.AssignmentStatementNode(System.Lex.Span(), moduleId, targetExpr, sourceExpr));
400 }
401 public override void Visit(Cm.Ast.ExpressionStatementNode& expressionStatementNode)
402 {
403 expressionStatementNode.Expression()->Accept(*this);
404 node.Reset(new Cm.Ast.ExpressionStatementNode(System.Lex.Span(), moduleId, node.Release()));
405 }
406 public override void Visit(Cm.Ast.EmptyStatementNode& emptyStatementNode)
407 {
408 node.Reset(new Cm.Ast.EmptyStatementNode(System.Lex.Span(), moduleId));
409 }
410 public override void Visit(Cm.Ast.RangeForStatementNode& rangeForStatementNode)
411 {
412 rangeForStatementNode.TypeExpr()->Accept(*this);
413 Cm.Ast.Node* typeExpr = node.Release();
414 rangeForStatementNode.Id()->Accept(*this);
415 Cm.Ast.IdentifierNode* id = cast<Cm.Ast.IdentifierNode*>(node.Release());
416 rangeForStatementNode.Container()->Accept(*this);
417 Cm.Ast.Node* container = node.Release();
418 rangeForStatementNode.Action()->Accept(*this);
419 Cm.Ast.StatementNode* action = cast<Cm.Ast.StatementNode*>(node.Release());
420 node.Reset(new Cm.Ast.RangeForStatementNode(System.Lex.Span(), moduleId, typeExpr, id, container, action));
421 }
422 public override void Visit(Cm.Ast.SwitchStatementNode& switchStatementNode)
423 {
424 switchStatementNode.Condition()->Accept(*this);
425 Cm.Ast.Node* cond = node.Release();
426 Cm.Ast.SwitchStatementNode* clone = new Cm.Ast.SwitchStatementNode(System.Lex.Span(), moduleId, cond);
427 int nc = switchStatementNode.Cases().Count();
428 for (int i = 0; i < nc; ++i;)
429 {
430 switchStatementNode.Cases()[i]->Accept(*this);
431 clone->AddCase(cast<Cm.Ast.CaseStatementNode*>(node.Release()));
432 }
433 if ((switchStatementNode.Default() != null))
434 {
435 switchStatementNode.Default()->Accept(*this);
436 clone->SetDefault(cast<Cm.Ast.DefaultStatementNode*>(node.Release()));
437 }
438 node.Reset(clone);
439 }
440 public override void Visit(Cm.Ast.CaseStatementNode& caseStatementNode)
441 {
442 Cm.Ast.CaseStatementNode* clone = new Cm.Ast.CaseStatementNode(System.Lex.Span(), moduleId);
443 int ne = caseStatementNode.CaseExprs().Count();
444 for (int i = 0; i < ne; ++i;)
445 {
446 caseStatementNode.CaseExprs()[i]->Accept(*this);
447 clone->AddCaseExpr(node.Release());
448 }
449 int ns = caseStatementNode.Statements().Count();
450 for (int i = 0; i < ns; ++i;)
451 {
452 caseStatementNode.Statements()[i]->Accept(*this);
453 clone->AddStatement(cast<Cm.Ast.StatementNode*>(node.Release()));
454 }
455 node.Reset(clone);
456 }
457 public override void Visit(Cm.Ast.DefaultStatementNode& defaultStatementNode)
458 {
459 Cm.Ast.DefaultStatementNode* clone = new Cm.Ast.DefaultStatementNode(System.Lex.Span(), moduleId);
460 int n = defaultStatementNode.Statements().Count();
461 for (int i = 0; i < n; ++i;)
462 {
463 defaultStatementNode.Statements()[i]->Accept(*this);
464 clone->AddStatement(cast<Cm.Ast.StatementNode*>(node.Release()));
465 }
466 node.Reset(clone);
467 }
468 public override void Visit(Cm.Ast.GotoCaseStatementNode& gotoCaseStatementNode)
469 {
470 gotoCaseStatementNode.CaseExpr()->Accept(*this);
471 Cm.Ast.GotoCaseStatementNode* clone = new Cm.Ast.GotoCaseStatementNode(System.Lex.Span(), moduleId, node.Release());
472 node.Reset(clone);
473 }
474 public override void Visit(Cm.Ast.GotoDefaultStatementNode& gotoDefaultStatementNode)
475 {
476 node.Reset(new Cm.Ast.GotoDefaultStatementNode(System.Lex.Span(), moduleId));
477 }
478 public override void Visit(Cm.Ast.ThrowStatementNode& throwStatementNode)
479 {
480 Cm.Ast.Node* expr = null;
481 if ((throwStatementNode.Expression() != null))
482 {
483 throwStatementNode.Expression()->Accept(*this);
484 expr = node.Release();
485 }
486 Cm.Ast.ThrowStatementNode* clone = new Cm.Ast.ThrowStatementNode(System.Lex.Span(), moduleId, expr);
487 node.Reset(clone);
488 }
489 public override void Visit(Cm.Ast.TryStatementNode& tryStatementNode)
490 {
491 tryStatementNode.TryBlock()->Accept(*this);
492 Cm.Ast.CompoundStatementNode* tryBlock = cast<Cm.Ast.CompoundStatementNode*>(node.Release());
493 Cm.Ast.TryStatementNode* clone = new Cm.Ast.TryStatementNode(System.Lex.Span(), moduleId, tryBlock);
494 int n = tryStatementNode.Catches().Count();
495 for (int i = 0; i < n; ++i;)
496 {
497 tryStatementNode.Catches()[i]->Accept(*this);
498 Cm.Ast.CatchNode* catchNode = cast<Cm.Ast.CatchNode*>(node.Release());
499 clone->AddCatch(catchNode);
500 }
501 node.Reset(clone);
502 }
503 public override void Visit(Cm.Ast.CatchNode& catchNode)
504 {
505 catchNode.TypeExpr()->Accept(*this);
506 Cm.Ast.Node* typeExpr = node.Release();
507 Cm.Ast.IdentifierNode* id = null;
508 if ((catchNode.Id() != null))
509 {
510 catchNode.Id()->Accept(*this);
511 id = cast<Cm.Ast.IdentifierNode*>(node.Release());
512 }
513 catchNode.CatchBlock()->Accept(*this);
514 Cm.Ast.CompoundStatementNode* catchBlock = cast<Cm.Ast.CompoundStatementNode*>(node.Release());
515 Cm.Ast.CatchNode* clone = new Cm.Ast.CatchNode(System.Lex.Span(), moduleId, typeExpr, id, catchBlock);
516 node.Reset(clone);
517 }
518 public override void Visit(Cm.Ast.AssertStatementNode& assertStatementNode)
519 {
520 assertStatementNode.AssertExpr()->Accept(*this);
521 Cm.Ast.Node* assertExpr = node.Release();
522 node.Reset(new Cm.Ast.AssertStatementNode(System.Lex.Span(), moduleId, assertExpr));
523 }
524 public override void Visit(Cm.Ast.ConditionalCompilationPartNode& conditionalCompilationPartNode)
525 {
526 conditionalCompilationPartNode.Expr()->Accept(*this);
527 Cm.Ast.ConditionalCompilationExpressionNode* expr = cast<Cm.Ast.ConditionalCompilationExpressionNode*>(node.Release());
528 Cm.Ast.ConditionalCompilationPartNode* clone = new Cm.Ast.ConditionalCompilationPartNode(System.Lex.Span(), moduleId, expr);
529 int n = conditionalCompilationPartNode.Statements().Count();
530 for (int i = 0; i < n; ++i;)
531 {
532 conditionalCompilationPartNode.Statements()[i]->Accept(*this);
533 clone->AddStatement(cast<Cm.Ast.StatementNode*>(node.Release()));
534 }
535 node.Reset(clone);
536 }
537 public override void Visit(Cm.Ast.ConditionalCompilationDisjunctionNode& conditionalCompilationDisjunctionNode)
538 {
539 conditionalCompilationDisjunctionNode.Left()->Accept(*this);
540 Cm.Ast.ConditionalCompilationExpressionNode* left = cast<Cm.Ast.ConditionalCompilationExpressionNode*>(node.Release());
541 conditionalCompilationDisjunctionNode.Right()->Accept(*this);
542 Cm.Ast.ConditionalCompilationExpressionNode* right = cast<Cm.Ast.ConditionalCompilationExpressionNode*>(node.Release());
543 Cm.Ast.ConditionalCompilationDisjunctionNode* clone = new Cm.Ast.ConditionalCompilationDisjunctionNode(System.Lex.Span(), moduleId, left, right);
544 node.Reset(clone);
545 }
546 public override void Visit(Cm.Ast.ConditionalCompilationConjunctionNode& conditionalCompilationConjunctionNode)
547 {
548 conditionalCompilationConjunctionNode.Left()->Accept(*this);
549 Cm.Ast.ConditionalCompilationExpressionNode* left = cast<Cm.Ast.ConditionalCompilationExpressionNode*>(node.Release());
550 conditionalCompilationConjunctionNode.Right()->Accept(*this);
551 Cm.Ast.ConditionalCompilationExpressionNode* right = cast<Cm.Ast.ConditionalCompilationExpressionNode*>(node.Release());
552 Cm.Ast.ConditionalCompilationConjunctionNode* clone = new Cm.Ast.ConditionalCompilationConjunctionNode(System.Lex.Span(), moduleId, left, right);
553 node.Reset(clone);
554 }
555 public override void Visit(Cm.Ast.ConditionalCompilationNotNode& conditionalCompilationNotNode)
556 {
557 conditionalCompilationNotNode.Expr()->Accept(*this);
558 Cm.Ast.ConditionalCompilationExpressionNode* expr = cast<Cm.Ast.ConditionalCompilationExpressionNode*>(node.Release());
559 Cm.Ast.ConditionalCompilationNotNode* clone = new Cm.Ast.ConditionalCompilationNotNode(System.Lex.Span(), moduleId, expr);
560 node.Reset(clone);
561 }
562 public override void Visit(Cm.Ast.ConditionalCompilationPrimaryNode& conditionalCompilationPrimaryNode)
563 {
564 node.Reset(new Cm.Ast.ConditionalCompilationPrimaryNode(System.Lex.Span(), moduleId, conditionalCompilationPrimaryNode.Symbol()));
565 }
566 public override void Visit(Cm.Ast.ParenthesizedConditionalCompilationExpressionNode& parenthesizeCondCompExprNode)
567 {
568 parenthesizeCondCompExprNode.Expr()->Accept(*this);
569 Cm.Ast.ConditionalCompilationExpressionNode* expr = cast<Cm.Ast.ConditionalCompilationExpressionNode*>(node.Release());
570 Cm.Ast.ParenthesizedConditionalCompilationExpressionNode* clone = new Cm.Ast.ParenthesizedConditionalCompilationExpressionNode(System.Lex.Span(), moduleId, expr);
571 node.Reset(clone);
572 }
573 public override void Visit(Cm.Ast.ConditionalCompilationStatementNode& conditionalCompilationStatementNode)
574 {
575 conditionalCompilationStatementNode.IfPart()->Accept(*this);
576 Cm.Ast.ConditionalCompilationPartNode* ifPart = cast<Cm.Ast.ConditionalCompilationPartNode*>(node.Release());
577 Cm.Ast.ConditionalCompilationStatementNode* clone = new Cm.Ast.ConditionalCompilationStatementNode(System.Lex.Span(), moduleId);
578 clone->SetIfPart(ifPart);
579 int n = conditionalCompilationStatementNode.ElifParts().Count();
580 for (int i = 0; i < n; ++i;)
581 {
582 conditionalCompilationStatementNode.ElifParts()[i]->Accept(*this);
583 clone->AddElifPart(cast<Cm.Ast.ConditionalCompilationPartNode*>(node.Release()));
584 }
585 if ((conditionalCompilationStatementNode.ElsePart() != null))
586 {
587 conditionalCompilationStatementNode.ElsePart()->Accept(*this);
588 clone->SetElsePart(cast<Cm.Ast.ConditionalCompilationPartNode*>(node.Release()));
589 }
590 node.Reset(clone);
591 }
592 public override void Visit(Cm.Ast.ConstNode& constNode)
593 {
594 constNode.Subject()->Accept(*this);
595 node.Reset(new Cm.Ast.ConstNode(System.Lex.Span(), moduleId, node.Release()));
596 }
597 public override void Visit(Cm.Ast.LValueRefNode& lvalueRefNode)
598 {
599 lvalueRefNode.Subject()->Accept(*this);
600 node.Reset(new Cm.Ast.LValueRefNode(System.Lex.Span(), moduleId, node.Release()));
601 }
602 public override void Visit(Cm.Ast.RValueRefNode& rvalueRefNode)
603 {
604 rvalueRefNode.Subject()->Accept(*this);
605 node.Reset(new Cm.Ast.RValueRefNode(System.Lex.Span(), moduleId, node.Release()));
606 }
607 public override void Visit(Cm.Ast.PointerNode& pointerNode)
608 {
609 pointerNode.Subject()->Accept(*this);
610 node.Reset(new Cm.Ast.PointerNode(System.Lex.Span(), moduleId, node.Release()));
611 }
612 public override void Visit(Cm.Ast.ArrayNode& arrayNode)
613 {
614 arrayNode.Subject()->Accept(*this);
615 Cm.Ast.Node* subject = node.Release();
616 Cm.Ast.Node* size = null;
617 if ((arrayNode.Size() != null))
618 {
619 arrayNode.Size()->Accept(*this);
620 size = node.Release();
621 }
622 node.Reset(new Cm.Ast.ArrayNode(System.Lex.Span(), moduleId, subject, size));
623 }
624 public override void Visit(Cm.Ast.DotNode& dotNode)
625 {
626 dotNode.Subject()->Accept(*this);
627 Cm.Ast.Node* subject = node.Release();
628 dotNode.MemberId()->Accept(*this);
629 Cm.Ast.IdentifierNode* memberId = cast<Cm.Ast.IdentifierNode*>(node.Release());
630 Cm.Ast.DotNode* clone = new Cm.Ast.DotNode(System.Lex.Span(), moduleId, subject, memberId);
631 node.Reset(clone);
632 }
633 public override void Visit(Cm.Ast.ArrowNode& arrowNode)
634 {
635 arrowNode.Subject()->Accept(*this);
636 Cm.Ast.Node* subject = node.Release();
637 arrowNode.MemberId()->Accept(*this);
638 Cm.Ast.IdentifierNode* memberId = cast<Cm.Ast.IdentifierNode*>(node.Release());
639 Cm.Ast.ArrowNode* clone = new Cm.Ast.ArrowNode(System.Lex.Span(), moduleId, subject, memberId);
640 node.Reset(clone);
641 }
642 public override void Visit(Cm.Ast.EquivalenceNode& equivalenceNode)
643 {
644 equivalenceNode.Left()->Accept(*this);
645 Cm.Ast.Node* left = node.Release();
646 equivalenceNode.Right()->Accept(*this);
647 Cm.Ast.Node* right = node.Release();
648 node.Reset(new Cm.Ast.EquivalenceNode(System.Lex.Span(), moduleId, left, right));
649 }
650 public override void Visit(Cm.Ast.ImplicationNode& implicationNode)
651 {
652 implicationNode.Left()->Accept(*this);
653 Cm.Ast.Node* left = node.Release();
654 implicationNode.Right()->Accept(*this);
655 Cm.Ast.Node* right = node.Release();
656 node.Reset(new Cm.Ast.ImplicationNode(System.Lex.Span(), moduleId, left, right));
657 }
658 public override void Visit(Cm.Ast.DisjunctionNode& disjunctionNode)
659 {
660 disjunctionNode.Left()->Accept(*this);
661 Cm.Ast.Node* left = node.Release();
662 disjunctionNode.Right()->Accept(*this);
663 Cm.Ast.Node* right = node.Release();
664 node.Reset(new Cm.Ast.DisjunctionNode(System.Lex.Span(), moduleId, left, right));
665 }
666 public override void Visit(Cm.Ast.ConjunctionNode& conjunctionNode)
667 {
668 conjunctionNode.Left()->Accept(*this);
669 Cm.Ast.Node* left = node.Release();
670 conjunctionNode.Right()->Accept(*this);
671 Cm.Ast.Node* right = node.Release();
672 node.Reset(new Cm.Ast.ConjunctionNode(System.Lex.Span(), moduleId, left, right));
673 }
674 public override void Visit(Cm.Ast.BitOrNode& bitOrNode)
675 {
676 bitOrNode.Left()->Accept(*this);
677 Cm.Ast.Node* left = node.Release();
678 bitOrNode.Right()->Accept(*this);
679 Cm.Ast.Node* right = node.Release();
680 node.Reset(new Cm.Ast.BitOrNode(System.Lex.Span(), moduleId, left, right));
681 }
682 public override void Visit(Cm.Ast.BitXorNode& bitXorNode)
683 {
684 bitXorNode.Left()->Accept(*this);
685 Cm.Ast.Node* left = node.Release();
686 bitXorNode.Right()->Accept(*this);
687 Cm.Ast.Node* right = node.Release();
688 node.Reset(new Cm.Ast.BitXorNode(System.Lex.Span(), moduleId, left, right));
689 }
690 public override void Visit(Cm.Ast.BitAndNode& bitAndNode)
691 {
692 bitAndNode.Left()->Accept(*this);
693 Cm.Ast.Node* left = node.Release();
694 bitAndNode.Right()->Accept(*this);
695 Cm.Ast.Node* right = node.Release();
696 node.Reset(new Cm.Ast.BitAndNode(System.Lex.Span(), moduleId, left, right));
697 }
698 public override void Visit(Cm.Ast.EqualNode& equalNode)
699 {
700 equalNode.Left()->Accept(*this);
701 Cm.Ast.Node* left = node.Release();
702 equalNode.Right()->Accept(*this);
703 Cm.Ast.Node* right = node.Release();
704 node.Reset(new Cm.Ast.EqualNode(System.Lex.Span(), moduleId, left, right));
705 }
706 public override void Visit(Cm.Ast.NotEqualNode& notEqualNode)
707 {
708 notEqualNode.Left()->Accept(*this);
709 Cm.Ast.Node* left = node.Release();
710 notEqualNode.Right()->Accept(*this);
711 Cm.Ast.Node* right = node.Release();
712 node.Reset(new Cm.Ast.NotEqualNode(System.Lex.Span(), moduleId, left, right));
713 }
714 public override void Visit(Cm.Ast.LessNode& lessNode)
715 {
716 lessNode.Left()->Accept(*this);
717 Cm.Ast.Node* left = node.Release();
718 lessNode.Right()->Accept(*this);
719 Cm.Ast.Node* right = node.Release();
720 node.Reset(new Cm.Ast.LessNode(System.Lex.Span(), moduleId, left, right));
721 }
722 public override void Visit(Cm.Ast.GreaterNode& greaterNode)
723 {
724 greaterNode.Left()->Accept(*this);
725 Cm.Ast.Node* left = node.Release();
726 greaterNode.Right()->Accept(*this);
727 Cm.Ast.Node* right = node.Release();
728 node.Reset(new Cm.Ast.GreaterNode(System.Lex.Span(), moduleId, left, right));
729 }
730 public override void Visit(Cm.Ast.LessOrEqualNode& lessOrEqualNode)
731 {
732 lessOrEqualNode.Left()->Accept(*this);
733 Cm.Ast.Node* left = node.Release();
734 lessOrEqualNode.Right()->Accept(*this);
735 Cm.Ast.Node* right = node.Release();
736 node.Reset(new Cm.Ast.LessOrEqualNode(System.Lex.Span(), moduleId, left, right));
737 }
738 public override void Visit(Cm.Ast.GreaterOrEqualNode& greaterOrEqualNode)
739 {
740 greaterOrEqualNode.Left()->Accept(*this);
741 Cm.Ast.Node* left = node.Release();
742 greaterOrEqualNode.Right()->Accept(*this);
743 Cm.Ast.Node* right = node.Release();
744 node.Reset(new Cm.Ast.GreaterOrEqualNode(System.Lex.Span(), moduleId, left, right));
745 }
746 public override void Visit(Cm.Ast.ShiftLeftNode& shiftLeftNode)
747 {
748 shiftLeftNode.Left()->Accept(*this);
749 Cm.Ast.Node* left = node.Release();
750 shiftLeftNode.Right()->Accept(*this);
751 Cm.Ast.Node* right = node.Release();
752 node.Reset(new Cm.Ast.ShiftLeftNode(System.Lex.Span(), moduleId, left, right));
753 }
754 public override void Visit(Cm.Ast.ShiftRightNode& shiftRightNode)
755 {
756 shiftRightNode.Left()->Accept(*this);
757 Cm.Ast.Node* left = node.Release();
758 shiftRightNode.Right()->Accept(*this);
759 Cm.Ast.Node* right = node.Release();
760 node.Reset(new Cm.Ast.ShiftRightNode(System.Lex.Span(), moduleId, left, right));
761 }
762 public override void Visit(Cm.Ast.AddNode& addNode)
763 {
764 addNode.Left()->Accept(*this);
765 Cm.Ast.Node* left = node.Release();
766 addNode.Right()->Accept(*this);
767 Cm.Ast.Node* right = node.Release();
768 node.Reset(new Cm.Ast.AddNode(System.Lex.Span(), moduleId, left, right));
769 }
770 public override void Visit(Cm.Ast.SubNode& subNode)
771 {
772 subNode.Left()->Accept(*this);
773 Cm.Ast.Node* left = node.Release();
774 subNode.Right()->Accept(*this);
775 Cm.Ast.Node* right = node.Release();
776 node.Reset(new Cm.Ast.SubNode(System.Lex.Span(), moduleId, left, right));
777 }
778 public override void Visit(Cm.Ast.MulNode& mulNode)
779 {
780 mulNode.Left()->Accept(*this);
781 Cm.Ast.Node* left = node.Release();
782 mulNode.Right()->Accept(*this);
783 Cm.Ast.Node* right = node.Release();
784 node.Reset(new Cm.Ast.MulNode(System.Lex.Span(), moduleId, left, right));
785 }
786 public override void Visit(Cm.Ast.DivNode& divNode)
787 {
788 divNode.Left()->Accept(*this);
789 Cm.Ast.Node* left = node.Release();
790 divNode.Right()->Accept(*this);
791 Cm.Ast.Node* right = node.Release();
792 node.Reset(new Cm.Ast.DivNode(System.Lex.Span(), moduleId, left, right));
793 }
794 public override void Visit(Cm.Ast.RemNode& remNode)
795 {
796 remNode.Left()->Accept(*this);
797 Cm.Ast.Node* left = node.Release();
798 remNode.Right()->Accept(*this);
799 Cm.Ast.Node* right = node.Release();
800 node.Reset(new Cm.Ast.RemNode(System.Lex.Span(), moduleId, left, right));
801 }
802 public override void Visit(Cm.Ast.NotNode& notNode)
803 {
804 notNode.Subject()->Accept(*this);
805 node.Reset(new Cm.Ast.NotNode(System.Lex.Span(), moduleId, node.Release()));
806 }
807 public override void Visit(Cm.Ast.UnaryPlusNode& unaryPlusNode)
808 {
809 unaryPlusNode.Subject()->Accept(*this);
810 node.Reset(new Cm.Ast.UnaryPlusNode(System.Lex.Span(), moduleId, node.Release()));
811 }
812 public override void Visit(Cm.Ast.UnaryMinusNode& unaryMinusNode)
813 {
814 unaryMinusNode.Subject()->Accept(*this);
815 node.Reset(new Cm.Ast.UnaryMinusNode(System.Lex.Span(), moduleId, node.Release()));
816 }
817 public override void Visit(Cm.Ast.PrefixIncrementNode& prefixIncrementNode)
818 {
819 prefixIncrementNode.Subject()->Accept(*this);
820 node.Reset(new Cm.Ast.PrefixIncrementNode(System.Lex.Span(), moduleId, node.Release()));
821 }
822 public override void Visit(Cm.Ast.PrefixDecrementNode& prefixDecrementNode)
823 {
824 prefixDecrementNode.Subject()->Accept(*this);
825 node.Reset(new Cm.Ast.PrefixDecrementNode(System.Lex.Span(), moduleId, node.Release()));
826 }
827 public override void Visit(Cm.Ast.DerefNode& derefNode)
828 {
829 derefNode.Subject()->Accept(*this);
830 node.Reset(new Cm.Ast.DerefNode(System.Lex.Span(), moduleId, node.Release()));
831 }
832 public override void Visit(Cm.Ast.AddrOfNode& addrOfNode)
833 {
834 addrOfNode.Subject()->Accept(*this);
835 node.Reset(new Cm.Ast.AddrOfNode(System.Lex.Span(), moduleId, node.Release()));
836 }
837 public override void Visit(Cm.Ast.ComplementNode& complementNode)
838 {
839 complementNode.Subject()->Accept(*this);
840 node.Reset(new Cm.Ast.ComplementNode(System.Lex.Span(), moduleId, node.Release()));
841 }
842 public override void Visit(Cm.Ast.IsNode& isNode)
843 {
844 isNode.TargetTypeExpr()->Accept(*this);
845 Cm.Ast.Node* targetTypeExpr = node.Release();
846 isNode.Expr()->Accept(*this);
847 node.Reset(new Cm.Ast.IsNode(System.Lex.Span(), moduleId, node.Release(), targetTypeExpr));
848 }
849 public override void Visit(Cm.Ast.AsNode& asNode)
850 {
851 asNode.TargetTypeExpr()->Accept(*this);
852 Cm.Ast.Node* targetTypeExpr = node.Release();
853 asNode.Expr()->Accept(*this);
854 node.Reset(new Cm.Ast.AsNode(System.Lex.Span(), moduleId, node.Release(), targetTypeExpr));
855 }
856 public override void Visit(Cm.Ast.IndexingNode& indexingNode)
857 {
858 indexingNode.Subject()->Accept(*this);
859 Cm.Ast.Node* subject = node.Release();
860 indexingNode.Index()->Accept(*this);
861 Cm.Ast.Node* index = node.Release();
862 node.Reset(new Cm.Ast.IndexingNode(System.Lex.Span(), moduleId, subject, index));
863 }
864 public override void Visit(Cm.Ast.InvokeNode& invokeNode)
865 {
866 invokeNode.Subject()->Accept(*this);
867 Cm.Ast.Node* subject = node.Release();
868 Cm.Ast.InvokeNode* clone = new Cm.Ast.InvokeNode(System.Lex.Span(), moduleId, subject);
869 int n = invokeNode.Arguments().Count();
870 for (int i = 0; i < n; ++i;)
871 {
872 invokeNode.Arguments()[i]->Accept(*this);
873 clone->AddArgument(node.Release());
874 }
875 node.Reset(clone);
876 }
877 public override void Visit(Cm.Ast.PostfixIncrementNode& postfixIncrementNode)
878 {
879 postfixIncrementNode.Subject()->Accept(*this);
880 Cm.Ast.Node* subject = node.Release();
881 node.Reset(new Cm.Ast.PostfixIncrementNode(System.Lex.Span(), moduleId, subject));
882 }
883 public override void Visit(Cm.Ast.PostfixDecrementNode& postfixDecrementNode)
884 {
885 postfixDecrementNode.Subject()->Accept(*this);
886 Cm.Ast.Node* subject = node.Release();
887 node.Reset(new Cm.Ast.PostfixDecrementNode(System.Lex.Span(), moduleId, subject));
888 }
889 public override void Visit(Cm.Ast.SizeOfNode& sizeOfNode)
890 {
891 sizeOfNode.Expression()->Accept(*this);
892 node.Reset(new Cm.Ast.SizeOfNode(System.Lex.Span(), moduleId, node.Release()));
893 }
894 public override void Visit(Cm.Ast.TypeNameNode& typeNameNode)
895 {
896 typeNameNode.Expression()->Accept(*this);
897 Cm.Ast.TypeNameNode* clone = new Cm.Ast.TypeNameNode(System.Lex.Span(), moduleId, node.Release());
898 if (typeNameNode.Static())
899 {
900 clone->SetStatic();
901 }
902 node.Reset(clone);
903 }
904 public override void Visit(Cm.Ast.TypeIdNode& typeIdNode)
905 {
906 typeIdNode.Expression()->Accept(*this);
907 node.Reset(new Cm.Ast.TypeIdNode(System.Lex.Span(), moduleId, node.Release()));
908 }
909 public override void Visit(Cm.Ast.CastNode& castNode)
910 {
911 castNode.TargetTypeExpr()->Accept(*this);
912 Cm.Ast.Node* targetTypeExpr = node.Release();
913 castNode.SourceExpr()->Accept(*this);
914 node.Reset(new Cm.Ast.CastNode(System.Lex.Span(), moduleId, targetTypeExpr, node.Release()));
915 }
916 public override void Visit(Cm.Ast.ConstructNode& constructNode)
917 {
918 constructNode.TypeExpr()->Accept(*this);
919 Cm.Ast.Node* typeExpr = node.Release();
920 Cm.Ast.ConstructNode* clone = new Cm.Ast.ConstructNode(System.Lex.Span(), moduleId, typeExpr);
921 int n = constructNode.Arguments().Count();
922 for (int i = 0; i < n; ++i;)
923 {
924 constructNode.Arguments()[i]->Accept(*this);
925 clone->AddArgument(node.Release());
926 }
927 node.Reset(clone);
928 }
929 public override void Visit(Cm.Ast.NewNode& newNode)
930 {
931 newNode.TypeExpr()->Accept(*this);
932 Cm.Ast.Node* typeExpr = node.Release();
933 Cm.Ast.NewNode* clone = new Cm.Ast.NewNode(System.Lex.Span(), moduleId, typeExpr);
934 int n = newNode.Arguments().Count();
935 for (int i = 0; i < n; ++i;)
936 {
937 newNode.Arguments()[i]->Accept(*this);
938 clone->AddArgument(node.Release());
939 }
940 node.Reset(clone);
941 }
942 public override void Visit(Cm.Ast.ParenthesizedExpressionNode& parenthesizedExpressionNode)
943 {
944 parenthesizedExpressionNode.Subject()->Accept(*this);
945 node.Reset(new Cm.Ast.ParenthesizedExpressionNode(System.Lex.Span(), moduleId, node.Release()));
946 }
947 public override void Visit(Cm.Ast.TemplateIdNode& templateIdNode)
948 {
949 templateIdNode.Primary()->Accept(*this);
950 Cm.Ast.Node* primary = node.Release();
951 Cm.Ast.TemplateIdNode* clone = new Cm.Ast.TemplateIdNode(System.Lex.Span(), moduleId, primary);
952 int n = templateIdNode.TemplateArguments().Count();
953 for (int i = 0; i < n; ++i;)
954 {
955 templateIdNode.TemplateArguments()[i]->Accept(*this);
956 clone->AddTemplateArgument(node.Release());
957 }
958 node.Reset(clone);
959 }
960 private UniquePtr<Cm.Ast.Node> node;
961 private bool valueOfPtrType;
962 private ustring nonterminalName;
963 private List<NonterminalInfo> nonterminalInfos;
964 private List<int> nonterminalCounts;
965 private Cm.Ast.Node* returnType;
966 private bool noParserDebugSupport;
967 private ustring parserName;
968 private Cm.Ast.CompoundStatementNode* currentBlock;
969 private Uuid moduleId;
970 }
971 }