/[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.15 - (hide annotations) (download)
Thu Apr 28 15:22:59 2005 UTC (20 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.14: +111 -6 lines
bin/dac2pm.pl: New script; lib/Message/Util/DIS.dis: Module generation implemented; lib/Makefile: New

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24