/[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.8 - (hide annotations) (download)
Fri Apr 1 07:58:46 2005 UTC (20 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.7: +200 -2 lines
Brock preprocessing implemented (but not work yet)

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24