/[suikacvs]/messaging/manakai/lib/Message/Util/PerlCode.dis
Suika

Contents of /messaging/manakai/lib/Message/Util/PerlCode.dis

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (hide annotations) (download)
Wed Apr 27 06:24:48 2005 UTC (20 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.12: +94 -18 lines
lib/manakai/XML.dis: New module; lib/Message/Util/DIS.dis: Creating Perl package code moved from (uncommitted) test script

1 wakaba 1.1 Module:
2     @QName:
3     Util:PerlCode
4     @FullName:
5     @@lang: en
6     @@@:
7     Perl Code Constructor
8     @Namespace:
9     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/PerlCode#
10    
11     @Description:
12     @@lang:en
13     @@@:
14     This module provides an object-oriented interface to construct
15     Perl code.
16    
17     @Author:
18     @@FullName: Wakaba
19     @@Mail: w@suika.fam.cx
20     @License:
21     @@@:
22     license:Perl+MPL
23     @@Original:
24     @@@FullName:
25     manakai <CODE::lib/manakai/genlib.pl>
26     @@@Year:2004
27     @@@Author:
28     @@@@FullName:Wakaba
29     @@@@Mail:w@suika.fam.cx
30     @Date:
31     @@@:
32 wakaba 1.13 $Date: 2005/04/10 05:40:59 $
33 wakaba 1.1 @@ContentType:
34     dis:Date.RCS
35    
36     @Require:
37     @@Module:
38     @@@Name: ManakaiNode
39     @@@WithFor:
40     ManakaiDOM:Perl
41     @@Module:
42     @@@Name: DOMBoot
43 wakaba 1.5 @@@QName:
44     MDOM:DOMBoot
45 wakaba 1.1 @@@WithFor:
46     ManakaiDOM:ManakaiDOMLatest
47     @@Module:
48     @@@Name: DOMMetaImpl
49 wakaba 1.5 @@@QName:
50     MDOM:DOMMetaImpl
51 wakaba 1.1 @@@WithFor:
52     ManakaiDOM:ManakaiDOMLatest
53    
54     @DefaultFor:
55     ManakaiDOM:Perl
56    
57     Namespace:
58     @DIS:
59     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
60     @dis:
61     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
62     @dis2pm:
63     http://suika.fam.cx/~wakaba/archive/2004/11/8/dis2pm#
64     @DISlib:
65     http://suika.fam.cx/~wakaba/archive/2004/dis/
66     @DOMCore:
67     http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#
68     @DOMLS:
69     http://suika.fam.cx/~wakaba/archive/2004/dom/ls#
70     @DOMMain:
71     http://suika.fam.cx/~wakaba/archive/2004/dom/main#
72     @infoset:
73     http://www.w3.org/2001/04/infoset#
74     @lang:
75     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
76     @license:
77     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
78     @ManakaiDOM:
79     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
80     @Markup:
81     http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup#
82 wakaba 1.5 @MDOM:
83     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#ManakaiDOM.
84 wakaba 1.1 @MDOMX:
85     http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#
86     @owl:
87     http://www.w3.org/2002/07/owl#
88     @pc:
89     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/PerlCode#
90     @Perl:
91     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl--
92     @rdf:
93     http://www.w3.org/1999/02/22-rdf-syntax-ns#
94     @rdfs:
95     http://www.w3.org/2000/01/rdf-schema#
96     @swcfg21:
97     http://suika.fam.cx/~wakaba/archive/2005/swcfg21#
98     @TreeCore:\
99     @Util:
100     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/
101    
102     ## -- Features
103    
104     ElementTypeBinding:
105     @Name: FeatureDef
106     @ElementType:
107     dis:ResourceDef
108     @ShadowContent:
109     @@rdf:type:
110     DOMMain:DOMFeature
111     @@AliasFor:
112     @@@@:
113     ::ManakaiDOM:all
114     @@@For:
115     !=ManakaiDOM:all
116    
117     ElementTypeBinding:
118     @Name: FeatureVerDef
119     @ElementType:
120     dis:ResourceDef
121     @ShadowContent:
122     @@rdf:type:
123     DOMMain:DOMFeature
124    
125     ElementTypeBinding:
126     @Name: featureQName
127     @ElementType:
128     dis:AppName
129     @ShadowContent:
130     @@ContentType:
131     dis:TypeQName
132    
133     FeatureDef:
134     @QName: CoreFeature
135     @featureQName:
136     Util:PerlCode
137     @FeatureVerDef:
138     @@QName: CoreFeature10
139     @@Version: 1.0
140     @@ISA: CoreFeature
141     @@FullName:
142     @@@lang:en
143     @@@@:
144     Perl Code Constructor, version 1.0
145     @@Description:
146     @@@lang:en
147     @@@@:
148     Perl Code Constructor, version 1.0.
149    
150     ## -- Classes
151    
152     ClsDef:
153     @ClsQName: ManakaiPerlCodeFragment
154     @ClsISA:
155     ManakaiDOM:ManakaiDOMNodeReference::ManakaiDOM:Perl
156     @enDesc:
157     A class on which another Perl code classes are constructed based.
158    
159     @IntMethod:
160     @@Operator:
161     @@@@:
162     ManakaiDOM:MUErrorHandler
163     @@@ContentType:
164     dis:TypeQName
165     @@Description:
166     @@@lang:en
167     @@@@:
168     This method is a generic error handler; all manakai exceptions
169     and warnings associated to an object are once reported to this method
170     and then delivered to appropriate entities.
171     \
172     If the error is an exception (such as <X::DOMCore:DOMException> or
173     <X::ManakaiDOM:ManakaiDOMImplementationException>), it is
174     simply thrown. If the error is only a warning, it is reported
175     via the <IF::DOMCore:DOMError> interface.
176     \
177     See <PerlModule::Message::Util::Error> documentation for more
178     information on the error reporting mechanism.
179     \
180     {NOTE:: This kind of methods are named as <Perl::___report_error>
181     in the convention of <PerlModule::Message::Util::Error>.
182     \
183     }
184     @@Param:
185     @@@Name:err
186     @@@Type:
187     ManakaiDOM:ManakaiDOMExceptionOrWarning::ManakaiDOM:Perl
188     @@@Description:
189     @@@@lang:en
190     @@@@@:
191     An exception object that describes what kind of error it is
192     and how it should be recovered.
193     \
194     {NOTE:: Exception objects in manakai implementation
195     inherit the class <PerlModule::Message::Util::Error>,
196     that in turn inherits <PerlModule::Error>.
197     \
198     }
199     @@Return:
200     @@@PerlDef:
201     if ($err->isa (<ClassName::ManakaiDOM:ManakaiDOMException
202     ::ManakaiDOM:Perl>)) {
203     $err->throw;
204     } else {
205     \## TODO: Implement warning reporting
206     warn $err->stringify;
207     }
208    
209     @Attr:
210     @@Name: parentNode
211     @@enDesc:
212     The parent construction of this object.
213     @@Get:
214     @@@Type: ManakaiPerlCodeFragment
215 wakaba 1.5 @@@nullCase:
216     @@@@enDesc:
217     This object has no parent.
218 wakaba 1.1 @@@PerlDef:
219     $r = $self->{<Q::TreeCore:node>}->{<Q::pc:parent>};
220 wakaba 1.6 $r = <ClassM::ManakaiPerlCodeFragment.getNodeReference> ($r) if $r;
221    
222     @Attr:
223     @@Name: fileNode
224     @@enDesc:
225     The root <QUOTE::file> node of the tree to which this node belongs.
226     @@Type: ManakaiPerlCodeFragment
227     @@Get:
228     @@@enDesc:
229     The <QUOTE::file> node of the tree.
230     @@@nullCase:
231     @@@@enDesc:
232     This node does not belong to any file tree.
233     @@@PerlDef:
234     $r = $self->{<Q::TreeCore:node>}->{<Q::pc:parent>};
235     {
236     if ($r->{<Q::pc:parent>}) {
237     $r = $r->{<Q::pc:parent>};
238     redo;
239     }
240     };
241     if ($r) {
242     if ($r->{<Q::pc:nodeType>} eq 'file') {
243     __DEEP{
244     $r = <ClassM::ManakaiPerlCodeFragment.getNodeReference> ($r);
245     }__;
246     } else {
247     $r = null;
248     }
249     } elsif ($self->{<Q::TreeCore:node>}->{<Q::pc:nodeType>} eq 'file') {
250     $r = $self;
251     }
252    
253     @IntMethod:
254     @@Name: getNodeReference
255     @@ManakaiDOM:isStatic:1
256     @@enDesc:
257     Gets a node reference for a node object.
258     @@Param:
259     @@@Name: object
260     @@@Type:
261     ManakaiDOM:ManakaiDOMNodeReference::ManakaiDOM:Perl
262     @@@enDesc:
263     A node object.
264     @@Return:
265     @@@Type:
266     ManakaiDOM:ManakaiDOMNodeReference::ManakaiDOM:Perl
267     @@@PerlDef:
268     my $nt = $object->{<Q::pc:nodeType>};
269     my $pack;
270 wakaba 1.9 __CODE{pc:nodeTypeToPackageName::
271     $nodeType => $nt, $packageName => $pack, $object => $object}__;
272 wakaba 1.6 __CODE{ManakaiNode:getNewReference::
273     $object => $object, $ref => $r, $class => $pack}__;
274    
275     @Method:
276     @@Name: replaceVariable
277     @@enDesc:
278     Replaces a variable.
279     \
280     {NOTE:: For objects of type <Class::ManakaiPerlFile>,
281 wakaba 1.11 <Class::ManakaiPerlPackageScope>,
282     <Class::ManakaiPerlSub> and
283     <Class::ManakaiPerlVariable>, the result is undefined.
284 wakaba 1.6 \
285     }
286     @@Param:
287     @@@Name: originalVariable
288     @@@Type:
289     lang:Perl::ManakaiDOM:all
290     @@@enDesc:
291     Original variable specification, including prefix.
292     \
293     {NOTE:: Qualified name variable and hash key is not supported.
294     \
295     }
296     @@Param:
297     @@@Name: newValue
298 wakaba 1.11 @@@Type:
299     DOMMain:any::ManakaiDOM:all
300 wakaba 1.6 @@@enDesc:
301     New value to replace.
302 wakaba 1.11 @@@InCase:
303     @@@@Type:ManakaiPerlCodeFragment
304     @@@@enDesc:
305     New Perl code fragment to replace by.
306     @@@InCase:
307     @@@@Type:
308     lang:Perl::ManakaiDOM:all
309     @@@@enDesc:
310     Inline Perl code fragment string to replace by.
311 wakaba 1.6 @@Return:
312     @@@PerlDef:
313     my $node = $self->{<Q::TreeCore:node>};
314     if ($node->{<Q::pc:nodeType>} eq 'unparsed' or
315     $node->{<Q::pc:nodeType>} eq 'inunparsed') {
316 wakaba 1.11 my $newVariable = ref $newValue ? $newValue->stringify : ''.$newValue;
317     $node->{<Q::pc:code>} =~ s/\$\Q$originalVariable\E\b/$newVariable/g;
318 wakaba 1.6 } elsif ($node->{<Q::pc:childNodes>}) {
319     __DEEP{
320 wakaba 1.11 for my $cnoi (0..$#{$node->{<Q::pc:childNodes>}}) {
321     my $cno = $node->{<Q::pc:childNodes>}->[$cnoi];
322     if ($cno->{<Q::pc:nodeType>} eq 'variable') {
323     if (substr ($originalVariable, 0, 1)
324     eq $cno->{<Q::pc:variableType>} and
325     not $cno->{<Q::pc:packageName>} and
326     substr ($originalVariable, 1)
327     eq $cno->{<Q::pc:localName>} and
328     not $cno->{<Q::pc:hashKey>}) {
329     if (ref $newValue) {
330     CORE::delete $cno->{<Q::pc:parent>};
331     $cno-><M::ManakaiDOM:ManakaiDOMNodeObject
332     ::ManakaiDOM:Perl.orphanate>;
333     my $newnode = $newValue->{<Q::TreeCore:node>};
334     $node-><M::ManakaiDOM:ManakaiDOMNodeObject
335     ::ManakaiDOM:Perl.importTree> ($newnode);
336     $newnode->{<Q::pc:parent>} = $node;
337     $node->{<Q::pc:childNodes>}->[$cnoi] = $newnode;
338     } else {
339     my $cn;
340     __CODE{ManakaiNode:getWeakReference::
341     $object => $cno, $ref => $cn,
342     $class => {<ClassName::ManakaiPerlCodeFragment>},
343     }__;
344     $cn-><M::ManakaiPerlInlineContainer.appendCode>
345     ($newValue);
346     }
347     }
348     } else { ## Non-variable child
349     my $cn;
350     __CODE{ManakaiNode:getWeakReference::
351     $object => $cno, $ref => $cn,
352     $class => {<ClassName::ManakaiPerlCodeFragment>},
353     }__;
354     $cn-><M::ManakaiPerlCodeFragment.replaceVariable>
355     ($originalVariable => $newValue);
356     }
357 wakaba 1.6 }
358     }__;
359     }
360 wakaba 1.13
361     @Method:
362     @@Name: addUsePerlModuleName
363     @@enDesc:
364     Adds a Perl module into the list of Perl modules
365     <Perl::use>d by this code fragment.
366     @@Param:
367     @@@Name: moduleName
368     @@@Type:
369     Perl:package-name::ManakaiDOM:all
370     @@@enDesc:
371     The name of the module package that should be <Perl::use>d.
372     @@Return:
373     @@@PerlDef:
374     $self->{<Q::TreeCore:node>}->{<Q::pc:useModuleName>}
375     ->{$moduleName} = true;
376    
377     @Method:
378     @@Name: disAddRequireURI
379     @@enDesc:
380     Adds a <QUOTE::dis> resource into the list of <Perl::require>d
381     resources of this code fragment.
382     @@Param:
383     @@@Name: uriArg
384     @@@Type:
385     DISLang:String::ManakaiDOM:all
386     @@@enDesc:
387     The URI reference of the resource to add.
388     @@Return:
389     @@@PerlDef:
390     $self->{<Q::TreeCore:node>}->{<Q::pc:requireResourceURI>}
391     ->{$uriArg} = true;
392 wakaba 1.1 ##PerlCodeFragment
393    
394 wakaba 1.13 PropDef:
395     @QName: useModuleName
396     @enDesc:
397     The list of modules.
398    
399     PropDef:
400     @QName: requireResourceURI
401     @enDesc:
402     The list of resources.
403    
404 wakaba 1.9 ResourceDef:
405     @QName: nodeTypeToPackageName
406     @rdf:type:
407     dis2pm:BlockCode
408     @enDesc:
409     Gets Perl class package name from a node type string.
410     @PerlDef:
411     if ($nodeType eq 'unparsed') {
412     $packageName = <ClassName::ManakaiPerlUnparsedCode>;
413     } elsif ($nodeType eq 'bare') {
414     $packageName = <ClassName::ManakaiPerlBare>;
415     } elsif ($nodeType eq 'atom') {
416     $packageName = <ClassName::ManakaiPerlAtom>;
417     } elsif ($nodeType eq 'variable') {
418     $packageName = <ClassName::ManakaiPerlVariable>;
419     } elsif ($nodeType eq 'inunparsed') {
420     $packageName = <ClassName::ManakaiPerlInlineUnparsedCode>;
421     } elsif ($nodeType eq 'incontainer') {
422     $packageName = <ClassName::ManakaiPerlInlineContainer>;
423     } elsif ($nodeType eq 'statement') {
424     $packageName = <ClassName::ManakaiPerlStatement>;
425 wakaba 1.11 } elsif ($nodeType eq 'assign') {
426     $packageName = <ClassName::ManakaiPerlAssignment>;
427 wakaba 1.9 } elsif ($nodeType eq 'string') {
428     $packageName = <ClassName::ManakaiPerlStringLiteral>;
429     } elsif ($nodeType eq 'blockcontainer') {
430     $packageName = <ClassName::ManakaiPerlBlockContainer>;
431     } elsif ($nodeType eq 'block') {
432     $packageName = <ClassName::ManakaiPerlBlock>;
433 wakaba 1.12 } elsif ($nodeType eq 'if') {
434     $packageName = <ClassName::ManakaiPerlIf>;
435 wakaba 1.9 } elsif ($nodeType eq 'sub') {
436     $packageName = <ClassName::ManakaiPerlSub>;
437     } elsif ($nodeType eq 'package') {
438     $packageName = <ClassName::ManakaiPerlPackageScope>;
439     } elsif ($nodeType eq 'file') {
440     $packageName = <ClassName::ManakaiPerlFile>;
441     } else {
442     __ASSERT{DISPerl:invariant::
443     msg => {qq[Node type: "$nodeType" ].
444     qq[(ref: "@{[ref $object]}")]},
445     }__;
446     }
447    
448    
449 wakaba 1.6 PropDef:
450     @QName: nodeType
451     @enDesc:
452     Node type.
453    
454 wakaba 1.1 ClsDef:
455     @ClsQName: ManakaiPerlFile
456     @ClsISA: ManakaiPerlCodeFragment
457     @enDesc:
458     Perl source code files.
459    
460     @IntMethod:
461     @@Name:newObject
462     @@ManakaiDOM:isStatic:1
463     @@Description:
464     @@@lang:en
465     @@@@:
466     Creates a new instance object for <Class::ManakaiPerlFile>.
467     @@Return:
468     @@@Type:
469     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
470     @@@Description:
471     @@@@lang:en
472     @@@@@:
473     The newly created node object.
474     @@@PerlDef:
475     @@@@@:
476     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
477     ::ManakaiDOM:Perl.new>;
478     push @{$node->{<Q::TreeCore:subnode>}}, <Q::pc:childNodes>;
479     $node->{<Q::pc:childNodes>} = [];
480     $node->{<Q::pc:sourceFile>} = '';
481     $node->{<Q::pc:sourceModule>} = '';
482     $node->{<Q::pc:sourceFor>} = '';
483     $node->{<Q::pc:currentPackage>} = 'main';
484     $node->{<Q::pc:currentChunk>} = 0;
485 wakaba 1.6 $node->{<Q::pc:nodeType>} = 'file';
486 wakaba 1.1 @@@@ImplNote:
487     @@@@@lang:en
488     @@@@@@:
489     Properties: <Q::pc:sourceFile>,
490     <Q::pc:sourceModule>, <Q::pc:sourceFor>, <Q::childNodes>,
491 wakaba 1.6 <Q::pc:currentPackage>, <Q::pc:currentChunk>,
492     <Q::pc:nodeType>.
493 wakaba 1.1
494     @Method:
495     @@Name: appendNewPackage
496     @@enDesc:
497     Appends a new package scope block.
498     @@Param:
499     @@@Name: packageName
500     @@@Type:
501     Perl:package-name::ManakaiDOM:all
502     @@@enDesc:
503     The fully-qualified name of the package to create.
504     @@Return:
505     @@@Type: ManakaiPerlPackageScope
506     @@@enDesc:
507     The newly created package scope object.
508     @@@PerlDef:
509     $r = <ClassM::ManakaiPerlPackageScope.newObject>;
510     $r->{<Q::pc:packageName>} = $packageName;
511     $self->{<Q::TreeCore:node>}
512     -><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
513     .importTree> ($r);
514     push @{$self->{<Q::TreeCore:node>}->{<Q::pc:childNodes>}}, $r;
515     $r->{<Q::pc:parent>} = $self->{<Q::TreeCore:node>};
516 wakaba 1.6 __CODE{ManakaiNode:getNewReference::
517     $object => $r, $ref => $r,
518     $class => {<ClassName::ManakaiPerlPackageScope>}}__;
519 wakaba 1.1
520     @Method:
521 wakaba 1.13 @@Name: appendPackage
522     @@enDesc:
523     Appends a Perl package scope object.
524     @@Param:
525     @@@Name: codeArg
526     @@@Type: ManakaiPerlPackageScope
527     @@@enDesc:
528     The package to append.
529     @@Return:
530     @@@RaiseException:
531     @@@@@:IN_USE_NODE_ERR
532     @@@@enDesc:
533     An attempt is made to set a subroutine that is
534     already used elsewhere.
535     @@@PerlDef:
536     my $packobj = $codeArg->{<Q::TreeCore:node>};
537     if ($packobj->{<Q::pc:parent>}) {
538     __EXCEPTION{IN_USE_NODE_ERR::
539     pc:childNode => {$codeArg},
540     MDOMX:param-name => 'codeArg',
541     }__;
542     }
543     $self->{<Q::TreeCore:node>}
544     -><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
545     .importTree> ($packobj);
546     push @{$self->{<Q::TreeCore:node>}->{<Q::pc:childNodes>}}, $packobj;
547     $packobj->{<Q::pc:parent>} = $self->{<Q::TreeCore:node>};
548    
549     @Method:
550 wakaba 1.1 @@Name: getFirstPackage
551     @@enDesc:
552     Gets the first package scope block of a name.
553     @@Param:
554     @@@Name: packageName
555     @@@@Type:
556     Perl:package-name::ManakaiDOM:all
557     @@@@enDesc:
558     The fully-qualified name of the package to get.
559     @@NamedParam:
560     @@@Name: makeNewPackage
561     @@@Type:
562 wakaba 1.12 DOMMain:boolean::ManakaiDOM:all
563 wakaba 1.1 @@@enDesc:
564     Whether a new package scope object should be created if
565     no package of <P::packageName> found.
566     @@@TrueCase:
567     @@@@enDesc:
568     Makes a new object if not found.
569     @@@FalseCase:
570     @@@@enDesc:
571     Don't make a new object.
572     @@Return:
573     @@@Type: ManakaiPerlPackageScope
574     @@@enDesc:
575     The first package scope object whose name is equal to
576     <P::packageName>.
577     @@@nullCase:
578     @@@@enDesc:
579     There is no <P::packageName> package object and
580     the <P::makeNewPackage> parameter is set to <DOM::false>.
581     @@@PerlDef:
582     for my $cn (@{$self->{<Q::TreeCore:node>}->{<Q::pc:childNodes>}}) {
583     if ($cn->{<Q::pc:packageName>} eq $packageName) {
584     $r = $cn;
585     last;
586     }
587     }
588     if ($r) {
589 wakaba 1.6 __CODE{ManakaiNode:getNewReference::
590     $object => $r, $ref => $r,
591     $class => {<ClassName::ManakaiPerlPackageScope>}}__;
592 wakaba 1.1 } elsif ($makeNewPackage) {
593     __DEEP{
594     $r = $self-><M::ManakaiPerlFile.appendNewPackage> ($packageName);
595     }__;
596     }
597    
598     @Method:
599     @@Name: getLastPackage
600     @@enDesc:
601     Gets the last package scope block of a name.
602     @@Param:
603     @@@Name: packageName
604     @@@@Type:
605     Perl:package-name::ManakaiDOM:all
606     @@@@enDesc:
607     The fully-qualified name of the package to get.
608     @@NamedParam:
609     @@@Name: makeNewPackage
610     @@@Type:
611 wakaba 1.12 DOMMain:boolean::ManakaiDOM:all
612 wakaba 1.1 @@@enDesc:
613     Whether a new package scope object should be created if
614     no package of <P::packageName> found.
615     @@@TrueCase:
616     @@@@enDesc:
617     Makes a new object if not found.
618     @@@FalseCase:
619     @@@@enDesc:
620     Don't make a new object.
621     @@Return:
622     @@@Type: ManakaiPerlPackageScope
623     @@@enDesc:
624     The last package scope object whose name is equal to
625     <P::packageName>.
626     @@@nullCase:
627     @@@@enDesc:
628     There is no <P::packageName> package object and
629     the <P::makeNewPackage> parameter is set to <DOM::false>.
630     @@@PerlDef:
631     for my $cn (reverse @{$self->{<Q::TreeCore:node>}
632     ->{<Q::pc:childNodes>}}) {
633     if ($cn->{<Q::pc:packageName>} eq $packageName) {
634     $r = $cn;
635     last;
636     }
637     }
638     if ($r) {
639 wakaba 1.6 __CODE{ManakaiNode:getNewReference::
640     $object => $r, $ref => $r,
641     $class => {<ClassName::ManakaiPerlPackageScope>}}__;
642 wakaba 1.1 } elsif ($makeNewPackage) {
643     __DEEP{
644     $r = $self-><M::ManakaiPerlFile.appendNewPackage> ($packageName);
645     }__;
646     }
647    
648     @Attr:
649     @@Name: length
650     @@enDesc:
651     The number of child code fragments.
652     @@Type:
653 wakaba 1.12 DOMMain:unsigned-long::ManakaiDOM:all
654 wakaba 1.1 @@Get:
655     @@@PerlDef:
656 wakaba 1.4 $r = @{$self->{<Q::TreeCore:node>}->{<Q::pc:childNodes>}};
657 wakaba 1.1
658     @Attr:
659     @@Name: sourceFile
660     @@enDesc:
661     The file name of the source file from which this
662     Perl code is primary generated.
663     @@Get:
664     @@@Type:
665 wakaba 1.12 DISLang:String::ManakaiDOM:all
666 wakaba 1.1 @@@disDef:
667     @@@@GetProp: sourceFile
668     @@Set:
669     @@@Type:
670 wakaba 1.12 DISLang:String::ManakaiDOM:all
671 wakaba 1.1 @@@disDef:
672     @@@@SetProp: sourceFile
673    
674     @Attr:
675     @@Name: sourceModule
676     @@enDesc:
677     The name URI reference of the source module that this package defines.
678     @@Get:
679     @@@Type:
680 wakaba 1.12 DISLang:String::ManakaiDOM:all
681 wakaba 1.1 @@@disDef:
682     @@@@GetProp: sourceModule
683     @@Set:
684     @@@Type:
685 wakaba 1.12 DISLang:String::ManakaiDOM:all
686 wakaba 1.1 @@@disDef:
687     @@@@SetProp: sourceModule
688    
689     @Attr:
690     @@Name: sourceFor
691     @@enDesc:
692     The URI reference of the source module <QUOTE::for> for which this
693     package is.
694     @@Get:
695     @@@Type:
696 wakaba 1.12 DISLang:String::ManakaiDOM:all
697 wakaba 1.1 @@@disDef:
698     @@@@GetProp: sourceFor
699     @@Set:
700     @@@Type:
701 wakaba 1.12 DISLang:String::ManakaiDOM:all
702 wakaba 1.1 @@@disDef:
703     @@@@SetProp: sourceFor
704    
705     @ToStringMethod:
706     @@Return:
707     @@@Type:
708 wakaba 1.12 DISLang:String::ManakaiDOM:all
709 wakaba 1.1 @@@enDesc:
710     The Perl code generated.
711     @@@PerlDef:
712     __DEEP{
713     my $node = $self->{<Q::TreeCore:node>};
714     ## -- Header
715     $r = qq<#!/usr/bin/perl \n>;
716     $r .= <ClassM::ManakaiPerlCodeImplementation.perlComment>
717     (q<This file is automatically generated>);
718     $r .= <ClassM::ManakaiPerlCodeImplementation.perlComment>
719     (q< at >.<ClassM::ManakaiPerlCodeImplementation
720     .rfc3339DateTime> (time).q<,>);
721     $r .= <ClassM::ManakaiPerlCodeImplementation.perlComment>
722     (q< from file ">.$node->{<Q::sourceFile>}.q<",>);
723     $r .= <ClassM::ManakaiPerlCodeImplementation.perlComment>
724     (q[ module <].$node->{<Q::sourceModule>}.q[>,]);
725     $r .= <ClassM::ManakaiPerlCodeImplementation.perlComment>
726     (q[ for <].$node->{<Q::sourceFor>}.q[>.]);
727     $r .= <ClassM::ManakaiPerlCodeImplementation.perlComment>
728     (q<Don't edit by hand!>);
729     $r .= qq<use strict;\n>;
730     $self-><AS::ManakaiPerlFile.currentPackage> ('main');
731 wakaba 1.6 $self-><AS::ManakaiPerlFile.currentChunkNumber> (0);
732 wakaba 1.1
733     ## -- Packages
734     my $pack = {};
735     for my $sp (@{$node->{<Q::pc:childNodes>}}) {
736 wakaba 1.6 my $spe;
737     __CODE{ManakaiNode:getWeakReference::
738     $object => $sp, $ref => $spe,
739     $class => {<ClassName::ManakaiPerlPackageScope>}}__;
740 wakaba 1.1 $r .= $spe->stringify;
741     for my $ipack (keys %{$sp->{<Q::dis:Implement>}}) {
742     $pack->{$ipack} ||= true; # not defined
743     }
744     $pack->{$sp->{<Q::pc:packageName>}} = []; # defined
745     }
746    
747     ## -- Enables interface packages
748 wakaba 1.3 my @packs = map {'$' . $_ . '::'}
749     grep {not ref $pack->{$_} and $pack->{$_}}
750     keys %$pack;
751     $r .= q<for (>. join (', ', @packs) . qq<){}\n> if @packs;
752 wakaba 1.1
753     ## -- Footer
754     $r .= <ClassM::ManakaiPerlCodeImplementation.perlComment>
755 wakaba 1.2 (q[License: <].$node->{<Q::dis:License>}.qq[>\n]);
756 wakaba 1.1 $r .= qq<1;\n>;
757     }__;
758    
759     @Attr:
760     @@Name: currentPackage
761     @@enDesc:
762     The current Perl package (used in stringify method).
763     @@Type:
764     Perl:package-name::ManakaiDOM:all
765     @@Get:
766     @@@disDef:
767     @@@@GetProp: currentPackage
768     @@Set:
769     @@@disDef:
770     @@@@SetProp: currentPackage
771    
772     @Attr:
773 wakaba 1.6 @@Name: currentChunkNumber
774 wakaba 1.1 @@enDesc:
775 wakaba 1.6 The current code chunk number (used in stringify method).
776 wakaba 1.1 @@Type:
777     DOMMain:unsigned-long::ManakaiDOM:all
778     @@Get:
779     @@@disDef:
780     @@@@GetProp: currentChunk
781     @@Set:
782     @@@disDef:
783     @@@@SetProp: currentChunk
784 wakaba 1.6
785     @Method:
786     @@Name: getNextChunkNumber
787     @@enDesc:
788     Increments the current chunk number of this file
789     and returns it.
790     @@Return:
791     @@@Type:
792     DOMMain:unsigned-long::ManakaiDOM:all
793     @@@enDesc:
794     The next chunk number.
795     @@@PerlDef:
796     $r = ++$self->{<Q::TreeCore:node>}->{<Q::pc:currentChunk>};
797 wakaba 1.2
798     @Attr:
799     @@Name: licenseURI
800     @@enDesc:
801     The license term URI reference for this code.
802     @@Type:
803     DISLang:String::ManakaiDOM:all
804     @@Get:
805     @@@disDef:
806     @@@@GetProp:
807     dis:License
808     @@Set:
809     @@@disDef:
810     @@@@SetProp:
811     dis:License
812 wakaba 1.1 ##PerlFile
813    
814     PropDef:
815     @QName: sourceModule
816     @enDesc:
817     The soruce module name URI reference.
818    
819     PropDef:
820     @QName: sourceFor
821     @enDesc:
822     The source module <QUOTE::for> URI reference.
823    
824     PropDef:
825     @QName: currentPackage
826     @enDesc:
827     The current Perl package name (used for stringify).
828    
829     PropDef:
830     @QName: currentChunk
831     @enDesc:
832     The current code chunk (used for stringify).
833    
834     ClsDef:
835     @ClsQName: ManakaiPerlPackageScope
836     @ClsISA: ManakaiPerlCodeFragment
837    
838     @Attr:
839     @@Name: packageName
840     @@Type:
841 wakaba 1.12 Perl:package-name::ManakaiDOM:all
842 wakaba 1.1 @@enDesc:
843     The fully-qualified package name.
844     @@Get:
845     @@@disDef:
846     @@@@GetProp: packageName
847    
848     @IntMethod:
849     @@Name:newObject
850     @@ManakaiDOM:isStatic:1
851     @@Description:
852     @@@lang:en
853     @@@@:
854     Creates a new instance object for <Class::ManakaiPerlPackageScope>.
855     @@Return:
856     @@@Type:
857     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
858     @@@Description:
859     @@@@lang:en
860     @@@@@:
861     The newly created node object.
862     @@@PerlDef:
863     @@@@@:
864     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
865     ::ManakaiDOM:Perl.new>;
866 wakaba 1.4 push @{$node->{<Q::TreeCore:subnode2>}}, <Q::pc:sub>,
867     <Q::dis2pm:overload>;
868 wakaba 1.1 push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
869     $node->{<Q::pc:sub>} = {};
870     $node->{<Q::dis:ISA>} = [];
871     $node->{<Q::dis:Implement>} = {};
872 wakaba 1.4 $node->{<Q::dis2pm:overload>} = {};
873 wakaba 1.6 $node->{<Q::pc:nodeType>} = 'package';
874     @@@@ImplNote:
875     @@@@@lang:en
876     @@@@@@:
877     Properties: <Q::pc:sub>, <Q::dis2pm:overload>,
878     <Q::dis:ISA>, <Q::dis:Implement>,
879     <Q::pc:nodeType>.
880 wakaba 1.1
881     @Method:
882     @@Name: getSub
883     @@enDesc:
884     Gets a subroutine.
885     @@Param:
886     @@@Name: subName
887     @@@Type:
888     DISPerl:SubName::ManakaiDOM:all
889     @@@enDesc:
890     The name of subroutine to get.
891     @@NamedParam:
892     @@@Name: makeNewNode
893     @@@Type:
894 wakaba 1.12 DOMMain:boolean::ManakaiDOM:all
895 wakaba 1.1 @@@enDesc:
896     Whether a new subroutine object should be created,
897     if it is not exist, or not.
898     @@Return:
899     @@@Type: ManakaiPerlSub
900     @@@enDesc:
901     The subroutine object.
902 wakaba 1.4 @@@nullCase:
903     @@@@enDesc:
904     Either the specified subroutine is not found and
905     the <P::makeNewNode> parameter is set to <DOM::false> or
906     the subroutine is defined as an alias.
907 wakaba 1.1 @@@PerlDef:
908     if ($self->{<Q::TreeCore:node>}->{<Q::pc:sub>}->{$subName}) {
909 wakaba 1.4 $r = ref $self->{<Q::TreeCore:node>}->{<Q::pc:sub>}->{$subName}
910     ? $self->{<Q::TreeCore:node>}->{<Q::pc:sub>}->{$subName} : null;
911 wakaba 1.1 } elsif ($makeNewNode) {
912     $r = $self->{<Q::TreeCore:node>}->{<Q::pc:sub>}->{$subName}
913     = <ClassM::ManakaiPerlSub.newObject>;
914     $self->{<Q::TreeCore:node>}
915     -><M::ManakaiDOM:ManakaiDOMNodeObject
916     ::ManakaiDOM:Perl.importTree> ($r);
917     $r->{<Q::pc:parent>} = $self->{<Q::TreeCore:node>};
918     $r->{<Q::pc:localName>} = $subName;
919     }
920 wakaba 1.6 if ($r) {
921     __CODE{ManakaiNode:getNewReference::
922     $object => $r, $ref => $r,
923     $class => {<ClassName::ManakaiPerlSub>}}__;
924     }
925 wakaba 1.1
926 wakaba 1.4 @Method:
927 wakaba 1.5 @@Name: setSub
928     @@enDesc:
929     Sets a subrotine.
930     @@Param:
931     @@@Name: subName
932     @@@Type:
933     DISLang:String::ManakaiDOM:all
934     @@@enDesc:
935     The name of the subroutine.
936     \
937     {NOTE:: The <P::subName> value must be equal to the
938     <A::ManakaiPerlSub.localName> of the <P::subArg>.
939     @@Param:
940     @@@Name: subArg
941     @@@Type: ManakaiPerlSub
942     @@@enDesc:
943     The subroutine object.
944     @@Return:
945     @@@RaiseException:
946     @@@@@:IN_USE_NODE_ERR
947     @@@@enDesc:
948     An attempt is made to set a subroutine that is
949     already used elsewhere.
950     @@@PerlDef:
951     my $ops = $self->{<Q::TreeCore:node>}->{<Q::pc:sub>};
952     if (ref $ops->{$subName}) {
953     CORE::delete $ops->{<Q::pc:parent>};
954     $ops->{$subName}
955     -><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl.orphanate>;
956     }
957     if ($subArg->{<Q::TreeCore:node>}->{<Q::pc:parent>}) {
958     __EXCEPTION{IN_USE_NODE_ERR::
959     pc:childNode => {$subArg},
960     }__;
961     }
962     $self->{<Q::TreeCore:node>}-><M::MNodeObject.importTree>
963     ($subArg->{<Q::TreeCore:node>});
964     $ops->{$subName} = $subArg->{<Q::TreeCore:node>};
965     $subArg->{<Q::TreeCore:node>}->{<Q::pc:parent>}
966     = $self->{<Q::TreeCore:node>};
967    
968     @Method:
969 wakaba 1.4 @@Name: getSubAliasName
970     @@enDesc:
971     Gets the real name of a subroutine.
972     @@Param:
973     @@@Name: subName
974     @@@Type:
975     DISLang:String::ManakaiDOM:all
976     @@@enDesc:
977     The name of the alias subroutine.
978     @@Return:
979     @@@Type:
980     DISLang:String::ManakaiDOM:all
981     @@@enDesc:
982     The real name.
983     @@@nullCase:
984     @@@@enDesc:
985     The specified name is used.
986     @@@InCase:
987     @@@@Value:\#CODE
988     @@@@enDesc:
989     The specified name is not an alias.
990     @@@PerlDef:
991     if ($self->{<Q::TreeCore:node>}->{<Q::sub>}->{$subName}) {
992     $r = ref $self->{<Q::TreeCore:node>}
993     ->{<Q::sub>}->{$subName}
994     ? q<#CODE> : $self->{<Q::TreeCore:node>}
995     ->{<Q::sub>}->{$subName};
996     }
997    
998     @Method:
999     @@Name: setSubAliasName
1000     @@enDesc:
1001     Sets a subroutine name as an alias of another subroutine.
1002     @@Param:
1003     @@@Name: aliasName
1004     @@@Type:
1005     DISLang:String::ManakaiDOM:all
1006     @@@enDesc:
1007     The alias name.
1008     @@Param:
1009     @@@Name: realName
1010     @@@Type:
1011     DISLang:String::ManakaiDOM:all
1012     @@@enDesc:
1013     The real name.
1014     @@Return:
1015     @@@UnknownOperatorException:
1016     @@@PerlDef:
1017     my $ops = $self->{<Q::TreeCore:node>}->{<Q::sub>};
1018     if (ref $ops->{$aliasName}) {
1019     CORE::delete $ops->{<Q::pc:parent>};
1020     $ops->{$aliasName}
1021     -><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl.orphanate>;
1022     }
1023     $ops->{$aliasName} = $realName;
1024    
1025     @Method:
1026     @@Name: getOverloadSub
1027     @@enDesc:
1028     Gets an overloading subroutine.
1029     @@Param:
1030     @@@Name: opName
1031     @@@Type:
1032     DISLang:String::ManakaiDOM:all
1033     @@@enDesc:
1034     The name of the overloaded operator.
1035     @@NamedParam:
1036     @@@Name: makeNewNode
1037     @@@Type:
1038 wakaba 1.12 DOMMain:boolean::ManakaiDOM:all
1039 wakaba 1.4 @@@enDesc:
1040     Whether a new subroutine object should be created,
1041     if it is not exist, or not.
1042     @@Return:
1043     @@@Type: ManakaiPerlSub
1044     @@@enDesc:
1045     The subroutine object.
1046     @@@nullCase:
1047     @@@@enDesc:
1048     Either the specified subroutine is not found and
1049     the <P::makeNewNode> parameter is set to <DOM::false> or
1050     the specified operator is overloaded by specifying method name.
1051     @@@UnknownOperatorException:
1052     @@@PerlDef:
1053     unless (<Code::operatorNameList>->{$opName}) {
1054     __EXCEPTION{UNSUPPORTED_OPERATOR_ERR::
1055     pc:operator => {$opName},
1056     }__;
1057     }
1058     if ($self->{<Q::TreeCore:node>}->{<Q::dis2pm:operator>}->{$opName}) {
1059     $r = ref $self->{<Q::TreeCore:node>}
1060     ->{<Q::dis2pm:operator>}->{$opName}
1061     ? $self->{<Q::TreeCore:node>}
1062     ->{<Q::dis2pm:operator>}->{$opName} : null;
1063     } elsif ($makeNewNode) {
1064     $r = $self->{<Q::TreeCore:node>}->{<Q::dis2pm:operator>}->{$opName}
1065     = <ClassM::ManakaiPerlSub.newObject>;
1066     $self->{<Q::TreeCore:node>}
1067     -><M::ManakaiDOM:ManakaiDOMNodeObject
1068     ::ManakaiDOM:Perl.importTree> ($r);
1069     $r->{<Q::pc:parent>} = $self->{<Q::TreeCore:node>};
1070     }
1071 wakaba 1.6 if ($r) {
1072     __CODE{ManakaiNode:getNewReference::
1073     $object => $r, $ref => $r,
1074     $class => {<ClassName::ManakaiPerlSub>}}__;
1075     }
1076 wakaba 1.4
1077     @Method:
1078 wakaba 1.5 @@Name: setOverloadSub
1079     @@enDesc:
1080     Sets an overloading subrotine.
1081     @@Param:
1082     @@@Name: opName
1083     @@@Type:
1084     DISLang:String::ManakaiDOM:all
1085     @@@enDesc:
1086     The name of the opeartor to overload.
1087     @@Param:
1088     @@@Name: subArg
1089     @@@Type: ManakaiPerlSub
1090     @@@enDesc:
1091     The subroutine object.
1092     @@Return:
1093     @@@UnknownOperatorException:
1094     @@@RaiseException:
1095     @@@@@:IN_USE_NODE_ERR
1096     @@@@enDesc:
1097     An attempt is made to set a subroutine that is
1098     already used elsewhere.
1099     @@@PerlDef:
1100     unless (<Code::operatorNameList>->{$opName}) {
1101     __EXCEPTION{UNSUPPORTED_OPERATOR_ERR::
1102     pc:operator => {$opName},
1103     }__;
1104     }
1105     my $ops = $self->{<Q::TreeCore:node>}->{<Q::dis2pm:operator>};
1106     if (ref $ops->{$opName}) {
1107     CORE::delete $ops->{<Q::pc:parent>};
1108     $ops->{$opName}
1109     -><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl.orphanate>;
1110     }
1111     if ($subArg->{<Q::TreeCore:node>}->{<Q::pc:parent>}) {
1112     __EXCEPTION{IN_USE_NODE_ERR::
1113     pc:parentNode => {$self},
1114     pc:childNode => {$subArg},
1115     }__;
1116     }
1117     $self->{<Q::TreeCore:node>}-><M::MNodeObject.importTree>
1118     ($subArg->{<Q::TreeCore:node>});
1119     $ops->{$opName} = $subArg->{<Q::TreeCore:node>};
1120     $subArg->{<Q::TreeCore:node>}->{<Q::pc:parent>}
1121     = $self->{<Q::TreeCore:node>};
1122    
1123    
1124     @Method:
1125 wakaba 1.4 @@Name: getOverloadMethodName
1126     @@enDesc:
1127     Gets an overloading method name.
1128     @@Param:
1129     @@@Name: opName
1130     @@@Type:
1131     DISLang:String::ManakaiDOM:all
1132     @@@enDesc:
1133     The name of the overloaded operator.
1134     @@Return:
1135     @@@Type:
1136     DISLang:String::ManakaiDOM:all
1137     @@@enDesc:
1138     The method name.
1139     @@@nullCase:
1140     @@@@enDesc:
1141     The specified operator is not overloaded.
1142     @@@InCase:
1143     @@@@Value:\#CODE
1144     @@@@enDesc:
1145     The operator is overloaded by an anonymous subroutine.
1146     @@@PerlDef:
1147     if ($self->{<Q::TreeCore:node>}->{<Q::dis2pm:operator>}->{$opName}) {
1148     $r = ref $self->{<Q::TreeCore:node>}
1149     ->{<Q::dis2pm:operator>}->{$opName}
1150     ? q<#CODE> : $self->{<Q::TreeCore:node>}
1151     ->{<Q::dis2pm:operator>}->{$opName};
1152     }
1153    
1154     @Method:
1155     @@Name: setOverloadMethodName
1156     @@enDesc:
1157     Sets an overloading method name.
1158     @@Param:
1159     @@@Name: opName
1160     @@@Type:
1161     DISLang:String::ManakaiDOM:all
1162     @@@enDesc:
1163     The name of the overloaded operator.
1164     @@Param:
1165     @@@Name: methodName
1166     @@@Type:
1167     DISLang:String::ManakaiDOM:all
1168     @@@enDesc:
1169     The name of the method by which overloads an operator.
1170     \
1171     {NOTE:: The method may or may not belong to this package.
1172     \
1173     }
1174     @@Return:
1175     @@@UnknownOperatorException:
1176     @@@PerlDef:
1177     unless (<Code::operatorNameList>->{$opName}) {
1178     __EXCEPTION{UNSUPPORTED_OPERATOR_ERR::
1179     pc:operator => {$opName},
1180     }__;
1181     }
1182     my $ops = $self->{<Q::TreeCore:node>}->{<Q::dis2pm:operator>};
1183     if (ref $ops->{$opName}) {
1184     CORE::delete $ops->{<Q::pc:parent>};
1185     $ops->{$opName}
1186     -><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl.orphanate>;
1187     }
1188     $ops->{$opName} = $methodName;
1189    
1190 wakaba 1.1 @Attr:
1191     @@Name: length
1192     @@enDesc:
1193     The number of child code fragments.
1194     @@Type:
1195 wakaba 1.12 DOMMain:unsigned-long::ManakaiDOM:all
1196 wakaba 1.1 @@Get:
1197     @@@PerlDef:
1198 wakaba 1.4 $r = keys (%{$self->{<Q::TreeCore:node>}->{<Q::pc:sub>}})
1199     + keys (%{$self->{<Q::TreeCore:node>}->{<Q::dis2pm:operator>}});
1200 wakaba 1.1
1201     @Method:
1202 wakaba 1.13 @@Name: addISAPackage
1203 wakaba 1.1 @@enDesc:
1204     Adds a class package that this class inherits.
1205     @@Param:
1206     @@@Name: packageName
1207     @@@Type:
1208     Perl:package-name::ManakaiDOM:all
1209     @@@enDesc:
1210     The name of package to add.
1211     @@Return:
1212     @@@PerlDef:
1213     push @{$self->{<Q::TreeCore:node>}->{<Q::dis:ISA>}}, $packageName;
1214    
1215     @Method:
1216     @@Name: addImplementPackage
1217     @@enDesc:
1218     Adds a interface package that this class implements.
1219     @@Param:
1220     @@@Name: packageName
1221     @@@Type:
1222     Perl:package-name::ManakaiDOM:all
1223     @@@enDesc:
1224     The name of package to add.
1225     @@Return:
1226     @@@PerlDef:
1227     $self->{<Q::TreeCore:node>}->{<Q::dis:Implement>}->{$packageName} = true;
1228    
1229     @ToStringMethod:
1230     @@Return:
1231     @@@Type:
1232 wakaba 1.12 DISLang:String::ManakaiDOM:all
1233 wakaba 1.1 @@@enDesc:
1234     Perl code.
1235     @@@PerlDef:
1236     my $file = $self-><AG::ManakaiPerlCodeFragment.parentNode>;
1237     my $node = $self->{<Q::TreeCore:node>};
1238     my $pn = $node->{<Q::pc:packageName>};
1239     $r .= q<package > . $pn . ";\n";
1240     __DEEP{
1241     $file-><AS::ManakaiPerlFile.currentPackage> ($pn);
1242     $r .= 'our $VERSION = '.
1243     <ClassM::ManakaiPerlCodeImplementation.versionDateTime> (time).
1244     ";\n";
1245     }__;
1246     my @isa = (@{$node->{<Q::dis:ISA>}},
1247     sort keys %{$node->{<Q::dis:Implement>}});
1248     if (@isa) {
1249     $r .= 'push our @ISA, ' .
1250     <ClassM::ManakaiPerlCodeImplementation.perlList> (\@isa) .
1251     ";\n";
1252     }
1253 wakaba 1.4 for my $cnk (keys %{$node->{<Q::pc:sub>}}) {
1254     my $cno = $node->{<Q::pc:sub>}->{$cnk};
1255     if (ref $cno) {
1256 wakaba 1.6 my $cn;
1257     __CODE{ManakaiNode:getWeakReference::
1258     $object => $cno, $ref => $cn,
1259     $class => {<ClassName::ManakaiPerlSub>}}__;
1260 wakaba 1.4 $r .= $cn->stringify;
1261     } else {
1262     $r .= qq<*$cnk = \&$cno;\n>;
1263     }
1264     }
1265     my $op = '';
1266     for my $cnk (keys %{$node->{<Q::dis2pm:operator>}}) {
1267     my $cno = $node->{<Q::dis2pm:operator>}->{$cnk};
1268     if (ref $cno) {
1269 wakaba 1.6 my $cn;
1270     __CODE{ManakaiNode:getWeakReference::
1271     $object => $cno, $ref => $cn,
1272     $class => {<ClassName::ManakaiPerlSub>}}__;
1273 wakaba 1.4 $op .= <ClassM::ManakaiPerlCodeImplementation.perlLiteral> ($cnk)
1274     . ' => ' . $cn->stringify . ', ';
1275     } elsif (defined $cno) {
1276     $op .= <ClassM::ManakaiPerlCodeImplementation.perlList>
1277     ([$cnk => $cno]) . ', ';
1278     }
1279     }
1280     $r .= 'use overload ' . $op . qq[fallback => 1;\n] if $op;
1281 wakaba 1.1 ##PerlPackageScope
1282    
1283 wakaba 1.4 PropDef:
1284     @QName:
1285     dis2pm:operator
1286     @enDesc:
1287     Overloaded operators.
1288    
1289     ElementTypeBinding:
1290     @Name: UnknownOperatorException
1291     @ElementType:
1292     ManakaiDOM:raises
1293     @ShadowContent:
1294     @@@:UNSUPPORTED_OPERATOR_ERR
1295     @@enDesc:
1296     An attempt is made to overload an unknown operator.
1297    
1298     XParamDef:
1299     @QName:
1300     pc:operator
1301     @enDesc:
1302     An operator to overload.
1303    
1304     ResourceDef:
1305     @QName: operatorNameList
1306     @enDesc:
1307     The list of valid operators for <PerlModule::operator> pragma.
1308     @rdf:type:
1309     dis2pm:InlineCode
1310     @PerlDef:
1311     {qw[
1312     + 1 - 1 * 1 / 1 % 1 ** 1 << 1 >> 1 x 1 . 1
1313     += 1 -= 1 *= 1 /= 1 %= 1 **= 1 <<= 1 >>= 1 x= 1 .= 1
1314     < 1 <= 1 > 1 >= 1 == 1 != 1 <=> 1
1315     lt 1 le 1 gt 1 ge 1 eq 1 ne 1 cmp 1
1316     & 1 | 1 ^ 1 neg 1 ! 1 ~ 1
1317     ++ 1 -- 1 = 1
1318     atan2 1 cos 1 sin 1 exp 1 abs 1 log 1 sqrt 1
1319     bool 1 "" 1 0+ 1 ${} 1 @{} 1 %{} 1 &{} 1 *{} 1 <> 1
1320     nomethod 1
1321     ]}
1322    
1323 wakaba 1.1 ClsDef:
1324 wakaba 1.6 @ClsQName: ManakaiPerlStatementContainer
1325     @ClsISA: ManakaiPerlAnyContainer
1326 wakaba 1.1 @enDesc:
1327 wakaba 1.6 A base class for node types that contains zero or more
1328     statements and/or blocks.
1329 wakaba 1.1
1330     @Attr:
1331 wakaba 1.10 @@Name: sourceFile
1332     @@enDesc:
1333     The source file name of this fragment.
1334     @@Type:
1335 wakaba 1.12 DISLang:String::ManakaiDOM:all
1336 wakaba 1.10 @@Get:
1337     @@@enDesc:
1338     Any string identifying the source.
1339     @@@nullCase:
1340     @@@@enDesc: No source file name is set.
1341     @@@disDef:
1342     @@@@GetProp: sourceFile
1343     @@Set:
1344     @@@nullCase:
1345     @@@@enDesc: No (or unknown) source file.
1346     @@@disDef:
1347     @@@@SetProp: sourceFile
1348    
1349     @Attr:
1350     @@Name: sourceLine
1351     @@enDesc:
1352     Source file line number of the first line of this fragment.
1353     @@Type:
1354 wakaba 1.12 DOMMain:unsigned-long::ManakaiDOM:all
1355 wakaba 1.10 @@Get:
1356     @@@disDef:
1357     @@@@GetProp: sourceLine
1358     @@Set:
1359     @@@disDef:
1360     @@@@SetProp: sourceLine
1361    
1362     @Attr:
1363 wakaba 1.1 @@Name: currentSourceFile
1364     @@enDesc:
1365     The current source file name that is referred when
1366     a code fragment is added.
1367     @@Type:
1368 wakaba 1.12 DISLang:String::ManakaiDOM:all
1369 wakaba 1.1 @@Get:
1370     @@@nullCase:
1371     @@@@enDesc: No source file name is set.
1372     @@@disDef:
1373 wakaba 1.10 @@@@GetProp:currentSourceFile
1374 wakaba 1.1 @@Set:
1375     @@@nullCase:
1376     @@@@enDesc: No (or unknown) source file.
1377     @@@disDef:
1378 wakaba 1.10 @@@@SetProp:currentSourceFile
1379 wakaba 1.1
1380     @Attr:
1381     @@Name: currentSourceLine
1382     @@enDesc:
1383     The current line number in source file that is referred when
1384     a code fragment is added.
1385     @@Type:
1386 wakaba 1.6 DOMMain:unsigned-long::ManakaiDOM:all
1387 wakaba 1.1 @@Get:
1388     @@@disDef:
1389 wakaba 1.10 @@@@GetProp:currentSourceLine
1390 wakaba 1.1 @@Set:
1391     @@@disDef:
1392 wakaba 1.10 @@@@SetProp:currentSourceLine
1393 wakaba 1.1
1394     @Method:
1395 wakaba 1.5 @@Name: appendCodeFragment
1396     @@enDesc:
1397     Appends a <Class::ManakaiPerlCodeFragment> object.
1398     @@Param:
1399     @@@Name: codeArg
1400     @@@Type: ManakaiPerlCodeFragment
1401     @@@enDesc:
1402     A code fragment object.
1403     @@Return:
1404     @@@RaiseException:
1405     @@@@@:BAD_CHILD_ERR
1406     @@@@enDesc:
1407     An attempt is made to append a child
1408     that is not a <Class::ManakaiPerlUnparsedCode>.
1409     @@@RaiseException:
1410     @@@@@:IN_USE_NODE_ERR
1411     @@@@enDesc:
1412     An attempt is made to append a node that is
1413     already used elsewhere.
1414     @@@PerlDef:
1415 wakaba 1.6 if ({
1416     unparsed => 1, if => 1, statement => 1, block => 1,
1417 wakaba 1.9 blockcontainer => true,
1418 wakaba 1.6 inunparsed => 1, variable => 1, bare => 1, atom => 1,
1419     incontainer => 1, string => 1, assign => 1,
1420     }->{$codeArg->{<Q::TreeCore:node>}->{<Q::pc:nodeType>}}) {
1421 wakaba 1.5 if ($codeArg->{<Q::TreeCore:node>}->{<Q::pc:parent>}) {
1422     __EXCEPTION{IN_USE_NODE_ERR::
1423     pc:childNode => {$codeArg},
1424     }__;
1425     }
1426     $self->{<Q::TreeCore:node>}-><M::MNodeObject.importTree>
1427     ($codeArg->{<Q::TreeCore:node>});
1428     push @{$self->{<Q::TreeCore:node>}->{<Q::pc:childNodes>}},
1429     $codeArg->{<Q::TreeCore:node>};
1430     $codeArg->{<Q::TreeCore:node>}->{<Q::pc:parent>}
1431     = $self->{<Q::TreeCore:node>};
1432     } else {
1433     __EXCEPTION{BAD_CHILD_ERR::
1434     pc:parentNode => {$self},
1435     pc:childNode => {$codeArg},
1436     }__;
1437     }
1438    
1439     @Method:
1440 wakaba 1.1 @@Name: appendCode
1441     @@enDesc:
1442     Appends an unparsed Perl code fragment.
1443     @@Param:
1444     @@@Name: codeArg
1445     @@@Type:
1446     lang:Perl::ManakaiDOM:all
1447     @@@enDesc:
1448     An unparsed Perl code fragment.
1449     @@Return:
1450     @@@Type: ManakaiPerlUnparsedCode
1451     @@@enDesc:
1452     The newly created Perl code object.
1453     @@@PerlDef:
1454     $r = <ClassM::ManakaiPerlUnparsedCode.newObject>;
1455     my $node = $self->{<Q::TreeCore:node>};
1456 wakaba 1.10 $r->{<Q::sourceFile>} = $node->{<Q::pc:currentSourceFile>};
1457     $r->{<Q::sourceLine>} = $node->{<Q::pc:currentSourceLine>};
1458 wakaba 1.1 $r->{<Q::code>} = $codeArg;
1459 wakaba 1.10 $node->{<Q::pc:currentSourceLine>} += ($codeArg =~ tr/\x0A/\x0A/);
1460 wakaba 1.6 $node-><M::ManakaiDOM:ManakaiDOMNodeObject
1461     ::ManakaiDOM:Perl.importTree> ($r);
1462     push @{$node->{<Q::pc:childNodes>}}, $r;
1463     $r->{<Q::pc:parent>} = $node;
1464     __CODE{ManakaiNode:getNewReference::
1465     $object => $r, $ref => $r,
1466     $class =>{<ClassName::ManakaiPerlUnparsedCode>},
1467     }__;
1468 wakaba 1.1
1469     @Method:
1470     @@Name: skipLines
1471     @@enDesc:
1472     Skips lines in a code.
1473     @@Param:
1474     @@@Name: codeArg
1475     @@@Type:
1476     lang:Perl::ManakaiDOM:all
1477     @@@enDesc:
1478     A code fragment, which is counted lines.
1479     @@Return:
1480     @@@PerlDef:
1481 wakaba 1.10 $self->{<Q::TreeCore:node>}->{<Q::pc:currentSourceLine>}
1482 wakaba 1.1 += ($codeArg =~ tr/\x0A/\x0A/);
1483 wakaba 1.4
1484 wakaba 1.6 @ImplNote:
1485     @@lang:en
1486     @@@:
1487     A <Class::ManakaiPerlStatementContainer> object must have
1488     a property:
1489     <Q::pc:childNodes>.
1490 wakaba 1.8
1491     @Attr:
1492     @@Name: label
1493     @@enDesc:
1494     Label for this block.
1495     @@Type:
1496     DISLang:String::ManakaiDOM:all
1497     @@Get:
1498     @@@nullCase:
1499     @@@@enDesc:
1500     No label.
1501     @@@disDef:
1502     @@@@GetProp:label
1503     @@Set:
1504     @@@nullCase:
1505     @@@@enDesc:
1506     No label.
1507     @@@disDef:
1508     @@@@SetProp:label
1509    
1510     @Method:
1511     @@Name: appendBlock
1512     @@enDesc:
1513     Appends a Perl block code.
1514     @@Return:
1515     @@@Type: ManakaiPerlBlock
1516     @@@enDesc:
1517     The newly created Perl code object.
1518     @@@PerlDef:
1519     $r = <ClassM::ManakaiPerlBlock.newObject>;
1520     my $node = $self->{<Q::TreeCore:node>};
1521     $node-><M::ManakaiDOM:ManakaiDOMNodeObject
1522     ::ManakaiDOM:Perl.importTree> ($r);
1523     push @{$node->{<Q::pc:childNodes>}}, $r;
1524     $r->{<Q::pc:parent>} = $node;
1525     if (defined wantarray) {
1526     __CODE{ManakaiNode:getNewReference::
1527     $object => $r, $ref => $r,
1528     $class =>{<ClassName::ManakaiPerlBlock>},
1529     }__;
1530     }
1531    
1532     @Method:
1533     @@Name: appendStatement
1534     @@enDesc:
1535     Appends a Perl statement.
1536     @@Param:
1537     @@@Name: codeArg
1538     @@@Type:
1539     lang:Perl::ManakaiDOM:all
1540     @@@enDesc:
1541     A Perl statement without terminating <Perl::;>.
1542     @@@nullCase:
1543     @@@@enDesc:
1544     No initial content.
1545     @@Return:
1546     @@@Type: ManakaiPerlStatement
1547     @@@enDesc:
1548     The newly created Perl code object.
1549     @@@PerlDef:
1550     $r = <ClassM::ManakaiPerlStatement.newObject>;
1551     my $node = $self->{<Q::TreeCore:node>};
1552     $node-><M::ManakaiDOM:ManakaiDOMNodeObject
1553     ::ManakaiDOM:Perl.importTree> ($r);
1554     push @{$node->{<Q::pc:childNodes>}}, $r;
1555     $r->{<Q::pc:parent>} = $node;
1556     if (defined wantarray or defined $codeArg) {
1557     __CODE{ManakaiNode:getNewReference::
1558     $object => $r, $ref => $r,
1559     $class =>{<ClassName::ManakaiPerlStatement>},
1560     }__;
1561     if (defined $codeArg) {
1562     __DEEP{
1563     $r-><M::ManakaiPerlAnyContainer.appendBare> ($codeArg);
1564     }__;
1565     }
1566     }
1567 wakaba 1.12
1568     @Method:
1569     @@Name: appendNewIf
1570     @@enDesc:
1571     Appends a newly created <Class::ManakaiPerlIf> object.
1572     @@Param:
1573     @@@Name: conditionArg
1574     @@@Type: ManakaiPerlCodeFragment
1575     @@@enDesc:
1576     Conditoon code fragment object.
1577     @@Param:
1578     @@@Name: trueArg
1579     @@@Type: ManakaiPerlCodeFragment
1580     @@@enDesc:
1581     A true code fragment object.
1582     @@@nullCase:
1583     @@@@enDesc: No true code.
1584     @@Param:
1585     @@@Name: falseArg
1586     @@@Type: ManakaiPerlCodeFragment
1587     @@@enDesc:
1588     A false code fragment object.
1589     @@@nullCase:
1590     @@@@enDesc: No false code.
1591     @@Return:
1592     @@@RaiseException:
1593     @@@@@:BAD_CHILD_ERR
1594     @@@@enDesc:
1595     An attempt is made to append a child
1596     that is not valid type.
1597     @@@RaiseException:
1598     @@@@@:IN_USE_NODE_ERR
1599     @@@@enDesc:
1600     An attempt is made to append a node that is
1601     already used elsewhere.
1602     @@@PerlDef:
1603     for my $arg ([conditionArg => $conditionArg]) {
1604     if ({
1605     atom => 1, bare => 1, incontainer => 1, assign => true,
1606     inunparsed => 1, variable => 1, string => true,
1607     }->{$arg->[1]->{<Q::TreeCore:node>}->{<Q::pc:nodeType>}}) {
1608     if ($arg->[1]->{<Q::TreeCore:node>}->{<Q::pc:parent>}) {
1609     __EXCEPTION{IN_USE_NODE_ERR::
1610     pc:childNode => {$arg->[1]},
1611     MDOMX:param-name => {$arg->[0]},
1612     }__;
1613     }
1614     } else {
1615     __EXCEPTION{BAD_CHILD_ERR::
1616     pc:parentNode => {$self},
1617     pc:childNode => {$arg->[1]},
1618     MDOMX:param-name => {$arg->[0]},
1619     }__;
1620     }
1621     } # c
1622    
1623     for my $arg ([trueArg => $trueArg],
1624     [falseArg => $falseArg]) {
1625     next unless $arg->[1];
1626     if ({
1627     blockcontainer => true,
1628     }->{$arg->[1]->{<Q::TreeCore:node>}->{<Q::pc:nodeType>}}) {
1629     if ($arg->[1]->{<Q::TreeCore:node>}->{<Q::pc:parent>}) {
1630     __EXCEPTION{IN_USE_NODE_ERR::
1631     pc:childNode => {$arg->[1]},
1632     MDOMX:param-name => {$arg->[0]},
1633     }__;
1634     }
1635     } else {
1636     __EXCEPTION{BAD_CHILD_ERR::
1637     pc:parentNode => {$self},
1638     pc:childNode => {$arg->[1]},
1639     MDOMX:param-name => {$arg->[0]},
1640     }__;
1641     }
1642     } # t/f
1643    
1644     my $assign = <ClassM::ManakaiPerlIf.newObject>;
1645     $assign->{<Q::pc:condition>} = $conditionArg->{<Q::TreeCore:node>};
1646     $assign->{<Q::pc:true>} = $trueArg->{<Q::TreeCore:node>} if $trueArg;
1647     $assign->{<Q::pc:false>} = $falseArg->{<Q::TreeCore:node>} if $falseArg;
1648     $conditionArg->{<Q::TreeCore:node>}->{<Q::pc:parent>} = $assign;
1649     $trueArg->{<Q::TreeCore:node>}->{<Q::pc:parent>} = $assign if $trueArg;
1650     $falseArg->{<Q::TreeCore:node>}->{<Q::pc:parent>} = $assign if $falseArg;
1651     $self->{<Q::TreeCore:node>}-><M::MNodeObject.importTree> ($assign);
1652     $assign->{<Q::pc:parent>} = $self->{<Q::TreeCore:node>};
1653     push @{$self->{<Q::TreeCore:node>}->{<Q::pc:childNodes>}}, $assign;
1654 wakaba 1.6 ##PerlStatementContainer
1655    
1656     ClsDef:
1657     @ClsQName: ManakaiPerlSub
1658     @ClsISA: ManakaiPerlStatementContainer
1659     @enDesc:
1660     Perl subroutines.
1661    
1662     @IntMethod:
1663     @@Name:newObject
1664     @@ManakaiDOM:isStatic:1
1665     @@Description:
1666     @@@lang:en
1667     @@@@:
1668     Creates a new instance object for <Class::ManakaiPerlSub>.
1669     @@Return:
1670     @@@Type:
1671     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
1672     @@@Description:
1673     @@@@lang:en
1674     @@@@@:
1675     The newly created node object.
1676     @@@PerlDef:
1677     @@@@@:
1678     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
1679     ::ManakaiDOM:Perl.new>;
1680     push @{$node->{<Q::TreeCore:subnode>}}, <Q::pc:childNodes>;
1681     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
1682     $node->{<Q::pc:childNodes>} = [];
1683     $node->{<Q::pc:sourceLine>} = 0;
1684     $node->{<Q::pc:nodeType>} = 'sub';
1685     @@@@ImplNote:
1686     @@@@@lang:en
1687     @@@@@@:
1688     Optional properties: <Q::pc:localName>,
1689     <Q::pc:sourceFile>, <Q::pc:sourceLine>,
1690     <Q::pc:nodeType>.
1691    
1692     @Attr:
1693     @@Name: localName
1694     @@enDesc:
1695     The name of this subroutine.
1696     @@Type:
1697 wakaba 1.12 DISPerl:SubName::ManakaiDOM:all
1698 wakaba 1.6 @@Get:
1699     @@@nullCase:
1700     @@@@enDesc:
1701     This subroutine has no name.
1702     @@@disDef:
1703     @@@@GetProp: localName
1704     @@Set:
1705     @@@enDesc:
1706     Sets the name of this subroutine.
1707     \
1708     {NOTE:: Setting this attribute does not change the
1709     name by which the subroutine is registerred to
1710     the parent object.
1711     \
1712     }
1713     @@@nullCase:
1714     @@@@enDesc:
1715     This subroutine has no name.
1716     @@@disDef:
1717     @@@@SetProp: localName
1718    
1719     @Attr:
1720     @@Name: prototype
1721     @@enDesc:
1722     The prototype of this subroutine.
1723     @@Type:
1724 wakaba 1.11 DISPerl:SubPrototype::ManakaiDOM:all
1725 wakaba 1.6 @@Get:
1726     @@@disDef:
1727     @@@@GetProp: prototype
1728     @@@nullCase:
1729     @@@@enDesc:
1730     No prototype is set.
1731     @@Set:
1732     @@@disDef:
1733     @@@@SetProp: prototype
1734     @@@nullCase:
1735     @@@@enDesc:
1736     No prototype declaration.
1737    
1738 wakaba 1.4 @ToStringMethod:
1739     @@Return:
1740     @@@Type:
1741 wakaba 1.11 DISLang:String::ManakaiDOM:all
1742 wakaba 1.4 @@@enDesc:
1743     Perl code.
1744     @@@PerlDef:
1745     my $node = $self->{<Q::TreeCore:node>};
1746     $r = q<sub>;
1747     $r .= ' ' . $node->{<Q::pc:localName>}
1748     if defined $node->{<Q::pc:localName>};
1749     $r .= ' (' . $node->{<Q::pc:prototype>} . ')'
1750     if defined $node->{<Q::pc:prototype>};
1751     $r .= " {\n";
1752 wakaba 1.6 for my $cno (@{$node->{<Q::pc:childNodes>}}) {
1753 wakaba 1.7 my $cn = <ClassM::ManakaiPerlCodeFragment.getNodeReference> ($cno);
1754 wakaba 1.6 $r .= $cn->stringify;
1755     }
1756 wakaba 1.4 $r .= "}\n";
1757 wakaba 1.1 ##PerlSub
1758    
1759 wakaba 1.5 XParamDef:
1760     @QName: parentNode
1761     @enDesc:
1762     Parent node.
1763    
1764     XParamDef:
1765     @QName: childNode
1766     @enDesc:
1767     Child node.
1768    
1769 wakaba 1.1 ClsDef:
1770     @ClsQName: ManakaiPerlUnparsedCode
1771     @ClsISA: ManakaiPerlCodeFragment
1772     @enDesc:
1773     Unparsed Perl code fragments.
1774    
1775     @IntMethod:
1776     @@Name:newObject
1777     @@ManakaiDOM:isStatic:1
1778     @@Description:
1779     @@@lang:en
1780     @@@@:
1781     Creates a new instance object for <Class::ManakaiPerlUnparsedCode>.
1782     @@Return:
1783     @@@Type:
1784     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
1785     @@@Description:
1786     @@@@lang:en
1787     @@@@@:
1788     The newly created node object.
1789     @@@PerlDef:
1790     @@@@@:
1791     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
1792     ::ManakaiDOM:Perl.new>;
1793     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
1794     $node->{<Q::pc:code>} = '';
1795 wakaba 1.6 $node->{<Q::pc:nodeType>} = 'unparsed';
1796 wakaba 1.1 @@@@ImplNote:
1797     @@@@@lang:en
1798     @@@@@@:
1799 wakaba 1.9 Properties: <Q::pc:nodeType>, <Q::pc:code>,
1800     <Q::pc:sourceFile>, <Q::pc:sourceLine>.
1801    
1802     @IntCloneMethod:
1803     @@Return:
1804     @@@Type:
1805     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
1806     @@@PerlDef:
1807     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
1808     ::ManakaiDOM:Perl.new>;
1809     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
1810     for my $prop (<Q::pc:sourceFile>, <Q::pc:sourceLine>, <Q::pc:code>) {
1811     $node->{$prop} = $nodeObject->{$prop};
1812     }
1813     $node->{<Q::pc:nodeType>} = 'unparsed';
1814 wakaba 1.5
1815     @Attr:
1816     @@Name: code
1817     @@enDesc:
1818     Perl code.
1819     @@Type:
1820     lang:Perl::ManakaiDOM:all
1821     @@Get:
1822     @@@disDef:
1823     @@@@GetProp: code
1824     @@Set:
1825     @@@disDef:
1826     @@@@SetProp: code
1827    
1828     @Attr:
1829     @@Name: sourceFile
1830     @@enDesc:
1831     The source file name of this fragment.
1832     @@Type:
1833 wakaba 1.12 DISLang:String::ManakaiDOM:all
1834 wakaba 1.5 @@Get:
1835     @@@enDesc:
1836     Any string identifying the source.
1837     @@@nullCase:
1838     @@@@enDesc: No source file name is set.
1839     @@@disDef:
1840     @@@@GetProp: sourceFile
1841     @@Set:
1842     @@@nullCase:
1843     @@@@enDesc: No (or unknown) source file.
1844     @@@disDef:
1845     @@@@SetProp: sourceFile
1846    
1847     @Attr:
1848     @@Name: sourceLine
1849     @@enDesc:
1850     Source file line number of the first line of this fragment.
1851     @@Type:
1852 wakaba 1.12 DOMMain:unsigned-long::ManakaiDOM:all
1853 wakaba 1.5 @@Get:
1854     @@@disDef:
1855     @@@@GetProp: sourceLine
1856     @@Set:
1857     @@@disDef:
1858     @@@@SetProp: sourceLine
1859 wakaba 1.6
1860     @ToStringMethod:
1861     @@Return:
1862     @@@Type:
1863 wakaba 1.12 DISLang:String::ManakaiDOM:all
1864 wakaba 1.6 @@@enDesc:
1865     Perl code.
1866     @@@PerlDef:
1867     my $node = $self->{<Q::TreeCore:node>};
1868     __DEEP{
1869     my $file = $self-><AG::ManakaiPerlCodeFragment.fileNode>;
1870 wakaba 1.9 $r = sprintf (qq<\n#line %d "%s (Chunk #%d)"\n>,
1871 wakaba 1.10 $node->{<Q::pc:sourceLine>} || 1,
1872     $node->{<Q::pc:sourceFile>} ||
1873     $file-><AG::ManakaiPerlFile.sourceFile>,
1874 wakaba 1.6 $file-><M::ManakaiPerlFile.getNextChunkNumber>)
1875     . $node->{<Q::pc:code>}
1876 wakaba 1.9 . sprintf (qq<\n#line 1 "%s (Chunk #%d)"\n>,
1877 wakaba 1.6 $file-><AG::ManakaiPerlFile.sourceFile>,
1878     $file-><M::ManakaiPerlFile.getNextChunkNumber>);
1879     }__;
1880 wakaba 1.1 ##PerlUnparsedCode
1881    
1882     ClsDef:
1883 wakaba 1.6 @ClsQName: ManakaiPerlInlineUnparsedCode
1884     @ClsISA: ManakaiPerlCodeFragment
1885     @enDesc:
1886     Unparsed Perl inline code fragments.
1887    
1888     @IntMethod:
1889     @@Name:newObject
1890     @@ManakaiDOM:isStatic:1
1891     @@Description:
1892     @@@lang:en
1893     @@@@:
1894     Creates a new instance object for
1895     <Class::ManakaiPerlInlineUnparsedCode>.
1896     @@Return:
1897     @@@Type:
1898     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
1899     @@@Description:
1900     @@@@lang:en
1901     @@@@@:
1902     The newly created node object.
1903     @@@PerlDef:
1904     @@@@@:
1905     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
1906     ::ManakaiDOM:Perl.new>;
1907     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
1908     $node->{<Q::pc:code>} = '';
1909     $node->{<Q::pc:nodeType>} = 'inunparsed';
1910     @@@@ImplNote:
1911     @@@@@lang:en
1912     @@@@@@:
1913     Properties: <Q::pc:nodeType>, <Q::pc:code>.
1914    
1915 wakaba 1.9 @IntCloneMethod:
1916     @@Return:
1917     @@@Type:
1918     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
1919     @@@PerlDef:
1920     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
1921     ::ManakaiDOM:Perl.new>;
1922     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
1923     for my $prop (<Q::pc:code>) {
1924     $node->{$prop} = $nodeObject->{$prop};
1925     }
1926     $node->{<Q::pc:nodeType>} = 'inunparsed';
1927    
1928 wakaba 1.6 @Attr:
1929     @@Name: code
1930     @@enDesc:
1931     Perl code.
1932     @@Type:
1933     lang:Perl::ManakaiDOM:all
1934     @@Get:
1935     @@@disDef:
1936     @@@@GetProp: code
1937     @@Set:
1938     @@@disDef:
1939     @@@@SetProp: code
1940    
1941     @ToStringMethod:
1942     @@Return:
1943     @@@Type:
1944 wakaba 1.12 DISLang:String::ManakaiDOM:all
1945 wakaba 1.6 @@@enDesc:
1946     Perl code.
1947     @@@PerlDef:
1948     my $node = $self->{<Q::TreeCore:node>};
1949     $r = $node->{<Q::pc:code>};
1950     ##PerlInlineUnparsedCode
1951    
1952     ClsDef:
1953     @ClsQName: ManakaiPerlStringLiteral
1954     @ClsISA: ManakaiPerlCodeFragment
1955     @enDesc:
1956     Perl string literal.
1957    
1958     @IntMethod:
1959     @@Name:newObject
1960     @@ManakaiDOM:isStatic:1
1961     @@Description:
1962     @@@lang:en
1963     @@@@:
1964     Creates a new instance object for
1965     <Class::ManakaiPerlStringLiteral>.
1966     @@Return:
1967     @@@Type:
1968     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
1969     @@@Description:
1970     @@@@lang:en
1971     @@@@@:
1972     The newly created node object.
1973     @@@PerlDef:
1974     @@@@@:
1975     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
1976     ::ManakaiDOM:Perl.new>;
1977     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
1978     $node->{<Q::infoset:data>} = '';
1979     $node->{<Q::pc:nodeType>} = 'string';
1980     @@@@ImplNote:
1981     @@@@@lang:en
1982     @@@@@@:
1983     Properties: <Q::pc:nodeType>, <Q::infoset:data>.
1984    
1985 wakaba 1.9 @IntCloneMethod:
1986     @@Return:
1987     @@@Type:
1988     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
1989     @@@PerlDef:
1990     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
1991     ::ManakaiDOM:Perl.new>;
1992     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
1993     for my $prop (<Q::infoset:data>) {
1994     $node->{$prop} = $nodeObject->{$prop};
1995     }
1996     $node->{<Q::pc:nodeType>} = 'string';
1997    
1998 wakaba 1.6 @Attr:
1999     @@Name: data
2000     @@enDesc:
2001     String data.
2002     @@Type:
2003     DISLang:String::ManakaiDOM:all
2004     @@Get:
2005     @@@disDef:
2006     @@@@GetProp:
2007     infoset:data
2008     @@Set:
2009     @@@disDef:
2010     @@@@SetProp:
2011     infoset:data
2012    
2013     @ToStringMethod:
2014     @@Return:
2015     @@@Type:
2016 wakaba 1.12 DISLang:String::ManakaiDOM:all
2017 wakaba 1.6 @@@enDesc:
2018     Perl code.
2019     @@@PerlDef:
2020     my $node = $self->{<Q::TreeCore:node>};
2021     $r = $node->{<Q::infoset:data>};
2022     $r =~ s/(['\\])/\\$1/g;
2023     $r = q<'> . $r . q<'>;
2024     ##PerlStringLiteral
2025    
2026 wakaba 1.12 ## TODO: -> Separate module
2027     PropDef:
2028     @QName:
2029     infoset:data
2030    
2031 wakaba 1.6 ClsDef:
2032     @ClsQName: ManakaiPerlBare
2033     @ClsISA: ManakaiPerlCodeFragment
2034     @enDesc:
2035     Unparsed Perl inline code fragments.
2036    
2037     @IntMethod:
2038     @@Name:newObject
2039     @@ManakaiDOM:isStatic:1
2040     @@Description:
2041     @@@lang:en
2042     @@@@:
2043     Creates a new instance object for
2044     <Class::ManakaiPerlInlineBare>.
2045     @@Return:
2046     @@@Type:
2047     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2048     @@@Description:
2049     @@@@lang:en
2050     @@@@@:
2051     The newly created node object.
2052     @@@PerlDef:
2053     @@@@@:
2054     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2055     ::ManakaiDOM:Perl.new>;
2056     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2057     $node->{<Q::pc:code>} = '';
2058     $node->{<Q::pc:nodeType>} = 'bare';
2059     @@@@ImplNote:
2060     @@@@@lang:en
2061     @@@@@@:
2062     Properties: <Q::pc:nodeType>, <Q::pc:code>.
2063    
2064 wakaba 1.9 @IntCloneMethod:
2065     @@Return:
2066     @@@Type:
2067     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2068     @@@PerlDef:
2069     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2070     ::ManakaiDOM:Perl.new>;
2071     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2072     for my $prop (<Q::pc:code>) {
2073     $node->{$prop} = $nodeObject->{$prop};
2074     }
2075     $node->{<Q::pc:nodeType>} = 'bare';
2076    
2077 wakaba 1.6 @Attr:
2078     @@Name: code
2079     @@enDesc:
2080     Perl code.
2081     @@Type:
2082     lang:Perl::ManakaiDOM:all
2083     @@Get:
2084     @@@disDef:
2085     @@@@GetProp: code
2086     @@Set:
2087     @@@disDef:
2088     @@@@SetProp: code
2089    
2090     @ToStringMethod:
2091     @@Return:
2092     @@@Type:
2093 wakaba 1.12 DISLang:String::ManakaiDOM:all
2094 wakaba 1.6 @@@enDesc:
2095     Perl code.
2096     @@@PerlDef:
2097     my $node = $self->{<Q::TreeCore:node>};
2098     $r = $node->{<Q::pc:code>};
2099     ##PerlBare
2100    
2101     ClsDef:
2102     @ClsQName: ManakaiPerlAtom
2103     @ClsISA: ManakaiPerlBare
2104     @enDesc:
2105     Unparsed Perl atomic code fragments (such as numeric literal).
2106    
2107     @IntMethod:
2108     @@Name:newObject
2109     @@ManakaiDOM:isStatic:1
2110     @@Description:
2111     @@@lang:en
2112     @@@@:
2113     Creates a new instance object for
2114     <Class::ManakaiPerlAtom>.
2115     @@Return:
2116     @@@Type:
2117     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2118     @@@Description:
2119     @@@@lang:en
2120     @@@@@:
2121     The newly created node object.
2122     @@@PerlDef:
2123     @@@@@:
2124     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2125     ::ManakaiDOM:Perl.new>;
2126     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2127     $node->{<Q::pc:code>} = '';
2128     $node->{<Q::pc:nodeType>} = 'atom';
2129     @@@@ImplNote:
2130     @@@@@lang:en
2131     @@@@@@:
2132     Properties: <Q::pc:nodeType>, <Q::pc:code>.
2133    
2134 wakaba 1.9 @IntCloneMethod:
2135     @@Return:
2136     @@@Type:
2137     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2138     @@@PerlDef:
2139     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2140     ::ManakaiDOM:Perl.new>;
2141     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2142     for my $prop (<Q::pc:code>) {
2143     $node->{$prop} = $nodeObject->{$prop};
2144     }
2145     $node->{<Q::pc:nodeType>} = 'atom';
2146    
2147 wakaba 1.6 @ToStringMethod:
2148     @@Return:
2149     @@@Type:
2150 wakaba 1.12 DISLang:String::ManakaiDOM:all
2151 wakaba 1.6 @@@enDesc:
2152     Perl code.
2153     @@@PerlDef:
2154     my $node = $self->{<Q::TreeCore:node>};
2155     $r = $node->{<Q::pc:code>};
2156     ##PerlAtom
2157    
2158     ClsDef:
2159     @ClsQName: ManakaiPerlVariable
2160     @ClsISA: ManakaiPerlCodeFragment
2161     @enDesc:
2162     Unparsed Perl variable.
2163     \
2164     {NOTE:: Future version of the implementation may
2165     support to specify array index or hash key.
2166     \
2167     }
2168    
2169     @IntMethod:
2170     @@Name:newObject
2171     @@ManakaiDOM:isStatic:1
2172     @@Description:
2173     @@@lang:en
2174     @@@@:
2175     Creates a new instance object for
2176     <Class::ManakaiPerlVariable>.
2177     @@Return:
2178     @@@Type:
2179     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2180     @@@Description:
2181     @@@@lang:en
2182     @@@@@:
2183     The newly created node object.
2184     @@@PerlDef:
2185     @@@@@:
2186     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2187     ::ManakaiDOM:Perl.new>;
2188     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2189     $node->{<Q::pc:variableType>} = '';
2190     $node->{<Q::pc:nodeType>} = 'variable';
2191     @@@@ImplNote:
2192     @@@@@lang:en
2193     @@@@@@:
2194     Properties: <Q::pc:nodeType>, <Q::pc:variableType>,
2195     <Q::packageName>, <Q::localName> (required),
2196 wakaba 1.9 <Q::variableScope>, <Q::hashKey>.
2197    
2198     @IntCloneMethod:
2199     @@Return:
2200     @@@Type:
2201     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2202     @@@PerlDef:
2203     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2204     ::ManakaiDOM:Perl.new>;
2205     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2206     for my $prop (<Q::pc:variableType>, <Q::packageName>,
2207     <Q::localName>, <Q::variableScope>, <Q::hashKey>) {
2208     $node->{$prop} = $nodeObject->{$prop};
2209     }
2210     $node->{<Q::pc:nodeType>} = 'variable';
2211 wakaba 1.6
2212     @Attr:
2213     @@Name: variableType
2214     @@enDesc:
2215     Perl variable type (<CODE::$>, <CODE::@>, <CODE::%>,
2216     <CODE::&> or empty string).
2217     @@Type:
2218     lang:Perl::ManakaiDOM:all
2219     @@Get:
2220     @@@disDef:
2221     @@@@GetProp: variableType
2222     @@Set:
2223     @@@disDef:
2224     @@@@SetProp: variableType
2225    
2226     @Attr:
2227     @@Name: packageName
2228     @@enDesc:
2229     The name of the package to which this variable belongs.
2230     @@Type:
2231     Perl:package-name::ManakaiDOM:all
2232     @@Get:
2233     @@@nullCase:
2234     @@@@enDesc:
2235     This package belongs to the current package or
2236     does not belong to any package.
2237     @@@disDef:
2238     @@@@GetProp: packageName
2239     @@Set:
2240     @@@nullCase:
2241     @@@@enDesc:
2242     This package belongs to the current package or
2243     does not belong to any package.
2244     @@@disDef:
2245 wakaba 1.11 @@@@SetProp: packageName
2246 wakaba 1.6
2247     @Attr:
2248     @@Name: localName
2249     @@enDesc:
2250     The local variable name.
2251     @@Type:
2252     lang:Perl::ManakaiDOM:all
2253     @@Get:
2254     @@@disDef:
2255     @@@@GetProp: localName
2256     @@Set:
2257     @@@disDef:
2258     @@@@SetProp: localName
2259    
2260     @Attr:
2261     @@Name: variableScope
2262     @@enDesc:
2263     Scope modifier (<CODE::my> or <CODE::our> or <CODE::local>).
2264     @@Type:
2265     lang:Perl::ManakaiDOM:all
2266     @@Get:
2267     @@@nullCase:
2268     @@@@enDesc:
2269     This variable does not have scope modifier.
2270     @@@disDef:
2271     @@@@GetProp: variableScope
2272     @@Set:
2273     @@@nullCase:
2274     @@@@enDesc:
2275     This variable does not have scope modifier.
2276     @@@disDef:
2277     @@@@SetProp: variableScope
2278    
2279     @ToStringMethod:
2280     @@Return:
2281     @@@Type:
2282 wakaba 1.12 DISLang:String::ManakaiDOM:all
2283 wakaba 1.6 @@@enDesc:
2284     Perl code.
2285     @@@PerlDef:
2286     my $node = $self->{<Q::TreeCore:node>};
2287 wakaba 1.11 if ($node->{<Q::pc:variableScope>}) {
2288     $r = $node->{<Q::pc:variableScope>} . ' ';
2289     }
2290     $r .= $node->{<Q::pc:variableType>};
2291 wakaba 1.6 $r .= $node->{<Q::pc:packageName>} . '::'
2292     if defined $node->{<Q::pc:packageName>};
2293     $r .= $node->{<Q::pc:localName>};
2294     if ($node->{<Q::pc:variableType>} eq '$' and
2295     defined $node->{<Q::pc:hashKey>}) {
2296     my $hashKey = $node->{<Q::pc:hashKey>};
2297     $hashKey =~ s/(['\\])/\\$1/g;
2298     $r .= q<{'> . $hashKey . q<'}>;
2299     }
2300    
2301     @Attr:
2302     @@Name: hashKey
2303     @@enDesc:
2304     The key for hash.
2305     \
2306     {NOTE:: Using Perl code for key is not supported in the current
2307     version of the implementation.
2308     \
2309     }
2310     @@Type:
2311     DISLang:String::ManakaiDOM:all
2312     @@Get:
2313     @@@nullCase:
2314     @@@@enDesc:
2315     This variable is not for hash value access.
2316     @@@disDef:
2317     @@@@GetProp: hashKey
2318     @@Set:
2319     @@@nullCase:
2320     @@@@enDesc:
2321     This variable is not for hash value access.
2322     @@@disDef:
2323     @@@@SetProp: hashKey
2324     ##PerlInlineUnparsedCode
2325    
2326     PropDef:
2327     @QName: variableScope
2328     @enDesc:
2329     Variable scope (<CODE::local>, <CODE::my> or <CODE::our>).
2330    
2331     PropDef:
2332     @QName: variableType
2333     @enDesc:
2334     Variable type prefix.
2335    
2336     PropDef:
2337     @QName: hashKey
2338     @enDesc:
2339     Hash key string.
2340    
2341     ClsDef:
2342     @ClsQName: ManakaiPerlAnyContainer
2343     @ClsISA: ManakaiPerlCodeFragment
2344     @enDesc:
2345     A base class implemented by both inline container and
2346     block-level container.
2347    
2348     @Attr:
2349     @@Name: length
2350     @@enDesc:
2351     The number of child code fragments.
2352     @@Type:
2353 wakaba 1.12 DOMMain:unsigned-long::ManakaiDOM:all
2354 wakaba 1.6 @@Get:
2355     @@@PerlDef:
2356     $r = @{$self->{<Q::TreeCore:node>}->{<Q::pc:childNodes>}};
2357    
2358     @Method:
2359     @@Name: appendStringLiteral
2360     @@enDesc:
2361     Appends a Perl string literal (<CODE::q>).
2362     @@Param:
2363     @@@Name: stringArg
2364     @@@Type:
2365     DISLang:String::ManakaiDOM:all
2366     @@@enDesc:
2367     A string.
2368     @@Return:
2369     @@@Type: ManakaiPerlStringLiteral
2370     @@@enDesc:
2371     The newly created Perl string literal object.
2372     @@@PerlDef:
2373     $r = <ClassM::ManakaiPerlStringLiteral.newObject>;
2374     my $node = $self->{<Q::TreeCore:node>};
2375     $r->{<Q::infoset:data>} = $stringArg;
2376     $node-><M::ManakaiDOM:ManakaiDOMNodeObject
2377     ::ManakaiDOM:Perl.importTree> ($r);
2378     push @{$node->{<Q::pc:childNodes>}}, $r;
2379     $r->{<Q::pc:parent>} = $node;
2380     if (defined wantarray) {
2381     __CODE{ManakaiNode:getNewReference::
2382     $object => $r, $ref => $r,
2383     $class =>{<ClassName::ManakaiPerlStringLiteral>},
2384     }__;
2385     }
2386    
2387    
2388     @Method:
2389     @@Name: appendAtom
2390     @@enDesc:
2391     Appends a Perl atomic code fragment.
2392     @@Param:
2393     @@@Name: codeArg
2394     @@@Type:
2395     lang:Perl::ManakaiDOM:all
2396     @@@enDesc:
2397     An atom.
2398     @@Return:
2399     @@@Type: ManakaiPerlAtom
2400     @@@enDesc:
2401     The newly created Perl code object.
2402     @@@PerlDef:
2403     $r = <ClassM::ManakaiPerlAtom.newObject>;
2404     my $node = $self->{<Q::TreeCore:node>};
2405 wakaba 1.7 $r->{<Q::pc:code>} = $codeArg;
2406 wakaba 1.6 $node-><M::ManakaiDOM:ManakaiDOMNodeObject
2407     ::ManakaiDOM:Perl.importTree> ($r);
2408     push @{$node->{<Q::pc:childNodes>}}, $r;
2409     $r->{<Q::pc:parent>} = $node;
2410     if (defined wantarray) {
2411     __CODE{ManakaiNode:getNewReference::
2412     $object => $r, $ref => $r,
2413     $class =>{<ClassName::ManakaiPerlAtom>},
2414     }__;
2415     }
2416    
2417    
2418     @Method:
2419     @@Name: appendBare
2420     @@enDesc:
2421     Appends a Perl bare code fragment.
2422     @@Param:
2423     @@@Name: codeArg
2424     @@@Type:
2425     lang:Perl::ManakaiDOM:all
2426     @@@enDesc:
2427 wakaba 1.7 An bare code.
2428 wakaba 1.6 @@Return:
2429     @@@Type: ManakaiPerlBare
2430     @@@enDesc:
2431     The newly created Perl code object.
2432     @@@PerlDef:
2433     $r = <ClassM::ManakaiPerlBare.newObject>;
2434     my $node = $self->{<Q::TreeCore:node>};
2435 wakaba 1.7 $r->{<Q::pc:code>} = $codeArg;
2436 wakaba 1.6 $node-><M::ManakaiDOM:ManakaiDOMNodeObject
2437     ::ManakaiDOM:Perl.importTree> ($r);
2438     push @{$node->{<Q::pc:childNodes>}}, $r;
2439     $r->{<Q::pc:parent>} = $node;
2440     if (defined wantarray) {
2441     __CODE{ManakaiNode:getNewReference::
2442     $object => $r, $ref => $r,
2443     $class =>{<ClassName::ManakaiPerlBare>},
2444     }__;
2445     }
2446 wakaba 1.11
2447     @Method:
2448     @@Name: appendNewAssignment
2449     @@enDesc:
2450     Appends a newly created <Class::ManakaiPerlAssign> object.
2451     @@Param:
2452     @@@Name: leftArg
2453     @@@Type: ManakaiPerlCodeFragment
2454     @@@enDesc:
2455     A left hand side code fragment object.
2456     @@Param:
2457     @@@Name: rightArg
2458     @@@Type: ManakaiPerlCodeFragment
2459     @@@enDesc:
2460     A right hand side code fragment object.
2461     @@Return:
2462     @@@RaiseException:
2463     @@@@@:BAD_CHILD_ERR
2464     @@@@enDesc:
2465     An attempt is made to append a child
2466     that is not valid type.
2467     @@@RaiseException:
2468     @@@@@:IN_USE_NODE_ERR
2469     @@@@enDesc:
2470     An attempt is made to append a node that is
2471     already used elsewhere.
2472     @@@PerlDef:
2473     for my $arg ([leftArg => $leftArg], [rightArg => $rightArg]) {
2474     if ({
2475     atom => 1, bare => 1, incontainer => 1, assign => true,
2476     inunparsed => 1, variable => 1, string => true,
2477     }->{$arg->[1]->{<Q::TreeCore:node>}->{<Q::pc:nodeType>}}) {
2478     if ($arg->[1]->{<Q::TreeCore:node>}->{<Q::pc:parent>}) {
2479     __EXCEPTION{IN_USE_NODE_ERR::
2480     pc:childNode => {$arg->[1]},
2481     MDOMX:param-name => {$arg->[0]},
2482     }__;
2483     }
2484     } else {
2485     __EXCEPTION{BAD_CHILD_ERR::
2486     pc:parentNode => {$self},
2487     pc:childNode => {$arg->[1]},
2488     MDOMX:param-name => {$arg->[0]},
2489     }__;
2490     }
2491     } # left/right
2492    
2493     my $assign = <ClassM::ManakaiPerlAssignment.newObject>;
2494     $assign->{<Q::pc:left>} = $leftArg->{<Q::TreeCore:node>};
2495     $assign->{<Q::pc:right>} = $rightArg->{<Q::TreeCore:node>};
2496     $leftArg->{<Q::TreeCore:node>}->{<Q::pc:parent>} = $assign;
2497     $rightArg->{<Q::TreeCore:node>}->{<Q::pc:parent>} = $assign;
2498     $self->{<Q::TreeCore:node>}-><M::MNodeObject.importTree> ($assign);
2499     $assign->{<Q::pc:parent>} = $self->{<Q::TreeCore:node>};
2500     push @{$self->{<Q::TreeCore:node>}->{<Q::pc:childNodes>}}, $assign;
2501 wakaba 1.8 ##PerlAnyContainer
2502 wakaba 1.6
2503 wakaba 1.8 ClsDef:
2504     @ClsQName: ManakaiPerlStatement
2505     @ClsISA: ManakaiPerlInlineContainer
2506     @enDesc:
2507     Perl statements.
2508    
2509     @IntMethod:
2510     @@Name:newObject
2511     @@ManakaiDOM:isStatic:1
2512     @@Description:
2513     @@@lang:en
2514     @@@@:
2515     Creates a new instance object for
2516     <Class::ManakaiPerlStatement>.
2517     @@Return:
2518     @@@Type:
2519     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2520     @@@Description:
2521     @@@@lang:en
2522     @@@@@:
2523     The newly created node object.
2524     @@@PerlDef:
2525     @@@@@:
2526     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2527     ::ManakaiDOM:Perl.new>;
2528     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2529 wakaba 1.11 push @{$node->{<Q::TreeCore:subnode>}}, <Q::pc:childNodes>;
2530 wakaba 1.8 $node->{<Q::pc:childNodes>} = [];
2531     $node->{<Q::pc:nodeType>} = 'statement';
2532     @@@@ImplNote:
2533     @@@@@lang:en
2534     @@@@@@:
2535 wakaba 1.9 Properties: <Q::pc:nodeType>, <Q::pc:childNodes>, <Q::pc:parent>.
2536    
2537     @IntCloneMethod:
2538     @@Return:
2539     @@@Type:
2540     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2541     @@@PerlDef:
2542     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2543     ::ManakaiDOM:Perl.new>;
2544     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2545     $node->{<Q::pc:nodeType>} = 'statement';
2546 wakaba 1.11 push @{$node->{<Q::TreeCore:subnode>}}, <Q::pc:childNodes>;
2547 wakaba 1.9 $node->{<Q::pc:childNodes>} = [];
2548     for my $cno (@{$nodeObject->{<Q::pc:childNodes>}}) {
2549     my $pack;
2550     my $nt = $cno->{<Q::pc:nodeType>};
2551     __CODE{pc:nodeTypeToPackageName::
2552     $nodeType => $nt, $packageName => $pack, $object => $cno}__;
2553     ## NOTE: Method name written directly
2554     my $cno_clone = $pack->_make_clone_object;
2555     push @{$node->{<Q::pc:childNodes>}}, $cno_clone;
2556     $cno_clone->{<Q::pc:parent>} = $node;
2557     ## NOTE: Tree ID is not updated yet.
2558     }
2559 wakaba 1.8
2560     @ToStringMethod:
2561     @@Return:
2562     @@@Type:
2563 wakaba 1.12 DISLang:String::ManakaiDOM:all
2564 wakaba 1.8 @@@enDesc:
2565     Perl code.
2566     @@@PerlDef:
2567     $r = $self->SUPER::stringify;
2568     $r .= ';' if length $r;
2569     ##PerlStatement
2570 wakaba 1.6
2571     ClsDef:
2572     @ClsQName: ManakaiPerlInlineContainer
2573     @ClsISA: ManakaiPerlAnyContainer
2574     @enDesc:
2575     Unparsed Perl inline code block.
2576    
2577     @IntMethod:
2578     @@Name:newObject
2579     @@ManakaiDOM:isStatic:1
2580     @@Description:
2581     @@@lang:en
2582     @@@@:
2583     Creates a new instance object for
2584     <Class::ManakaiPerlInlineContainer>.
2585     @@Return:
2586     @@@Type:
2587     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2588     @@@Description:
2589     @@@@lang:en
2590     @@@@@:
2591     The newly created node object.
2592     @@@PerlDef:
2593     @@@@@:
2594     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2595     ::ManakaiDOM:Perl.new>;
2596     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2597 wakaba 1.11 push @{$node->{<Q::TreeCore:subnode>}}, <Q::pc:childNodes>;
2598 wakaba 1.6 $node->{<Q::pc:childNodes>} = [];
2599     $node->{<Q::pc:nodeType>} = 'incontainer';
2600     @@@@ImplNote:
2601     @@@@@lang:en
2602     @@@@@@:
2603 wakaba 1.9 Properties: <Q::pc:nodeType>, <Q::pc:childNodes>,
2604     <Q::pc:parent>.
2605    
2606     @IntCloneMethod:
2607     @@Return:
2608     @@@Type:
2609     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2610     @@@PerlDef:
2611     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2612     ::ManakaiDOM:Perl.new>;
2613     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2614 wakaba 1.11 push @{$node->{<Q::TreeCore:subnode>}}, <Q::pc:childNodes>;
2615 wakaba 1.9 $node->{<Q::pc:nodeType>} = 'incontainer';
2616     $node->{<Q::pc:childNodes>} = [];
2617     for my $cno (@{$nodeObject->{<Q::pc:childNodes>}}) {
2618     my $pack;
2619     my $nt = $cno->{<Q::pc:nodeType>};
2620     __CODE{pc:nodeTypeToPackageName::
2621     $nodeType => $nt, $packageName => $pack, $object => $cno}__;
2622     ## NOTE: Method name written directly
2623     my $cno_clone = $pack->_make_clone_object;
2624     push @{$node->{<Q::pc:childNodes>}}, $cno_clone;
2625     $cno_clone->{<Q::pc:parent>} = $node;
2626     ## NOTE: Tree ID is not updated yet.
2627     }
2628 wakaba 1.6
2629     @Method:
2630     @@Name: appendCodeFragment
2631     @@enDesc:
2632     Appends a <Class::ManakaiPerlCodeFragment> object.
2633     @@Param:
2634     @@@Name: codeArg
2635     @@@Type: ManakaiPerlCodeFragment
2636     @@@enDesc:
2637     A code fragment object.
2638     @@Return:
2639     @@@RaiseException:
2640     @@@@@:BAD_CHILD_ERR
2641     @@@@enDesc:
2642     An attempt is made to append a child
2643     that is not a <Class::ManakaiPerlUnparsedCode>.
2644     @@@RaiseException:
2645     @@@@@:IN_USE_NODE_ERR
2646     @@@@enDesc:
2647     An attempt is made to append a node that is
2648     already used elsewhere.
2649     @@@PerlDef:
2650     if ({
2651 wakaba 1.11 atom => 1, bare => 1, incontainer => 1, assign => true,
2652     inunparsed => 1, variable => 1, string => 1,
2653 wakaba 1.6 }->{$codeArg->{<Q::TreeCore:node>}->{<Q::pc:nodeType>}}) {
2654     if ($codeArg->{<Q::TreeCore:node>}->{<Q::pc:parent>}) {
2655     __EXCEPTION{IN_USE_NODE_ERR::
2656     pc:childNode => {$codeArg},
2657     }__;
2658     }
2659     $self->{<Q::TreeCore:node>}-><M::MNodeObject.importTree>
2660     ($codeArg->{<Q::TreeCore:node>});
2661     push @{$self->{<Q::TreeCore:node>}->{<Q::pc:childNodes>}},
2662     $codeArg->{<Q::TreeCore:node>};
2663     $codeArg->{<Q::TreeCore:node>}->{<Q::pc:parent>}
2664     = $self->{<Q::TreeCore:node>};
2665     } else {
2666     __EXCEPTION{BAD_CHILD_ERR::
2667     pc:parentNode => {$self},
2668     pc:childNode => {$codeArg},
2669     }__;
2670     }
2671    
2672     @Method:
2673     @@Name: appendCode
2674     @@enDesc:
2675     Appends an unparsed Perl code fragment.
2676     @@Param:
2677     @@@Name: codeArg
2678     @@@Type:
2679     lang:Perl::ManakaiDOM:all
2680     @@@enDesc:
2681     An unparsed Perl code fragment.
2682     @@Return:
2683     @@@Type: ManakaiPerlInlineUnparsedCode
2684     @@@enDesc:
2685     The newly created Perl code object.
2686     @@@PerlDef:
2687     $r = <ClassM::ManakaiPerlInlineUnparsedCode.newObject>;
2688     my $node = $self->{<Q::TreeCore:node>};
2689     $r->{<Q::code>} = $codeArg;
2690     $node-><M::ManakaiDOM:ManakaiDOMNodeObject
2691     ::ManakaiDOM:Perl.importTree> ($r);
2692     push @{$node->{<Q::pc:childNodes>}}, $r;
2693     $r->{<Q::pc:parent>} = $node;
2694     if (defined wantarray) {
2695     __CODE{ManakaiNode:getNewReference::
2696     $object => $r, $ref => $r,
2697     $class =>{<ClassName::ManakaiPerlInlineUnparsedCode>},
2698     }__;
2699     }
2700    
2701     @ToStringMethod:
2702     @@Return:
2703     @@@Type:
2704 wakaba 1.12 DISLang:String::ManakaiDOM:all
2705 wakaba 1.6 @@@enDesc:
2706     Perl code.
2707     @@@PerlDef:
2708     for my $cno (@{$self->{<Q::TreeCore:node>}->{<Q::pc:childNodes>}}) {
2709 wakaba 1.7 my $cn = <ClassM::ManakaiPerlCodeFragment.getNodeReference> ($cno);
2710 wakaba 1.6 if ($cno->{<Q::pc:nodeType>} eq 'incontainer' and
2711     \ @{$self->{<Q::TreeCore:node>}->{<Q::pc:childNodes>}} == 1) {
2712     $r .= '(' . $cn->stringify . ')';
2713     } else {
2714     $r .= $cn->stringify;
2715     }
2716     }
2717     ##PerlInlineContainer
2718    
2719 wakaba 1.8 ClsDef:
2720     @ClsQName: ManakaiPerlBlock
2721     @ClsISA: ManakaiPerlStatementContainer
2722     @enDesc:
2723     Perl block-level code block.
2724    
2725     @IntMethod:
2726     @@Name:newObject
2727     @@ManakaiDOM:isStatic:1
2728     @@Description:
2729     @@@lang:en
2730     @@@@:
2731     Creates a new instance object for
2732     <Class::ManakaiPerlBlock>.
2733     @@Return:
2734     @@@Type:
2735     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2736     @@@Description:
2737     @@@@lang:en
2738     @@@@@:
2739     The newly created node object.
2740     @@@PerlDef:
2741     @@@@@:
2742     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2743     ::ManakaiDOM:Perl.new>;
2744     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2745 wakaba 1.11 push @{$node->{<Q::TreeCore:subnode>}}, <Q::pc:childNodes>;
2746 wakaba 1.8 $node->{<Q::pc:childNodes>} = [];
2747     $node->{<Q::pc:nodeType>} = 'block';
2748     @@@@ImplNote:
2749     @@@@@lang:en
2750     @@@@@@:
2751 wakaba 1.9 Properties: <Q::pc:nodeType>, <Q::pc:childNodes>, <Q::pc:label>,
2752 wakaba 1.10 <Q::pc:parent>, <Q::pc:sourceFile>, <Q::pc:sourceLine>,
2753     <Q::pc:currentSoruceFile>, <Q::pc:currentSourceLine>.
2754 wakaba 1.9
2755     @IntCloneMethod:
2756     @@Return:
2757     @@@Type:
2758     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2759     @@@PerlDef:
2760     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2761     ::ManakaiDOM:Perl.new>;
2762     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2763 wakaba 1.11 push @{$node->{<Q::TreeCore:subnode>}}, <Q::pc:childNodes>;
2764 wakaba 1.9 $node->{<Q::pc:nodeType>} = 'block';
2765     $node->{<Q::pc:childNodes>} = [];
2766     for my $cno (@{$nodeObject->{<Q::pc:childNodes>}}) {
2767     my $pack;
2768     my $nt = $cno->{<Q::pc:nodeType>};
2769     __CODE{pc:nodeTypeToPackageName::
2770     $nodeType => $nt, $packageName => $pack, $object => $cno}__;
2771     ## NOTE: Method name written directly
2772     my $cno_clone = $pack->_make_clone_object ($cno);
2773     push @{$node->{<Q::pc:childNodes>}}, $cno_clone;
2774     $cno_clone->{<Q::pc:parent>} = $node;
2775     ## NOTE: Tree ID is not updated yet.
2776     }
2777 wakaba 1.10 for my $prop (<Q::pc:label>, <Q::pc:sourceFile>, <Q::pc:sourceLine>,
2778     <Q::pc:currentSourceFile>, <Q::pc:currentSourceLine>) {
2779     $node->{$prop} = $nodeObject->{$prop};
2780     }
2781 wakaba 1.8
2782     @ToStringMethod:
2783     @@Return:
2784     @@@Type:
2785 wakaba 1.12 DISLang:String::ManakaiDOM:all
2786 wakaba 1.8 @@@enDesc:
2787     Perl code.
2788     @@@PerlDef:
2789 wakaba 1.9 my $node = $self->{<Q::TreeCore:node>};
2790     if (@{$node->{<Q::pc:childNodes>}} == 1 and
2791     $node->{<Q::pc:childNodes>}->[0]->{<Q::pc:nodeType>} eq 'block') {
2792     my $cn;
2793     __CODE{ManakaiNode:getWeakReference::
2794     $object => {$node->{<Q::pc:childNodes>}->[0]},
2795     $ref => $cn,
2796     $class => {<ClassName::ManakaiPerlBlock>}}__;
2797     $r = $cn->stringify;
2798     } else {
2799     for my $cno (@{$node->{<Q::pc:childNodes>}}) {
2800     my $cn = <ClassM::ManakaiPerlCodeFragment.getNodeReference> ($cno);
2801     if ($cno->{<Q::pc:nodeType>} eq 'incontainer' and
2802     \ @{$node->{<Q::pc:childNodes>}} == 1) {
2803     $r .= '(' . $cn->stringify . ')';
2804     } else {
2805     $r .= $cn->stringify;
2806     }
2807 wakaba 1.8 }
2808 wakaba 1.9 __DEEP{
2809     my $file = $self-><AG::ManakaiPerlCodeFragment.fileNode>;
2810     $r = sprintf (qq<\n{\n#line %d "%s (Chunk #%d)"\n>,
2811 wakaba 1.10 $node->{<Q::pc:sourceLine>} || 1,
2812     $node->{<Q::pc:sourceFile>} ||
2813     $file-><AG::ManakaiPerlFile.sourceFile>,
2814 wakaba 1.9 $file-><M::ManakaiPerlFile.getNextChunkNumber>)
2815     . $r
2816     . sprintf (qq<\n#line 1 "%s (Chunk #%d)"\n}\n>,
2817     $file-><AG::ManakaiPerlFile.sourceFile>,
2818     $file-><M::ManakaiPerlFile.getNextChunkNumber>);
2819     }__;
2820 wakaba 1.8 }
2821    
2822     ##PerlBlock
2823    
2824 wakaba 1.9 ClsDef:
2825     @ClsQName: ManakaiPerlBlockContainer
2826     @ClsISA: ManakaiPerlStatementContainer
2827     @enDesc:
2828     Perl block-level code container whose content may or may
2829     not semantically be self-contained.
2830    
2831     @IntMethod:
2832     @@Name:newObject
2833     @@ManakaiDOM:isStatic:1
2834     @@Description:
2835     @@@lang:en
2836     @@@@:
2837     Creates a new instance object for
2838     <Class::ManakaiPerlBlockContainer>.
2839     @@Return:
2840     @@@Type:
2841     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2842     @@@Description:
2843     @@@@lang:en
2844     @@@@@:
2845     The newly created node object.
2846     @@@PerlDef:
2847     @@@@@:
2848     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2849     ::ManakaiDOM:Perl.new>;
2850     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2851 wakaba 1.11 push @{$node->{<Q::TreeCore:subnode>}}, <Q::pc:childNodes>;
2852 wakaba 1.9 $node->{<Q::pc:childNodes>} = [];
2853     $node->{<Q::pc:nodeType>} = 'blockcontainer';
2854     @@@@ImplNote:
2855     @@@@@lang:en
2856     @@@@@@:
2857 wakaba 1.10 Properties: <Q::pc:nodeType>, <Q::pc:childNodes>,
2858     <Q::pc:parent>, <Q::pc:sourceFile>, <Q::pc:sourceLine>,
2859     <Q::pc:currentSourceFile>, <Q::pc:currentSourceLine>.
2860 wakaba 1.9
2861     @IntCloneMethod:
2862     @@Return:
2863     @@@Type:
2864     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2865     @@@PerlDef:
2866     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2867     ::ManakaiDOM:Perl.new>;
2868     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2869 wakaba 1.11 push @{$node->{<Q::TreeCore:subnode>}}, <Q::pc:childNodes>;
2870 wakaba 1.9 $node->{<Q::pc:nodeType>} = 'blockcontainer';
2871     $node->{<Q::pc:childNodes>} = [];
2872     for my $cno (@{$nodeObject->{<Q::pc:childNodes>}}) {
2873     my $pack;
2874     my $nt = $cno->{<Q::pc:nodeType>};
2875     __CODE{pc:nodeTypeToPackageName::
2876     $nodeType => $nt, $packageName => $pack, $object => $cno}__;
2877     ## NOTE: Method name written directly
2878     my $cno_clone = $pack->_make_clone_object ($cno);
2879     push @{$node->{<Q::pc:childNodes>}}, $cno_clone;
2880     $cno_clone->{<Q::pc:parent>} = $node;
2881     ## NOTE: Tree ID is not updated yet.
2882     }
2883 wakaba 1.10 for my $prop (<Q::pc:sourceFile>, <Q::pc:sourceLine>,
2884     <Q::pc:currentSourceFile>, <Q::pc:currentSourceLine>) {
2885     $node->{$prop} = $nodeObject->{$prop};
2886     }
2887 wakaba 1.9
2888     @ToStringMethod:
2889     @@Return:
2890     @@@Type:
2891 wakaba 1.12 DISLang:String::ManakaiDOM:all
2892 wakaba 1.9 @@@enDesc:
2893     Perl code.
2894     @@@PerlDef:
2895     my $node = $self->{<Q::TreeCore:node>};
2896     if (@{$node->{<Q::pc:childNodes>}} == 1 and
2897     {
2898     block => true, blockcontainer => true,
2899     }->{$node->{<Q::pc:childNodes>}->[0]->{<Q::pc:nodeType>}}) {
2900     my $cn;
2901     __CODE{ManakaiNode:getWeakReference::
2902     $object => {$node->{<Q::pc:childNodes>}->[0]},
2903     $ref => $cn,
2904     $class => {<ClassName::ManakaiPerlBlock>}}__;
2905     $r = $cn->stringify;
2906     } else {
2907     for my $cno (@{$node->{<Q::pc:childNodes>}}) {
2908     my $cn = <ClassM::ManakaiPerlCodeFragment.getNodeReference> ($cno);
2909     if ($cno->{<Q::pc:nodeType>} eq 'incontainer' and
2910     \ @{$node->{<Q::pc:childNodes>}} == 1) {
2911     $r .= '(' . $cn->stringify . ')';
2912     } else {
2913     $r .= $cn->stringify;
2914     }
2915     }
2916     __DEEP{
2917     my $file = $self-><AG::ManakaiPerlCodeFragment.fileNode>;
2918     $r = sprintf (qq<\n#line %d "%s (Chunk #%d)"\n>,
2919 wakaba 1.10 $node->{<Q::pc:sourceLine>} || 1,
2920     $node->{<Q::pc:sourceFile>} ||
2921     $file-><AG::ManakaiPerlFile.sourceFile>,
2922 wakaba 1.9 $file-><M::ManakaiPerlFile.getNextChunkNumber>)
2923     . $r
2924     . sprintf (qq<\n#line 1 "%s (Chunk #%d)"\n>,
2925     $file-><AG::ManakaiPerlFile.sourceFile>,
2926     $file-><M::ManakaiPerlFile.getNextChunkNumber>);
2927     }__;
2928     }
2929    
2930     ##PerlBlockContainer
2931    
2932 wakaba 1.11 ClsDef:
2933     @ClsQName: ManakaiPerlAssignment
2934     @ClsISA: ManakaiPerlCodeFragment
2935     @enDesc:
2936     Perl variable assignment.
2937    
2938     @IntMethod:
2939     @@Name:newObject
2940     @@ManakaiDOM:isStatic:1
2941     @@Description:
2942     @@@lang:en
2943     @@@@:
2944     Creates a new instance object for
2945     <Class::ManakaiPerlAssignment>.
2946     @@Return:
2947     @@@Type:
2948     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2949     @@@Description:
2950     @@@@lang:en
2951     @@@@@:
2952     The newly created node object.
2953     @@@PerlDef:
2954     @@@@@:
2955     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2956     ::ManakaiDOM:Perl.new>;
2957     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2958     push @{$node->{<Q::TreeCore:subnode0>}}, <Q::pc:left>, <Q::pc:right>;
2959     $node->{<Q::pc:nodeType>} = 'assign';
2960     @@@@ImplNote:
2961     @@@@@lang:en
2962     @@@@@@:
2963     Properties: <Q::pc:nodeType>, <Q::pc:left>, <Q::pc:right>,
2964     <Q::pc:parent>.
2965    
2966     @IntCloneMethod:
2967     @@Return:
2968     @@@Type:
2969     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
2970     @@@PerlDef:
2971     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
2972     ::ManakaiDOM:Perl.new>;
2973     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
2974     push @{$node->{<Q::TreeCore:subnode0>}}, <Q::pc:left>, <Q::pc:right>;
2975     $node->{<Q::pc:nodeType>} = 'assign';
2976     for my $prop (<Q::pc:left>, <Q::pc:right>) {
2977     my $pack;
2978     my $cno = $nodeObject->{$prop};
2979     my $nt = $cno->{<Q::pc:nodeType>};
2980     __CODE{pc:nodeTypeToPackageName::
2981     $nodeType => $nt, $packageName => $pack, $object => $cno}__;
2982     ## NOTE: Method name written directly
2983     my $cno_clone = $pack->_make_clone_object ($cno);
2984     $node->{$prop} = $cno_clone;
2985     $cno_clone->{<Q::pc:parent>} = $node;
2986     ## NOTE: Tree ID is not updated yet.
2987     }
2988    
2989     @ToStringMethod:
2990     @@Return:
2991     @@@Type:
2992 wakaba 1.12 DISLang:String::ManakaiDOM:all
2993 wakaba 1.11 @@@enDesc:
2994     Perl code.
2995     @@@PerlDef:
2996     my $node = $self->{<Q::TreeCore:node>};
2997     $r = <ClassM::ManakaiPerlCodeFragment.getNodeReference>
2998     ($node->{<Q::pc:left>})->stringify . ' = ' .
2999     <ClassM::ManakaiPerlCodeFragment.getNodeReference>
3000     ($node->{<Q::pc:right>})->stringify;
3001     ##PerlAssignment
3002    
3003 wakaba 1.12 ClsDef:
3004     @ClsQName: ManakaiPerlIf
3005     @ClsISA: ManakaiPerlCodeFragment
3006     @enDesc:
3007     Perl variable assignment.
3008    
3009     @IntMethod:
3010     @@Name:newObject
3011     @@ManakaiDOM:isStatic:1
3012     @@Description:
3013     @@@lang:en
3014     @@@@:
3015     Creates a new instance object for
3016     <Class::ManakaiPerlAssignment>.
3017     @@Return:
3018     @@@Type:
3019     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
3020     @@@Description:
3021     @@@@lang:en
3022     @@@@@:
3023     The newly created node object.
3024     @@@PerlDef:
3025     @@@@@:
3026     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
3027     ::ManakaiDOM:Perl.new>;
3028     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
3029     push @{$node->{<Q::TreeCore:subnode0>}}, <Q::pc:condition>,
3030     <Q::pc:true>, <Q::pc:false>;
3031     $node->{<Q::pc:nodeType>} = 'if';
3032     @@@@ImplNote:
3033     @@@@@lang:en
3034     @@@@@@:
3035     Properties: <Q::pc:nodeType>, <Q::pc:true>, <Q::pc:false>,
3036     <Q::pc:parent>, <Q::pc:condition>.
3037    
3038     @IntCloneMethod:
3039     @@Return:
3040     @@@Type:
3041     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
3042     @@@PerlDef:
3043     my $node = $r = <ClassM::ManakaiDOM:ManakaiDOMNodeObject
3044     ::ManakaiDOM:Perl.new>;
3045     push @{$node->{<Q::TreeCore:origin>}}, <Q::pc:parent>;
3046     push @{$node->{<Q::TreeCore:subnode0>}}, <Q::pc:condition>,
3047     <Q::pc:true>, <Q::pc:false>;
3048     $node->{<Q::pc:nodeType>} = 'if';
3049     for my $prop (<Q::pc:true>, <Q::pc:false>, <Q::pc:condition>) {
3050     my $pack;
3051     my $cno = $nodeObject->{$prop};
3052     next unless $cno;
3053     my $nt = $cno->{<Q::pc:nodeType>};
3054     __CODE{pc:nodeTypeToPackageName::
3055     $nodeType => $nt, $packageName => $pack, $object => $cno}__;
3056     ## NOTE: Method name written directly
3057     my $cno_clone = $pack->_make_clone_object ($cno);
3058     $node->{$prop} = $cno_clone;
3059     $cno_clone->{<Q::pc:parent>} = $node;
3060     ## NOTE: Tree ID is not updated yet.
3061     }
3062    
3063     @ToStringMethod:
3064     @@Return:
3065     @@@Type:
3066     DISLang:String::ManakaiDOM:all
3067     @@@enDesc:
3068     Perl code.
3069     @@@PerlDef:
3070     my $node = $self->{<Q::TreeCore:node>};
3071     $r = <ClassM::ManakaiPerlCodeFragment.getNodeReference>
3072     ($node->{<Q::pc:condition>})->stringify;
3073     my $true_code = <ClassM::ManakaiPerlCodeFragment.getNodeReference>
3074     ($node->{<Q::pc:true>})->stringify if $node->{<Q::pc:true>};
3075     my $false_code = <ClassM::ManakaiPerlCodeFragment.getNodeReference>
3076     ($node->{<Q::pc:false>})->stringify if $node->{<Q::pc:false>};
3077     if (defined $true_code) {
3078     if (defined $false_code) {
3079     $r = q<if (> . $r . q<) {> . $true_code .
3080     q<} else {> . $false_code . q<}>;
3081     } else {
3082     $r = q<if (> . $r . q<) {> . $true_code . q<}>;
3083     }
3084     } else {
3085     $r = q<unless (> . $r . q<) {> . $false_code . q<}>;
3086     }
3087     ##PerlIf
3088    
3089     PropDef:
3090     @QName:condition
3091     @enDesc:
3092     Condition.
3093     PropDef:
3094     @QName:true
3095     @enDesc:
3096     If true.
3097     PropDef:
3098     @QName:false
3099     @enDesc:
3100     If false.
3101    
3102 wakaba 1.11 PropDef:
3103     @QName:left
3104     @FullName:
3105     @@lang:en
3106     @@@: Left hand side
3107     PropDef:
3108     @QName:right
3109     @FullName:
3110     @@lang:en
3111     @@@: Right hand side
3112    
3113 wakaba 1.8 PropDef:
3114     @QName:label
3115     @enDesc:
3116     Perl statement / block label.
3117    
3118 wakaba 1.6 ElementTypeBinding:
3119     @Name: RaiseException
3120     @ElementType:
3121     ManakaiDOM:raises
3122    
3123     ClsDef:
3124     @ClsQName: ManakaiPerlCodeImplementation
3125 wakaba 1.1 @enDesc:
3126     The class that provides factory methods.
3127    
3128     @Role:
3129     @@@:
3130     DOMCore:DOMImplementation::ManakaiDOM:ManakaiDOM
3131     @@compat:
3132     DOMCore:ManakaiDOMImplementation::ManakaiDOM:ManakaiDOMLatest
3133    
3134     @Method:
3135     @@Name: createPerlFile
3136     @@enDesc:
3137     Creates a Perl code file.
3138     @@Return:
3139     @@@Type: ManakaiPerlFile
3140     @@@enDesc: A newly created Perl source file object.
3141     @@@PerlDef:
3142     $r = <ClassM::ManakaiPerlFile.newObject>;
3143 wakaba 1.6 __CODE{ManakaiNode:getNewReference::
3144     $object => $r, $ref => $r,
3145     $class => {<ClassName::ManakaiPerlFile>}}__;
3146 wakaba 1.1
3147 wakaba 1.13 @Method:
3148     @@Name: createPerlPackage
3149     @@enDesc:
3150     Creates a new package scope block.
3151     @@Param:
3152     @@@Name: packageName
3153     @@@Type:
3154     Perl:package-name::ManakaiDOM:all
3155     @@@enDesc:
3156     The fully-qualified name of the package to create.
3157     @@Return:
3158     @@@Type: ManakaiPerlPackageScope
3159     @@@enDesc:
3160     The newly created package scope object.
3161     @@@PerlDef:
3162     $r = <ClassM::ManakaiPerlPackageScope.newObject>;
3163     $r->{<Q::pc:packageName>} = $packageName;
3164     __CODE{ManakaiNode:getNewReference::
3165     $object => $r, $ref => $r,
3166     $class => {<ClassName::ManakaiPerlPackageScope>}}__;
3167    
3168 wakaba 1.1 @IntMethod:
3169     @@Name: perlComment
3170     @@ManakaiDOM:isStatic:1
3171     @@enDesc:
3172     Generates a Perl comment string.
3173     @@Param:
3174     @@@Name: str
3175     @@@Type:
3176 wakaba 1.12 DISLang:String::ManakaiDOM:all
3177 wakaba 1.1 @@@enDesc:
3178     A comment text.
3179     @@Return:
3180     @@@Type:
3181 wakaba 1.12 DISLang:String::ManakaiDOM:all
3182 wakaba 1.1 @@@enDesc:
3183     A Perl comment string.
3184     @@@PerlDef:
3185     $r = $str;
3186     $r =~ s/\n/\n## /g;
3187     $r =~ s/\n## $/\n/s;
3188     $r .= "\n" unless $r =~ /\n$/;
3189     $r = q<## > . $r;
3190    
3191     @IntMethod:
3192     @@Name: rfc3339DateTime
3193     @@ManakaiDOM:isStatic:1
3194     @@enDesc:
3195     Returns RFC 3339 <CODE::date-time> representation of a date.
3196     @@Param:
3197     @@@Name: perlDate
3198     @@@Type:
3199 wakaba 1.12 DOMMain:unsigned-long::ManakaiDOM:all
3200 wakaba 1.1 @@@enDesc:
3201     A Perl representation of date.
3202     @@Return:
3203     @@@Type:
3204 wakaba 1.12 DISLang:String::ManakaiDOM:all
3205 wakaba 1.1 @@@enDesc:
3206     RFC 3339 date string.
3207     @@@PerlDef:
3208     my @time = gmtime $perlDate;
3209     $r = sprintf q<%04d-%02d-%02dT%02d:%02d:%02d+00:00>,
3210     $time[5] + 1900, $time[4] + 1, @time[3,2,1,0];
3211    
3212     @IntMethod:
3213     @@Name: versionDateTime
3214     @@ManakaiDOM:isStatic:1
3215     @@enDesc:
3216     Returns date for version.
3217     @@Param:
3218     @@@Name: perlDate
3219     @@@Type:
3220 wakaba 1.12 DOMMain:unsigned-long::ManakaiDOM:all
3221 wakaba 1.1 @@@enDesc:
3222     A Perl representation of date.
3223     @@Return:
3224     @@@Type:
3225 wakaba 1.12 DISLang:String::ManakaiDOM:all
3226 wakaba 1.1 @@@enDesc:
3227     A Perl number literal.
3228     @@@PerlDef:
3229     my @time = gmtime $perlDate;
3230     $r = sprintf q<%04d%02d%02d.%02d%02d>,
3231     $time[5] + 1900, $time[4] + 1, @time[3,2,1];
3232    
3233     @Method:
3234     @@Name: perlLiteral
3235     @@enDesc:
3236     Perl code representation.
3237     @@Param:
3238     @@@Name: val
3239     @@@Type:
3240 wakaba 1.12 DOMMain:any::ManakaiDOM:all
3241 wakaba 1.1 @@@enDesc:
3242     A Perl value.
3243     @@Return:
3244     @@@Type:
3245 wakaba 1.12 DISLang:String::ManakaiDOM:all
3246 wakaba 1.1 @@@enDesc:
3247     A Perl lexical representation of <P::val>.
3248     @@@PerlDef:
3249     unless (defined $val) {
3250     $r = q<undef>;
3251     } elsif (ref $val eq 'ARRAY') {
3252     __DEEP{
3253     $r = q<[> . <ClassM::ManakaiPerlCodeImplementation
3254     .perlLiteral> ($val) . q<]>;
3255     }__;
3256     } elsif (ref $val eq 'HASH') {
3257     __DEEP{
3258     $r = q<{> . <ClassM::ManakaiPerlCodeImplementation
3259     .perlLiteral> ([%$val]) . q<}>;
3260     }__;
3261     } else {
3262     $val =~ s/(['\\])/\\$1/g;
3263     $r = q<'> . $val . q<'>;
3264     }
3265    
3266     @Method:
3267     @@Name: perlList
3268     @@enDesc:
3269     Perl code representation of a list.
3270     @@Param:
3271     @@@Name: val
3272     @@@Type:
3273 wakaba 1.12 Perl:ARRAY::ManakaiDOM:all
3274 wakaba 1.1 @@@enDesc:
3275     A Perl array reference.
3276     @@Return:
3277     @@@Type:
3278 wakaba 1.12 DISLang:String::ManakaiDOM:all
3279 wakaba 1.1 @@@enDesc:
3280     A Perl lexical representation of <CODE::@$val>.
3281     @@@PerlDef:
3282     __DEEP{
3283     $r = join (q<, >, map {<ClassM::ManakaiPerlCodeImplementation
3284     .perlLiteral> ($_)} @{$val});
3285     }__;
3286 wakaba 1.5
3287     @Method:
3288     @@Name: createPerlSub
3289     @@enDesc:
3290     Creates a new <Class::ManakaiPerlSub> object.
3291     @@Param:
3292     @@@Name: subName
3293     @@@Type:
3294 wakaba 1.12 DISLang:String::ManakaiDOM:all
3295 wakaba 1.5 @@@enDesc:
3296     The name of the subroutine to create.
3297     @@@nullCase:
3298     @@@@enDesc:
3299     The subroutine created has no name.
3300     @@Return:
3301     @@@Type:ManakaiPerlSub
3302     @@@enDesc:
3303     Newly created Perl subroutine object.
3304     @@@PerlDef:
3305     __DEEP{
3306 wakaba 1.6 $r = <ClassM::ManakaiPerlSub.newObject>;
3307     __CODE{ManakaiNode:getNewReference::
3308     $object => $r, $ref => $r,
3309     $class => {<ClassName::ManakaiPerlSub>}}__;
3310     $r-><AS::ManakaiPerlSub.localName> ($subName) if defined $subName;
3311 wakaba 1.5 }__;
3312    
3313     @Method:
3314     @@Name: createPerlUnparsedCode
3315     @@enDesc:
3316     Creates a new <Class::ManakaiPerlUnparsedCode> object.
3317     @@Param:
3318     @@@Name: codeArg
3319     @@@Type:
3320     lang:Perl::ManakaiDOM:all
3321     @@@enDesc:
3322     The code fragment.
3323     @@@nullCase:
3324     @@@@enDesc:
3325     The fragment initially has no code.
3326     @@Return:
3327     @@@Type:ManakaiPerlUnparsedCode
3328     @@@enDesc:
3329     Newly created Perl code object.
3330     @@@PerlDef:
3331     __DEEP{
3332 wakaba 1.6 $r = <ClassM::ManakaiPerlUnparsedCode.newObject>;
3333     __CODE{ManakaiNode:getNewReference::
3334     $object => $r, $ref => $r,
3335     $class => {<ClassName::ManakaiPerlUnparsedCode>}}__;
3336 wakaba 1.7 $r-><AS::ManakaiPerlUnparsedCode.code> ($codeArg) if defined $codeArg;
3337 wakaba 1.6 }__;
3338    
3339     @Method:
3340     @@Name: createPerlInlineContainer
3341     @@enDesc:
3342     Creates a new <Class::ManakaiPerlInlineContainer> object.
3343     @@Return:
3344     @@@Type:ManakaiPerlInlineContainer
3345     @@@enDesc:
3346     Newly created Perl code object.
3347     @@@PerlDef:
3348     __DEEP{
3349     $r = <ClassM::ManakaiPerlInlineContainer.newObject>;
3350     __CODE{ManakaiNode:getNewReference::
3351     $object => $r, $ref => $r,
3352     $class => {<ClassName::ManakaiPerlInlineContainer>}}__;
3353     }__;
3354    
3355     @Method:
3356     @@Name: createPerlInlineUnparsedCode
3357     @@enDesc:
3358     Creates a new <Class::ManakaiPerlInlineUnparsedCode> object.
3359     @@Param:
3360     @@@Name: codeArg
3361     @@@Type:
3362     lang:Perl::ManakaiDOM:all
3363     @@@enDesc:
3364     The code fragment.
3365     @@@nullCase:
3366     @@@@enDesc:
3367     The fragment initially has no code.
3368     @@Return:
3369     @@@Type:ManakaiPerlInlineUnparsedCode
3370     @@@enDesc:
3371     Newly created Perl code object.
3372     @@@PerlDef:
3373     __DEEP{
3374     $r = <ClassM::ManakaiPerlInlineUnparsedCode.newObject>;
3375     __CODE{ManakaiNode:getNewReference::
3376     $object => $r, $ref => $r,
3377     $class => {<ClassName::ManakaiPerlInlineUnparsedCode>}}__;
3378 wakaba 1.7 $r-><AS::ManakaiPerlInlineUnparsedCode.code> ($codeArg)
3379 wakaba 1.6 if defined $codeArg;
3380     }__;
3381    
3382     @Method:
3383     @@Name: createPerlBare
3384     @@enDesc:
3385     Creates a new <Class::ManakaiPerlBare> object.
3386     @@Param:
3387     @@@Name: codeArg
3388     @@@Type:
3389     lang:Perl::ManakaiDOM:all
3390     @@@enDesc:
3391     The code fragment.
3392     @@Return:
3393     @@@Type:ManakaiPerlBare
3394     @@@enDesc:
3395     Newly created Perl code object.
3396     @@@PerlDef:
3397     __DEEP{
3398     $r = <ClassM::ManakaiPerlBare.newObject>;
3399     __CODE{ManakaiNode:getNewReference::
3400     $object => $r, $ref => $r,
3401     $class => {<ClassName::ManakaiPerlBare>}}__;
3402 wakaba 1.7 $r-><AS::ManakaiPerlBare.code> ($codeArg);
3403 wakaba 1.6 }__;
3404    
3405     @Method:
3406     @@Name: createPerlAtom
3407     @@enDesc:
3408     Creates a new <Class::ManakaiPerlAtom> object.
3409     @@Param:
3410     @@@Name: codeArg
3411     @@@Type:
3412     lang:Perl::ManakaiDOM:all
3413     @@@enDesc:
3414     The code fragment.
3415     @@Return:
3416     @@@Type:ManakaiPerlAtom
3417     @@@enDesc:
3418     Newly created Perl code object.
3419     @@@PerlDef:
3420     __DEEP{
3421     $r = <ClassM::ManakaiPerlAtom.newObject>;
3422     __CODE{ManakaiNode:getNewReference::
3423     $object => $r, $ref => $r,
3424     $class => {<ClassName::ManakaiPerlAtom>}}__;
3425 wakaba 1.7 $r-><AS::ManakaiPerlBare.code> ($codeArg);
3426 wakaba 1.6 }__;
3427    
3428     @Method:
3429     @@Name: createPerlStringLiteral
3430     @@enDesc:
3431     Creates a new <Class::ManakaiPerlStringLiteral> object.
3432     @@Param:
3433     @@@Name: stringArg
3434     @@@Type:
3435     DISLang:String::ManakaiDOM:all
3436     @@@enDesc: A string.
3437     @@Return:
3438     @@@Type:ManakaiPerlStringLiteral
3439     @@@enDesc:
3440     Newly created Perl code object.
3441     @@@PerlDef:
3442     __DEEP{
3443     $r = <ClassM::ManakaiPerlStringLiteral.newObject>;
3444     __CODE{ManakaiNode:getNewReference::
3445     $object => $r, $ref => $r,
3446     $class => {<ClassName::ManakaiPerlStringLiteral>}}__;
3447 wakaba 1.7 $r-><AS::ManakaiPerlStringLiteral.data> ($stringArg);
3448 wakaba 1.6 }__;
3449    
3450     @Method:
3451     @@Name: createPerlVariable
3452     @@enDesc:
3453     Creates a new <Class::ManakaiPerlVariable> object.
3454     @@Param:
3455     @@@Name: variableType
3456     @@@Type:
3457     DISLang:String::ManakaiDOM:all
3458     @@@enDesc:
3459     Variable prefix.
3460     @@Param:
3461     @@@Name: packageName
3462     @@@Type:
3463     Perl:package-name::ManakaiDOM:all
3464     @@@enDesc:
3465     Package name.
3466     @@@nullCase:
3467     @@@@enDesc:
3468     The variable belongs to the current package or a
3469     lexical-scoped variable.
3470     @@Param:
3471     @@@Name: localName
3472     @@@Type:
3473     DISLang:String::ManakaiDOM:all
3474     @@@enDesc:
3475     Variable name.
3476     @@Return:
3477     @@@Type:ManakaiPerlVariable
3478     @@@enDesc:
3479     Newly created Perl variable object.
3480     @@@PerlDef:
3481     __DEEP{
3482     $r = <ClassM::ManakaiPerlVariable.newObject>;
3483     __CODE{ManakaiNode:getNewReference::
3484     $object => $r, $ref => $r,
3485     $class => {<ClassName::ManakaiPerlVariable>}}__;
3486 wakaba 1.7 $r-><AS::ManakaiPerlVariable.variableType> ($variableType);
3487     $r-><AS::ManakaiPerlVariable.packageName> ($packageName);
3488     $r-><AS::ManakaiPerlVariable.localName> ($localName);
3489 wakaba 1.8 }__;
3490    
3491     @Method:
3492     @@Name: createPerlBlock
3493     @@enDesc:
3494     Creates a new <Class::ManakaiPerlBlock> object.
3495     @@Return:
3496     @@@Type:ManakaiPerlBlock
3497     @@@enDesc:
3498     Newly created Perl code object.
3499     @@@PerlDef:
3500     __DEEP{
3501     $r = <ClassM::ManakaiPerlBlock.newObject>;
3502     __CODE{ManakaiNode:getNewReference::
3503     $object => $r, $ref => $r,
3504     $class => {<ClassName::ManakaiPerlBlock>}}__;
3505 wakaba 1.5 }__;
3506 wakaba 1.9
3507     @Method:
3508     @@Name: createPerlBlockContainer
3509     @@enDesc:
3510     Creates a new <Class::ManakaiPerlBlockContainer> object.
3511     @@Return:
3512     @@@Type:ManakaiPerlBlockContainer
3513     @@@enDesc:
3514     Newly created Perl code object.
3515     @@@PerlDef:
3516     __DEEP{
3517     $r = <ClassM::ManakaiPerlBlockContainer.newObject>;
3518     __CODE{ManakaiNode:getNewReference::
3519     $object => $r, $ref => $r,
3520     $class => {<ClassName::ManakaiPerlBlockContainer>}}__;
3521     }__;
3522 wakaba 1.11
3523     @Method:
3524     @@Name: createPerlStatement
3525     @@enDesc:
3526     Creates a new Perl statement.
3527     @@Param:
3528     @@@Name: codeArg
3529     @@@Type:
3530     lang:Perl::ManakaiDOM:all
3531     @@@enDesc:
3532     A Perl statement without terminating <Perl::;>.
3533     @@@nullCase:
3534     @@@@enDesc:
3535     No initial content.
3536     @@Return:
3537     @@@Type: ManakaiPerlStatement
3538     @@@enDesc:
3539     The newly created Perl code object.
3540     @@@PerlDef:
3541     $r = <ClassM::ManakaiPerlStatement.newObject>;
3542     __CODE{ManakaiNode:getNewReference::
3543     $object => $r, $ref => $r,
3544     $class =>{<ClassName::ManakaiPerlStatement>},
3545     }__;
3546     if (defined $codeArg) {
3547     __DEEP{
3548     $r-><M::ManakaiPerlAnyContainer.appendBare> ($codeArg);
3549     }__;
3550     }
3551 wakaba 1.12
3552     @Method:
3553     @@Name: createPerlIf
3554     @@enDesc:
3555     Creates a <Class::ManakaiPerlIf> object.
3556     @@Param:
3557     @@@Name: conditionArg
3558     @@@Type: ManakaiPerlCodeFragment
3559     @@@enDesc:
3560     Conditoon code fragment object.
3561     @@Param:
3562     @@@Name: trueArg
3563     @@@Type: ManakaiPerlCodeFragment
3564     @@@enDesc:
3565     A true code fragment object.
3566     @@@nullCase:
3567     @@@@enDesc: No true code.
3568     @@Param:
3569     @@@Name: falseArg
3570     @@@Type: ManakaiPerlCodeFragment
3571     @@@enDesc:
3572     A false code fragment object.
3573     @@@nullCase:
3574     @@@@enDesc: No false code.
3575     @@Return:
3576     @@@RaiseException:
3577     @@@@@:BAD_CHILD_ERR
3578     @@@@enDesc:
3579     An attempt is made to append a child
3580     that is not valid type.
3581     @@@RaiseException:
3582     @@@@@:IN_USE_NODE_ERR
3583     @@@@enDesc:
3584     An attempt is made to append a node that is
3585     already used elsewhere.
3586     @@@PerlDef:
3587     for my $arg ([conditionArg => $conditionArg]) {
3588     if ({
3589     atom => 1, bare => 1, incontainer => 1, assign => true,
3590     inunparsed => 1, variable => 1, string => true,
3591     }->{$arg->[1]->{<Q::TreeCore:node>}->{<Q::pc:nodeType>}}) {
3592     if ($arg->[1]->{<Q::TreeCore:node>}->{<Q::pc:parent>}) {
3593     __EXCEPTION{IN_USE_NODE_ERR::
3594     pc:childNode => {$arg->[1]},
3595     MDOMX:param-name => {$arg->[0]},
3596     }__;
3597     }
3598     } else {
3599     __EXCEPTION{BAD_CHILD_ERR::
3600     pc:parentNode => {$self},
3601     pc:childNode => {$arg->[1]},
3602     MDOMX:param-name => {$arg->[0]},
3603     }__;
3604     }
3605     } # c
3606    
3607     for my $arg ([trueArg => $trueArg],
3608     [falseArg => $falseArg]) {
3609     next unless $arg->[1];
3610     if ({
3611     blockcontainer => true,
3612     }->{$arg->[1]->{<Q::TreeCore:node>}->{<Q::pc:nodeType>}}) {
3613     if ($arg->[1]->{<Q::TreeCore:node>}->{<Q::pc:parent>}) {
3614     __EXCEPTION{IN_USE_NODE_ERR::
3615     pc:childNode => {$arg->[1]},
3616     MDOMX:param-name => {$arg->[0]},
3617     }__;
3618     }
3619     } else {
3620     __EXCEPTION{BAD_CHILD_ERR::
3621     pc:parentNode => {$self},
3622     pc:childNode => {$arg->[1]},
3623     MDOMX:param-name => {$arg->[0]},
3624     }__;
3625     }
3626     } # t/f
3627    
3628     my $assign = <ClassM::ManakaiPerlIf.newObject>;
3629     $assign->{<Q::pc:condition>} = $conditionArg->{<Q::TreeCore:node>};
3630     $assign->{<Q::pc:true>} = $trueArg->{<Q::TreeCore:node>} if $trueArg;
3631     $assign->{<Q::pc:false>} = $falseArg->{<Q::TreeCore:node>} if $falseArg;
3632     $assign->{<Q::TreeCore:node>}-><M::MNodeObject.importTree> ($_)
3633     for (grep {$_}
3634     $assign->{<Q::pc:condition>}, $assign->{<Q::pc:true>},
3635     $assign->{<Q::pc:false>});
3636     $conditionArg->{<Q::TreeCore:node>}->{<Q::pc:parent>} = $assign;
3637     $trueArg->{<Q::TreeCore:node>}->{<Q::pc:parent>} = $assign if $trueArg;
3638     $falseArg->{<Q::TreeCore:node>}->{<Q::pc:parent>} = $assign if $falseArg;
3639 wakaba 1.1 ##PerlCodeImplementation
3640    
3641 wakaba 1.5 ResourceDef:
3642     @QName: MNodeObject
3643     @rdf:type:
3644     ManakaiDOM:Class
3645     @AliasFor:
3646     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
3647    
3648 wakaba 1.1 PropDef:
3649     @QName: code
3650     @enDesc: Perl code.
3651    
3652     PropDef:
3653     @QName: sourceFile
3654     @enDesc:
3655     Source file.
3656    
3657     PropDef:
3658     @QName: sourceLine
3659     @enDesc:
3660     Source line number.
3661 wakaba 1.10
3662     PropDef:
3663     @QName: currentSourceFile
3664     @enDesc:
3665     <QUOTE::Current> source file.
3666    
3667     PropDef:
3668     @QName: currentSourceLine
3669     @enDesc:
3670     <QUOTE::Current> source line number.
3671 wakaba 1.1
3672     PropDef:
3673     @QName: prototype
3674     @enDesc:
3675     Prototype of subroutine.
3676    
3677     PropDef:
3678     @QName: parent
3679     @enDesc:
3680     Higher-level object.
3681    
3682     PropDef:
3683     @QName: sub
3684     @enDesc:
3685     Perl subroutines.
3686    
3687     PropDef:
3688     @QName: packageName
3689     @Type:
3690 wakaba 1.12 Perl:package-name::ManakaiDOM:all
3691 wakaba 1.1 @enDesc:
3692     The fully qualified names of packages.
3693    
3694     PropDef:
3695     @QName: childNodes
3696     @enDesc:
3697     Child code fragments.
3698    
3699     PropDef:
3700     @QName: localName
3701     @enDesc:
3702     Scoped names.
3703 wakaba 1.4
3704     ## -- Exceptions
3705    
3706     ExceptionDef:
3707     @ClsQName: ManakaiPerlCodeException
3708     @enDesc:
3709     Exceptions for the <Module::PerlCode> module.
3710     @ClsISA:
3711     ManakaiDOM:ManakaiDOMException::ManakaiDOM:Perl
3712     @XConstGroupDef:
3713     @@ClsQName: ManakaiPerlCodeExceptionCode
3714     @@enDesc:
3715     Exception codes for <Class::ManakaiPerlCodeException>.
3716 wakaba 1.5 @@XConstDef:
3717     @@@Name: HIERARCHY_REQUEST_ERR
3718     @@@Value:3
3719     @@@enDesc:
3720     An attempt is made to break the hierarchy.
3721     @@@XSubTypeDef:
3722     @@@@QName: BAD_CHILD_ERR
3723     @@@@enDesc:
3724     An attempt is made to append a node as a child whose type
3725     is not allowed.
3726     @@@@XParam:
3727     @@@@@QName: childNode
3728     @@@@@enDesc:
3729     The node attempted to append.
3730     @@@@XParam:
3731     @@@@@QName: parentNode
3732     @@@@@enDesc:
3733     The node to whose child list an attempt to append is made.
3734     @@@XSubTypeDef:
3735     @@@@QName: IN_USE_NODE_ERR
3736     @@@@enDesc:
3737     An attempt is made to append a node that has already been used
3738     elsewhere.
3739     @@@@XParam:
3740     @@@@@QName: childNode
3741     @@@@@enDesc:
3742     The node attempted to append.
3743     @@@@XParam:
3744     @@@@@QName: parentNode
3745     @@@@@enDesc:
3746     The parent node of the <XP::childNode>.
3747 wakaba 1.4 @@XConstDef:
3748     @@@Name: NOT_SUPPORTED_ERR
3749     @@@Value:9
3750     @@@enDesc:
3751     An attempt is made to do something the implementation does not support.
3752     @@@XSubTypeDef:
3753     @@@@QName: UNSUPPORTED_OPERATOR_ERR
3754     @@@@enDesc:
3755     The implementation does not support the specified operator.
3756     @@@@XParam:
3757     @@@@@QName: operator
3758     @@@@@enDesc:
3759     The operator that is not supported.
3760     @@@@enMufDef:
3761     Operator "%p (name => {<Q::pc:operator>});" is not supported
3762    
3763     ElementTypeBinding:
3764     @Name: ExceptionDef
3765     @ElementType:
3766     dis:ResourceDef
3767     @ShadowContent:
3768     @@rdf:type:
3769     ManakaiDOM:ExceptionClass
3770     @@AliasFor:
3771     @@@@:
3772     ::ManakaiDOM:Perl
3773     @@@For:
3774     !=ManakaiDOM:Perl
3775     @@ForCheck:
3776     ManakaiDOM:Perl
3777     @@DOMMain:implementFeature: CoreFeature10
3778    
3779     ElementTypeBinding:
3780     @Name: XConstGroupDef
3781     @ElementType:
3782     dis:ResourceDef
3783     @ShadowContent:
3784     @@rdf:type:
3785     ManakaiDOM:ConstGroup
3786     @@Type:
3787     DOMMain:unsigned-short::ManakaiDOM:all
3788     @@rdfs:subClassOf:
3789     DOMMain:unsigned-short::ManakaiDOM:all
3790    
3791     ElementTypeBinding:
3792     @Name: XConstDef
3793     @ElementType:
3794     dis:ResourceDef
3795     @ShadowContent:
3796     @@rdf:type:
3797     ManakaiDOM:Const
3798    
3799     ElementTypeBinding:
3800     @Name: XSubTypeDef
3801     @ElementType:
3802     dis:ResourceDef
3803     @ShadowContent:
3804     @@rdf:type:
3805     ManakaiDOM:ExceptionOrWarningSubType
3806    
3807     ElementTypeBinding:
3808     @Name: XParam
3809     @ElementType:
3810     ManakaiDOM:exceptionOrWarningParameter
3811    
3812     ElementTypeBinding:
3813     @Name: XParamDef
3814     @ElementType:
3815     dis:ResourceDef
3816     @ShadowContent:
3817     @@rdf:type:
3818     DOMMain:XWParameter
3819     @@AliasFor:
3820     @@@For:
3821     !=ManakaiDOM:all
3822     @@@@:
3823     ::ManakaiDOM:all
3824    
3825     ElementTypeBinding:
3826     @Name: enMufDef
3827     @ElementType:
3828     dis:Def
3829     @ShadowContent:
3830     @@ContentType:
3831     lang:muf
3832     @@lang:en
3833    
3834 wakaba 1.1
3835     ElementTypeBinding:
3836     @Name: ClsDef
3837     @ElementType:
3838     dis:ResourceDef
3839     @ShadowContent:
3840     @@rdf:type:
3841     ManakaiDOM:Class
3842     @@AliasFor:
3843     @@@@:
3844     ::ManakaiDOM:Perl
3845     @@@For:
3846     !=ManakaiDOM:Perl
3847     @@ForCheck:
3848     ManakaiDOM:Perl
3849     @@DOMMain:implementFeature: CoreFeature10
3850    
3851     ElementTypeBinding:
3852     @Name: ClsQName
3853     @ElementType:
3854     dis:QName
3855    
3856     ElementTypeBinding:
3857     @Name: ClsISA
3858     @ElementType:
3859     dis:ISA
3860    
3861     ElementTypeBinding:
3862     @Name: Method
3863     @ElementType:
3864     dis:ResourceDef
3865     @ShadowContent:
3866     @@rdf:type:
3867     DISLang:Method
3868    
3869     ElementTypeBinding:
3870     @Name: ToStringMethod
3871     @ElementType:
3872     dis:ResourceDef
3873     @ShadowContent:
3874     @@rdf:type:
3875     DISLang:Method
3876     @@Operator:
3877     @@@@:
3878     DISPerl:AsStringMethod
3879     @@@ContentType:
3880     dis:TypeQName
3881     @@Description:
3882     @@@lang:en
3883     @@@@:
3884     Returns the textual Perl source code representation of this object.
3885 wakaba 1.9
3886    
3887     ElementTypeBinding:
3888     @Name: IntCloneMethod
3889     @ElementType:
3890     dis:ResourceDef
3891     @ShadowContent:
3892     @@rdf:type:
3893     DISLang:Method
3894     @@Name: makeCloneObject
3895     @@Description:
3896     @@@lang:en
3897     @@@@:
3898     Returns the node object of a deep clone of a node object.
3899     @@ManakaiDOM:isStatic:1
3900     @@ManakaiDOM:isForInternal:1
3901     @@ResourceDef:
3902     @@@rdf:type:
3903     DISLang:MethodParameter
3904     @@@Name: nodeObject
3905     @@@Type:
3906     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
3907     @@@Description:
3908     @@@@lang:en
3909     @@@@@: Node object to copy.
3910     @ShadowSibling:
3911     @@ResourceDef:
3912     @@@rdf:type:
3913     DISLang:Method
3914     @@@Operator:
3915     @@@@@:
3916     DISPerl:CloneMethod
3917     @@@@ContentType:
3918     dis:TypeQName
3919     @@@Description:
3920     @@@@lang:en
3921     @@@@@:
3922     Generates a deep clone of this node and returns it.
3923     @@@ResourceDef:
3924     @@@@rdf:type:
3925     DISLang:MethodReturn
3926     @@@@Type: ManakaiPerlCodeFragment
3927     @@@@Description:
3928     @@@@@lang:en
3929     @@@@@@:
3930     The newly created clone node.
3931     \
3932     {NOTE:: The <A::.parentNode> attribute of the clone
3933     is set to <DOM::null>.
3934     \
3935     }
3936     @@@@Def:
3937     @@@@@ContentType:
3938     lang:Perl
3939     @@@@@@:
3940     ## NOTE: Method name directly written
3941     my $ro = $self->_make_clone_object ($self->{<Q::TreeCore:node>});
3942     $ro-><M::ManakaiDOM:ManakaiDOMNodeObject
3943     ::ManakaiDOM:Perl.changeTreeID>
3944     (<Code::ManakaiDOM:generateUniqueID
3945     ::ManakaiDOM:Perl>);
3946     $r = <ClassM::ManakaiPerlCodeFragment.getNodeReference> ($ro);
3947 wakaba 1.1
3948     ElementTypeBinding:
3949     @Name: IntMethod
3950     @ElementType:
3951     dis:ResourceDef
3952     @ShadowContent:
3953     @@rdf:type:
3954     DISLang:Method
3955     @@ManakaiDOM:isForInternal:1
3956    
3957     ElementTypeBinding:
3958     @Name: Attr
3959     @ElementType:
3960     dis:ResourceDef
3961     @ShadowContent:
3962     @@rdf:type:
3963     DISLang:Attribute
3964    
3965     ElementTypeBinding:
3966     @Name: Return
3967     @ElementType:
3968     dis:ResourceDef
3969     @ShadowContent:
3970     @@rdf:type:
3971     DISLang:MethodReturn
3972    
3973     ElementTypeBinding:
3974     @Name: Get
3975     @ElementType:
3976     dis:ResourceDef
3977     @ShadowContent:
3978     @@rdf:type:
3979     DISLang:AttributeGet
3980    
3981     ElementTypeBinding:
3982     @Name: Set
3983     @ElementType:
3984     dis:ResourceDef
3985     @ShadowContent:
3986     @@rdf:type:
3987     DISLang:AttributeSet
3988    
3989     ElementTypeBinding:
3990     @Name: Param
3991     @ElementType:
3992     dis:ResourceDef
3993     @ShadowContent:
3994     @@rdf:type:
3995     DISLang:MethodParameter
3996    
3997     ElementTypeBinding:
3998     @Name: PerlDef
3999     @ElementType:
4000     dis:Def
4001     @ShadowContent:
4002     @@ContentType:
4003     lang:Perl
4004    
4005     ElementTypeBinding:
4006     @Name: disDef
4007     @ElementType:
4008     dis:Def
4009     @ShadowContent:
4010     @@ContentType:
4011     lang:dis
4012    
4013     ElementTypeBinding:
4014     @Name: InCase
4015     @ElementType:
4016     dis:ResourceDef
4017     @ShadowContent:
4018     @@rdf:type:
4019     ManakaiDOM:InCase
4020    
4021     ElementTypeBinding:
4022     @Name: nullCase
4023     @ElementType:
4024     dis:ResourceDef
4025     @ShadowContent:
4026     @@rdf:type:
4027     ManakaiDOM:InCase
4028     @@Value:
4029     @@@is-null:1
4030    
4031     ElementTypeBinding:
4032     @Name: TrueCase
4033     @ElementType:
4034     dis:ResourceDef
4035     @ShadowContent:
4036     @@rdf:type:
4037     ManakaiDOM:InCase
4038     @@Value:true
4039     @@Type:
4040 wakaba 1.12 DOMMain:boolean::ManakaiDOM:all
4041 wakaba 1.1
4042    
4043     ElementTypeBinding:
4044     @Name: FalseCase
4045     @ElementType:
4046     dis:ResourceDef
4047     @ShadowContent:
4048     @@rdf:type:
4049     ManakaiDOM:InCase
4050     @@Value:false
4051     @@Type:
4052 wakaba 1.12 DOMMain:boolean::ManakaiDOM:all
4053 wakaba 1.1
4054     ElementTypeBinding:
4055     @Name: enDesc
4056     @ElementType:
4057     dis:Description
4058     @ShadowContent:
4059     @@lang:en
4060    
4061     ElementTypeBinding:
4062     @Name: PropDef
4063     @ElementType:
4064     dis:ResourceDef
4065     @ShadowContent:
4066     @@rdf:type:
4067     rdf:Property
4068     @@AliasFor:
4069     @@@@:
4070     ::ManakaiDOM:all
4071     @@@For:
4072     !=ManakaiDOM:all
4073    
4074     ElementTypeBinding:
4075     @Name: NamedParam
4076     @ElementType:
4077     dis:ResourceDef
4078     @ShadowContent:
4079     @@rdf:type:
4080     DISLang:MethodParameter
4081     @@DISPerl:isNamedParameter:1
4082    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24