/[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.18 - (hide annotations) (download)
Sun May 1 05:33:58 2005 UTC (20 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.17: +48 -2 lines
Exporting constants implemented

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24