/[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.11 - (hide annotations) (download)
Mon Apr 4 15:21:32 2005 UTC (20 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.10: +241 -29 lines
Method parameters and return values implemented

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24