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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24