随笔-341  评论-2670  文章-0  trackbacks-0
    经历了大约一个多星期的挑选,Vczh Library++3.0托管语言的语法树大约就定下来了。跟本地语言有一个缺省的语法叫NativeX一样,这次的语法就叫ManagedX了。当然ManagedX只是设计来直接反映托管语言语法树的一门语言,如果愿意的话,这个语法树还能被编译成其他长得像(嗯,只能是像,因为必须是托管的,有类没指针等)Basic啦Pascal那样子的东西。

    我将ManagedX的语法分为两部分。第一部分是基础部分,第二部分则是扩展部分。将他们分开的依据就是,一个基于扩展部分的程序,总是可以被重写为一个功能完全一致但是仅基于基础部分的比较复杂的程序。举一个简单的例子。我们知道lambda表达式在一门面向对象语言中并不是必需的,它只是一个语法糖。如果我们在面向对象语言中把函数指针统统抽象成一个基类或者接口(就跟C#的Delegate一样)的话,一个lambda表达式总是可以被表达成一个新的类型,然后只需要重新组织一下生成该lambda表达式的函数的局部变量,就可以把lambda表达是去掉了。当然lambda表达式作为一个语法来说是必需的,因为它大大提高了开发效率。但是对于编译过程来说又不是必需的,因为它总是可以用自动重写的方法来去掉。

    因此ManagedX的编译过程就比较清晰了:
    1、我们接受一个基于扩展部分的程序,然后经过第一轮的语法分析,得到语法树上面所有节点的类型信息和引用信息。
    2、根据分析出来的信息,将该程序重写为仅基于基础部分的程序。在重写的过程中会使得信息不会丢失(特别是ManagedX支持反射,而反射却可以支持扩展部分,所以需要做很多小动作来维持重写前后的程序运行上的一致性)
    3、对重写出来的新程序重新进行语法分析。
    4、根据分析出来的信息,将它编译成NativeX

    从这里打架就可以知道为什么我之前要做NativeX了,因为实现了NativeX之后,以后实现很多新的复杂语言会十分省事。运行时的虚拟机做好了,函数库也有了一部分,还有基于二进制编译结果的多文件支持啦、泛型啦、concept mapping啦、外接函数插件啦、还有将来会做的debugger,和编译到X86的过程,都可以直接被新的语言所享受。在这里ManagedX的开发过程就仅仅是一个前端的开发过程了,因为后端的第一阶段已经完成了,至少可以直接使用。

    下面贴一下ManagedX那将近900行的语法树:(Library\Scripting\ManagedLanguage\ManagedLanguageExpression.h)
  1 /***********************************************************************
  2 Vczh Library++ 3.0
  3 Developer: 陈梓瀚(vczh)
  4 Scripting::ManagedLanguage
  5 
  6 Classes:
  7 ***********************************************************************/
  8 
  9 #ifndef VCZH_SCRIPTING_MANAGEDLANGUAGE_MANAGEDLANGUAGEEXPRESSION
 10 #define VCZH_SCRIPTING_MANAGEDLANGUAGE_MANAGEDLANGUAGEEXPRESSION
 11 
 12 #include "..\..\Pointer.h"
 13 #include "..\..\String.h"
 14 #include "..\..\Collections\List.h"
 15 #include "..\..\Collections\Dictionary.h"
 16 #include "..\Common\AlgorithmDeclaration.h"
 17 
 18 namespace vl
 19 {
 20     namespace scripting
 21     {
 22         namespace managedlanguage
 23         {
 24             struct ManagedPosition
 25             {
 26                 vint                                        start;
 27                 vint                                        lineStart;
 28                 vint                                        lineIndex;
 29                 vint                                        codeIndex;
 30 
 31                 ManagedPosition();
 32             };
 33 
 34             class ManagedLanguageElement : public Object, private NotCopyable
 35             {
 36             public:
 37                 ManagedPosition                                position;
 38             };
 39 
 40 /***********************************************************************
 41 Basic Constructions
 42 ***********************************************************************/
 43 
 44             class ManagedType : public ManagedLanguageElement
 45             {
 46             public:
 47                 ALGORITHM_TARGET_ROOT(ManagedType)
 48             };
 49 
 50             class ManagedExpression : public ManagedLanguageElement
 51             {
 52             public:
 53                 ALGORITHM_TARGET_ROOT(ManagedExpression)
 54             };
 55 
 56             class ManagedStatement : public ManagedLanguageElement
 57             {
 58             public:
 59                 ALGORITHM_TARGET_ROOT(ManagedStatement)
 60             };
 61 
 62             class ManagedDeclaration : public ManagedLanguageElement
 63             {
 64             public:
 65                 ALGORITHM_TARGET_ROOT(ManagedDeclaration)
 66             };
 67 
 68             class ManagedProgram : public ManagedLanguageElement
 69             {
 70             public:
 71                 collections::List<Ptr<ManagedDeclaration>>    declarations;
 72             };
 73 
 74 /***********************************************************************
 75 Extended Constructions
 76 ***********************************************************************/
 77 
 78             class ManagedExtendedType : public ManagedType
 79             {
 80             public:
 81                 ALGORITHM_ACCEPT_DECLARATION(ManagedType)
 82 
 83                 ALGORITHM_TARGET_ROOT(ManagedExtendedType)
 84             };
 85 
 86             class ManagedExtendedExpression : public ManagedExpression
 87             {
 88             public:
 89                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
 90 
 91                 ALGORITHM_TARGET_ROOT(ManagedExtendedExpression)
 92             };
 93 
 94             class ManagedExtendedStatement : public ManagedStatement
 95             {
 96             public:
 97                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
 98 
 99                 ALGORITHM_TARGET_ROOT(ManagedExtendedStatement)
100             };
101 
102             class ManagedExtendedDeclaration : public ManagedDeclaration
103             {
104             public:
105                 ALGORITHM_ACCEPT_DECLARATION(ManagedDeclaration)
106 
107                 ALGORITHM_TARGET_ROOT(ManagedExtendedDeclaration)
108             };
109 
110 /***********************************************************************
111 Basic Types
112 ***********************************************************************/
113 
114             class ManagedGenericArgumentType : public ManagedType
115             {
116             public:
117                 ALGORITHM_ACCEPT_DECLARATION(ManagedType)
118 
119                 WString                                        name;
120             };
121 
122             class ManagedReferencedType : public ManagedType
123             {
124             public:
125                 ALGORITHM_ACCEPT_DECLARATION(ManagedType)
126 
127                 WString                                        name;
128             };
129 
130             class ManagedMemberType : public ManagedType
131             {
132             public:
133                 ALGORITHM_ACCEPT_DECLARATION(ManagedType)
134 
135                 Ptr<ManagedType>                            operand;
136                 WString                                        member;
137             };
138 
139             class ManagedInstantiatedGenericType : public ManagedType
140             {
141             public:
142                 ALGORITHM_ACCEPT_DECLARATION(ManagedType)
143 
144                 Ptr<ManagedType>                            elementType;
145                 collections::List<Ptr<ManagedType>>            argumentTypes;
146             };
147 
148 #define MANAGED_TYPE_TARGETS(P, F)\
149             F(P, ManagedGenericArgumentType)\
150             F(P, ManagedReferencedType)\
151             F(P, ManagedMemberType)\
152             F(P, ManagedInstantiatedGenericType)\
153             F(P, ManagedExtendedType)\
154 
155             DEFINE_ALGORITHM_INTERFACE(ManagedType, MANAGED_TYPE_TARGETS)
156 
157 /***********************************************************************
158 Extended Types
159 ***********************************************************************/
160 
161             class ManagedArrayType : public ManagedExtendedType
162             {
163             public:
164                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedType)
165 
166                 Ptr<ManagedType>                            elementType;
167                 int                                            dimensionCount;
168             };
169 
170             class ManagedFunctionType : public ManagedExtendedType
171             {
172             public:
173                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedType)
174 
175                 Ptr<ManagedType>                            returnType;
176                 collections::List<Ptr<ManagedType>>            parameterTypes;
177             };
178 
179             class ManagedEventType : public ManagedExtendedType
180             {
181             public:
182                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedType)
183 
184                 Ptr<ManagedType>                            functionType;
185             };
186 
187             class ManagedAutoReferType : public ManagedExtendedType
188             {
189             public:
190                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedType)
191             };
192 
193 #define MANAGED_EXTENDED_TYPE_TARGETS(P, F)\
194             F(P, ManagedArrayType)\
195             F(P, ManagedFunctionType)\
196             F(P, ManagedEventType)\
197             F(P, ManagedAutoReferType)\
198 
199             DEFINE_ALGORITHM_INTERFACE(ManagedExtendedType, MANAGED_EXTENDED_TYPE_TARGETS)
200 
201 /***********************************************************************
202 Basic Expressions
203 ***********************************************************************/
204 
205             class ManagedPrimitiveExpression : public ManagedExpression
206             {
207             };
208 
209             class ManagedNullExpression : public ManagedPrimitiveExpression
210             {
211             public:
212                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
213             };
214 
215             class ManagedIntegerExpression : public ManagedPrimitiveExpression
216             {
217             public:
218                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
219 
220                 bool                                        sign;
221                 union
222                 {
223                     signed __int64                            signedInteger;
224                     unsigned __int64                        unsignedInteger;
225                 }                                            value;
226             };
227 
228             class ManagedFloatExpression : public ManagedPrimitiveExpression
229             {
230             public:
231                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
232 
233                 bool                                        doublePrecision;
234                 double                                        value;
235             };
236 
237             class ManagedBooleanExpression : public ManagedPrimitiveExpression
238             {
239             public:
240                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
241 
242                 bool                                        value;
243             };
244 
245             class ManagedCharExpression : public ManagedPrimitiveExpression
246             {
247             public:
248                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
249 
250                 wchar_t                                        value;
251             };
252 
253             class ManagedStringExpression : public ManagedPrimitiveExpression
254             {
255             public:
256                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
257 
258                 WString                                        value;
259             };
260 
261             class ManagedReferenceExpression : public ManagedExpression
262             {
263             public:
264                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
265 
266                 WString                                        name;
267             };
268 
269             class ManagedMemberExpression : public ManagedExpression
270             {
271             public:
272                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
273 
274                 Ptr<ManagedExpression>                        operand;
275                 WString                                        member;
276             };
277 
278             class ManagedInstanciatedExpression : public ManagedExpression
279             {
280             public:
281                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
282 
283                 Ptr<ManagedExpression>                        operand;
284                 collections::List<Ptr<ManagedType>>            argumentTypes;
285             };
286 
287             class ManagedInvokeExpression : public ManagedExpression
288             {
289             public:
290                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
291 
292                 Ptr<ManagedExpression>                        function;
293                 collections::List<Ptr<ManagedExpression>>    arguments;
294                 collections::List<WString>                    defaultParameterNames;
295                 collections::List<Ptr<ManagedExpression>>    defaultParameterValues;
296             };
297 
298             class ManagedNewExpression : public ManagedExpression
299             {
300             public:
301                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
302 
303                 Ptr<ManagedType>                            objectType;
304                 collections::List<Ptr<ManagedExpression>>    arguments;
305                 collections::List<WString>                    defaultParameterNames;
306                 collections::List<Ptr<ManagedExpression>>    defaultParameterValues;
307                 collections::List<WString>                    propertyNames;
308                 collections::List<Ptr<ManagedExpression>>    propertyValues;
309             };
310 
311             class ManagedFunctionResultExpression : public ManagedExpression
312             {
313             public:
314                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
315             };
316 
317             class ManagedCastingExpression : public ManagedExpression
318             {
319             public:
320                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
321 
322                 Ptr<ManagedExpression>                        operand;
323                 Ptr<ManagedType>                            type;
324             };
325 
326             class ManagedThisExpression : public ManagedExpression
327             {
328             public:
329                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
330             };
331 
332             class ManagedBaseExpression : public ManagedExpression
333             {
334             public:
335                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
336             };
337 
338             class ManagedAssignmentExpression : public ManagedExpression
339             {
340             public:
341                 ALGORITHM_ACCEPT_DECLARATION(ManagedExpression)
342             };
343 
344 #define MANAGED_EXPRESSION_TARGETS(P, F)\
345             F(P, ManagedNullExpression)\
346             F(P, ManagedIntegerExpression)\
347             F(P, ManagedFloatExpression)\
348             F(P, ManagedBooleanExpression)\
349             F(P, ManagedCharExpression)\
350             F(P, ManagedStringExpression)\
351             F(P, ManagedReferenceExpression)\
352             F(P, ManagedMemberExpression)\
353             F(P, ManagedInstanciatedExpression)\
354             F(P, ManagedInvokeExpression)\
355             F(P, ManagedNewExpression)\
356             F(P, ManagedFunctionResultExpression)\
357             F(P, ManagedCastingExpression)\
358             F(P, ManagedThisExpression)\
359             F(P, ManagedBaseExpression)\
360             F(P, ManagedAssignmentExpression)\
361             F(P, ManagedExtendedExpression)\
362 
363             DEFINE_ALGORITHM_INTERFACE(ManagedExpression, MANAGED_EXPRESSION_TARGETS)
364 
365 /***********************************************************************
366 Extended Expressions
367 ***********************************************************************/
368 
369             class ManagedLambdaExpression : public ManagedExtendedExpression
370             {
371             public:
372                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedExpression)
373 
374                 collections::List<Ptr<ManagedType>>            parameterTypes;
375                 collections::List<WString>                    parameterNames;
376                 Ptr<ManagedType>                            returnType;
377                 Ptr<ManagedStatement>                        body;
378             };
379 
380             class ManagedChoiceExpression : public ManagedExtendedExpression
381             {
382             public:
383                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedExpression)
384 
385                 Ptr<ManagedExpression>                        condition;
386                 Ptr<ManagedExpression>                        trueExpression;
387                 Ptr<ManagedExpression>                        falseExpression;
388             };
389 
390             class ManagedNullChoiceExpression : public ManagedExtendedExpression
391             {
392             public:
393                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedExpression)
394 
395                 Ptr<ManagedExpression>                        valueExpression;
396                 Ptr<ManagedExpression>                        candidateExpression;
397             };
398 
399             class ManagedTypeofExpression : public ManagedExtendedExpression
400             {
401             public:
402                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedExpression)
403 
404                 Ptr<ManagedType>                            type;
405             };
406 
407 #define MANAGED_EXTENDED_EXPRESSION_TARGETS(P, F)\
408             F(P, ManagedLambdaExpression)\
409             F(P, ManagedChoiceExpression)\
410             F(P, ManagedNullChoiceExpression)\
411             F(P, ManagedTypeofExpression)\
412 
413             DEFINE_ALGORITHM_INTERFACE(ManagedExtendedExpression, MANAGED_EXTENDED_EXPRESSION_TARGETS)
414 
415 /***********************************************************************
416 Basic Statements
417 ***********************************************************************/
418 
419             class ManagedEmptyStatement : public ManagedStatement
420             {
421             public:
422                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
423             };
424 
425             class ManagedCompositeStatement : public ManagedStatement
426             {
427             public:
428                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
429 
430                 collections::List<Ptr<ManagedStatement>>    statements;
431             };
432 
433             class ManagedExpressionStatement : public ManagedStatement
434             {
435             public:
436                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
437 
438                 Ptr<ManagedExpression>                        expression;
439             };
440 
441             class ManagedVariableStatement : public ManagedStatement
442             {
443             public:
444                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
445 
446                 bool                                        constant;
447                 Ptr<ManagedType>                            type;
448                 WString                                        name;
449                 Ptr<ManagedExpression>                        initializer;
450             };
451 
452             class ManagedIfStatement : public ManagedStatement
453             {
454             public:
455                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
456 
457                 Ptr<ManagedExpression>                        condition;
458                 Ptr<ManagedStatement>                        trueStatement;
459                 Ptr<ManagedStatement>                        falseStatement;
460             };
461 
462             class ManagedWhileStatement : public ManagedStatement
463             {
464             public:
465                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
466 
467                 Ptr<ManagedExpression>                        beginCondition;
468                 Ptr<ManagedExpression>                        endCondition;
469                 Ptr<ManagedStatement>                        statement;
470             };
471 
472             class ManagedForStatement : public ManagedStatement
473             {
474             public:
475                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
476 
477                 Ptr<ManagedStatement>                        initializer;
478                 Ptr<ManagedStatement>                        sideEffect;
479                 Ptr<ManagedExpression>                        condition;
480                 Ptr<ManagedStatement>                        statement;
481             };
482 
483             class ManagedBreakStatement : public ManagedStatement
484             {
485             public:
486                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
487             };
488 
489             class ManagedContinueStatement : public ManagedStatement
490             {
491             public:
492                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
493             };
494 
495             class ManagedReturnStatement : public ManagedStatement
496             {
497             public:
498                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
499             };
500 
501             class ManagedTryCatchStatement : public ManagedStatement
502             {
503             public:
504                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
505 
506                 Ptr<ManagedStatement>                        tryStatement;
507                 collections::List<Ptr<ManagedType>>            catchExceptionTypes;
508                 collections::List<WString>                    catchExceptionNames;
509                 collections::List<Ptr<ManagedStatement>>    catchExceptionHandlers;
510                 Ptr<ManagedStatement>                        finallyStatement;
511             };
512 
513             class ManagedThrowStatement : public ManagedStatement
514             {
515             public:
516                 ALGORITHM_ACCEPT_DECLARATION(ManagedStatement)
517 
518                 Ptr<ManagedExpression>                        expression;
519             };
520 
521 #define MANAGED_STATEMENT_TARGETS(P, F)\
522             F(P, ManagedEmptyStatement)\
523             F(P, ManagedCompositeStatement)\
524             F(P, ManagedExpressionStatement)\
525             F(P, ManagedVariableStatement)\
526             F(P, ManagedIfStatement)\
527             F(P, ManagedWhileStatement)\
528             F(P, ManagedForStatement)\
529             F(P, ManagedBreakStatement)\
530             F(P, ManagedContinueStatement)\
531             F(P, ManagedReturnStatement)\
532             F(P, ManagedTryCatchStatement)\
533             F(P, ManagedThrowStatement)\
534             F(P, ManagedExtendedStatement)
535 
536             DEFINE_ALGORITHM_INTERFACE(ManagedStatement, MANAGED_STATEMENT_TARGETS)
537 
538 /***********************************************************************
539 Extended Statements
540 ***********************************************************************/
541 
542             class ManagedUsingStatement : public ManagedExtendedStatement
543             {
544             public:
545                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedStatement)
546 
547                 Ptr<ManagedType>                            type;
548                 WString                                        name;
549                 Ptr<ManagedExpression>                        initialize;
550                 Ptr<ManagedStatement>                        statement;
551             };
552 
553             class ManagedLockStatement : public ManagedExtendedStatement
554             {
555             public:
556                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedStatement)
557 
558                 Ptr<ManagedExpression>                        lock;
559                 Ptr<ManagedStatement>                        statement;
560             };
561 
562             class ManagedSelectStatement : public ManagedExtendedStatement
563             {
564             public:
565                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedStatement)
566 
567                 Ptr<ManagedExpression>                        expression;
568                 collections::List<Ptr<ManagedExpression>>    caseConditions;
569                 collections::List<Ptr<ManagedStatement>>    caseStatements;
570                 Ptr<ManagedStatement>                        defaultStatements;
571             };
572 
573 #define MANAGED_EXTENDED_STATEMENT_TARGETS(P, F)\
574             F(P, ManagedUsingStatement)\
575             F(P, ManagedLockStatement)\
576             F(P, ManagedSelectStatement)\
577 
578             DEFINE_ALGORITHM_INTERFACE(ManagedExtendedStatement, MANAGED_EXTENDED_STATEMENT_TARGETS)
579 
580 /***********************************************************************
581 Basic Declaration Fragments
582 ***********************************************************************/
583 
584             struct ManagedAttributeInfo
585             {
586             public:
587                 collections::List<Ptr<ManagedNewExpression>>    attributes;
588             };
589 
590             struct ManagedGenericInfo
591             {
592             public:
593                 struct Argument
594                 {
595                     WString                                    name;
596                     collections::List<Ptr<ManagedType>>        typeConstraints;
597                     bool                                    newConstraint;
598                 };
599 
600                 collections::List<Ptr<Argument>>            arguments;
601             };
602 
603             namespace declatt
604             {
605                 enum Accessor
606                 {
607                     Public,
608                     Protected,
609                     Private,
610                     ProtectedInternal,
611                     Internal,
612                 };
613 
614                 enum Inheritation
615                 {
616                     Normal,
617                     Sealed,
618                     Abstract,
619                     Virtual,
620                     Override,
621                 };
622 
623                 enum MemberType
624                 {
625                     Instance,
626                     Static,
627                 };
628 
629                 enum DataType
630                 {
631                     Variable,
632                     Constant,
633                     Readonly,
634                 };
635             };
636 
637             class ManagedMember : public ManagedLanguageElement
638             {
639             public:
640                 ALGORITHM_TARGET_ROOT(ManagedMember)
641 
642                 declatt::Accessor                            accessor;
643                 declatt::MemberType                            memberType;
644                 ManagedAttributeInfo                        attributeInfo;
645             };
646 
647             class ManagedExtendedMember : public ManagedMember
648             {
649             public:
650                 ALGORITHM_ACCEPT_DECLARATION(ManagedMember)
651 
652                 ALGORITHM_TARGET_ROOT(ManagedExtendedMember)
653             };
654 
655             class ManagedParameter : public ManagedLanguageElement
656             {
657             public:
658                 enum ParameterType
659                 {
660                     Normal,
661                     Default,
662                     Params
663                 };
664 
665                 Ptr<ManagedType>                            type;
666                 WString                                        name;
667                 ParameterType                                parameterType;
668                 Ptr<ManagedExpression>                        defaultValue;
669                 bool                                        params;
670             };
671 
672             class ManagedMethodCommon
673             {
674             public:
675                 collections::List<Ptr<ManagedParameter>>    parameters;
676                 Ptr<ManagedStatement>                        body;
677             };
678 
679             class ManagedConstructorCommon
680             {
681             public:
682                 collections::List<Ptr<ManagedExpression>>    baseArguments;
683                 collections::List<WString>                    baseDefaultParameterNames;
684                 collections::List<Ptr<ManagedExpression>>    baseDefaultParameterValues;
685             };
686 
687 /***********************************************************************
688 Basic Members
689 ***********************************************************************/
690 
691             class ManagedField : public ManagedMember
692             {
693             public:
694                 ALGORITHM_ACCEPT_DECLARATION(ManagedMember)
695 
696                 Ptr<ManagedType>                            type;
697                 WString                                        name;
698                 Ptr<ManagedExpression>                        initializer;
699 
700                 declatt::DataType                            dataType;
701             };
702 
703             class ManagedMethod : public ManagedMember, public ManagedMethodCommon
704             {
705             public:
706                 ALGORITHM_ACCEPT_DECLARATION(ManagedMember)
707 
708                 Ptr<ManagedType>                            implementedInterfaceType;
709                 WString                                        name;
710                 Ptr<ManagedType>                            returnType;
711 
712                 declatt::Inheritation                        inheritation;
713                 ManagedGenericInfo                            genericInfo;
714             };
715 
716             class ManagedConstructor : public ManagedMember, public ManagedMethodCommon, public ManagedConstructorCommon
717             {
718             public:
719                 ALGORITHM_ACCEPT_DECLARATION(ManagedMember)
720             };
721 
722 #define MANAGED_MEMBER_TARGETS(P, F)\
723             F(P, ManagedField)\
724             F(P, ManagedMethod)\
725             F(P, ManagedConstructor)\
726             F(P, ManagedExtendedMember)\
727 
728             DEFINE_ALGORITHM_INTERFACE(ManagedMember, MANAGED_MEMBER_TARGETS)
729 
730 /***********************************************************************
731 Extended Members
732 ***********************************************************************/
733 
734             class ManagedProperty : public ManagedExtendedMember
735             {
736             public:
737                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedMember)
738 
739                 Ptr<ManagedType>                            type;
740                 WString                                        name;
741                 Ptr<ManagedStatement>                        getter;
742                 Ptr<ManagedStatement>                        setter;
743 
744                 declatt::Accessor                            setterAccessor;
745                 declatt::Inheritation                        inheritation;
746             };
747 
748             class ManagedConverterOperator : public ManagedExtendedMember
749             {
750             public:
751                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedMember)
752 
753                 Ptr<ManagedType>                            targetType;
754                 bool                                        implicit;
755 
756                 declatt::Inheritation                        inheritation;
757                 ManagedGenericInfo                            genericInfo;
758             };
759 
760             class ManagedConverterConstructor : public ManagedExtendedMember, public ManagedConstructorCommon
761             {
762             public:
763                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedMember)
764 
765                 Ptr<ManagedType>                            sourceType;
766                 bool                                        implicit;
767             };
768 
769 #define MANAGED_EXTENDED_MEMBER_TARGETS(P, F)\
770             F(P, ManagedProperty)\
771             F(P, ManagedConverterOperator)\
772             F(P, ManagedConverterConstructor)\
773 
774             DEFINE_ALGORITHM_INTERFACE(ManagedExtendedMember, MANAGED_EXTENDED_MEMBER_TARGETS)
775 
776 /***********************************************************************
777 Basic Declarations
778 ***********************************************************************/
779 
780             class ManagedTypeDeclaration : public ManagedDeclaration
781             {
782             public:
783                 ALGORITHM_ACCEPT_DECLARATION(ManagedDeclaration)
784 
785                 enum DeclarationType
786                 {
787                     Class,
788                     Structure,
789                     Interface,
790                 };
791 
792                 collections::List<Ptr<ManagedMember>>        members;
793 
794                 declatt::Accessor                            accessor;
795                 declatt::Inheritation                        inheritation;
796                 ManagedGenericInfo                            genericInfo;
797                 ManagedAttributeInfo                        attributeInfo;
798             };
799 
800             class ManagedNamespaceDeclaration : public ManagedDeclaration
801             {
802             public:
803                 ALGORITHM_ACCEPT_DECLARATION(ManagedDeclaration)
804 
805                 collections::List<Ptr<ManagedDeclaration>>    declarations;
806             };
807 
808 #define MANAGED_DECLARATION_TARGETS(P, F)\
809             F(P, ManagedTypeDeclaration)\
810             F(P, ManagedNamespaceDeclaration)\
811             F(P, ManagedExtendedDeclaration)\
812 
813             DEFINE_ALGORITHM_INTERFACE(ManagedDeclaration, MANAGED_DECLARATION_TARGETS)
814 
815 /***********************************************************************
816 Extended Declarations
817 ***********************************************************************/
818 
819             class ManagedEnumerationDeclaration : public ManagedExtendedDeclaration
820             {
821             public:
822                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedDeclaration)
823 
824                 bool                                        composable;
825                 collections::List<WString>                    enumerationNames;
826                 collections::List<vint>                        enumerationValues;
827 
828                 declatt::Accessor                            accessor;
829                 ManagedAttributeInfo                        attributeInfo;
830             };
831 
832             class ManagedTypeRenameDeclaration : public ManagedExtendedDeclaration
833             {
834             public:
835                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedDeclaration)
836 
837                 declatt::Accessor                            accessor;
838                 ManagedGenericInfo                            genericInfo;
839             };
840 
841             class ManagedUsingNamespaceDeclaration : public ManagedExtendedDeclaration
842             {
843             public:
844                 ALGORITHM_ACCEPT_DECLARATION(ManagedExtendedDeclaration)
845 
846                 collections::List<WString>                    namespaceFragments;
847             };
848 
849 #define MANAGED_EXTENDED_DECLARATION_TARGETS(P, F)\
850             F(P, ManagedEnumerationDeclaration)\
851             F(P, ManagedTypeRenameDeclaration)\
852             F(P, ManagedUsingNamespaceDeclaration)\
853 
854             DEFINE_ALGORITHM_INTERFACE(ManagedExtendedDeclaration, MANAGED_EXTENDED_DECLARATION_TARGETS)
855         }
856     }
857 }
858 
859 #endif

posted on 2011-05-28 00:33 陈梓瀚(vczh) 阅读(3186) 评论(17)  编辑 收藏 引用 所属分类: VL++3.0开发纪事

评论:
# re: Vczh Library++3.0托管语言语法树完成 2011-05-28 01:10 | 溪流
保持队形,膜拜大神啊!^_^  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成[未登录] 2011-05-28 02:09 | 邱震钰(zblc)
膜拜大神啊~~~~~~~~~~~~~~~~~~~~~
(表代码...表代码.........我要图..........请上图,我要好看的图........,最好是连环画的那种)  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-28 02:48 | 陈梓瀚(vczh)
@溪流
卧槽你们这群魂淡  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-28 02:52 | ArthasLee
妖~完全看不明白。。。
求大神自拍、3D视频……  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-28 04:54 | lwch
为什么会是先有Demo再有语法树的结构的?不解...  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-28 05:43 | 陈梓瀚(vczh)
@lwch
ManagedX没有demo,那个demo是NativeX的。我先做完了NativeX,然后现在基于NativeX做ManagedX。  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-28 05:46 | 陈昱(CY)
我也来膜拜大神,难道以后要成水区了。。。。。。  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-28 06:54 | lwch
@陈梓瀚(vczh)
ManagedX和NativeX到底是两种神马玩意..  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成[未登录] 2011-05-28 07:45 | 邱震钰(zblc)
@lwch
嘛,我认为就像MSIL和C#的关系  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-28 09:52 | 陈梓瀚(vczh)
@lwch
看本文的“NativeX”上的超链接  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-28 09:52 | 陈梓瀚(vczh)
@邱震钰(zblc)
no,是C和C#的关系  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-28 10:40 | Enic
虽然不知道楼主在说什么,但是感觉楼主很牛逼,,,

膜拜大神啊,,,  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-28 18:39 | 陈梓瀚(vczh)
@Enic
........  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成[未登录] 2011-05-28 19:30 | 邱震钰(zblc)
@陈梓瀚(vczh)
- -bnr ...... 原来如此 广义上是这么回事  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-29 02:13 | airtrack
额,还是膜拜下。  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成 2011-05-30 01:29 | 千暮(zblc)
膜拜楼主啊~~~~~~~~~~~~~~~~~~~~~~~~
(每每看到楼主的帖子如此风骚且韵味十足 我就情不自禁的想膜拜一下~~~~~~~~)  回复  更多评论
  
# re: Vczh Library++3.0托管语言语法树完成[未登录] 2011-05-30 02:58 | connor
膜拜大神啊~~~~~~~~~~
求包 养~~~~~~~~~~  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理