Вы находитесь на странице: 1из 19

VivaCore

: : 09.01.2008 ,

, VivaCore, . , ++.

VivaCore, .

VivaCore , , , ,

++

. , .

Viva64 [1]. / ++, . Viva64

Viva64 64Windows-

, . . OpenC++. , , . , , (OpenC++ VivaCore). VivaCore - http://www.viva64.com/vivacore-download.php. . , ,

OpenC++ [2],

Viva64

, OpenC++,

VivaCore. , / ++ VivaCore

VivaCore
VivaCore , . . , . OpenC++ .

OpenC++
, OpenC++, , wchar_t, . 2004 2003

, OpenC++? , . OpenC++ , . .

, . OpenC++ , OpenC++

, VivaCore, 1. : PureC_Foo(ptr) char *ptr; { ... } 2. ++, VisualStudio 2005/2008. , __noop, __if_exists, __ptr32, __pragma, __inter ace f . 3. . 4. 5. Viva64. 6. , L"begin"L"end") const char *name = "Viva\ Core"; OpenC++ . 7. . . (const wchar_t *str = : , , register template: object.template foo<int> ();. . 64 OpenC++: . "class" ,

"bool r = a < 1 || b > (int) 2;", . ,

VivaCore

( The Wave C++ preprocessor library) Visual Studio). , , ; , 127

; , VivaCore. , , , OpenC++ OpenC++ VivaCore, . VivaCore. , OpenC++

VivaCore, .

VivaCore
VivaCore . , VivaCore . . 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. , , . , VivaCore : , , VivaCore, ,

(VisualAssist, DevExpress Refactoring, JetBrains Resharper); (Viva64, lint, Gimpel Software PC-Lint, Microsoft FxCop, Parasoft C++test); (Compuware BoundsChecker, AutomatedQA AQTime); / ++, (OpenTS); (Parasoft C++test) , , ; (Whole Tomato Software VisualAssist, ); (Synopsis, Doxygen); ; ; (C and C++ Code Counter - CCCC); (Gimpel Software PC-Lint); , (Viva64); ; , (Source-Navigator);

16.

(Ochre SourceStyler).

[3]. VivaCore . , . , , VivaCore. front-end ++ , GCC Semantic Designs [5]. / ++ /

[4]. ++

, ,

, , #include , ".i". ( ). . , , , ( ( , ) . ). , . , ,

VivaCore . ".c/.cpp" , #include . , : ,

" ,

").

. .

(Abstract Syntax Tree - AST) , , .

, . (derivation tree- DT, parse tree - PT) , , .

. AST

, . VivaCore / ++

. VivaCore . , . / ++

VivaCore
VivaCore . 1.

1-

VivaCore.

 

1)
VivaCore . Wave C++ preprocessor library, Microsoft Visual C++)

(Input subsystem)
/ ++ , The . ( , / VivaCore . (PT) , , . , , . : VivaConfiguration, ReadFile. . VivaCore. , , , . ++ . , , "i".

2) subsystem)
, . VivaCore.
y

(Preprocessor

, : . ). . , . , . , ,

( ,

++. , Visual Studio.

, SA_Success

Viva64 SA_FormatString,

. : VivaPreprocessor, CreateStringInfo, IsInterestingLine, GetLineNumberByPtr, PreprocessingItem, SkipUninterestingCode.

3)
. , .

(Lexer)
, ,

!
,

2-

 

    

 

 

VivaCore Token.h), . CLASS WCHAR "class" "wchar_t" . . tokennames.h "table" , . "tableC" . Lex.cc. , CLASS, "class" ++ , tokennames.h.

Token ( :

++ .

isTypeSpecifier, optIntegralTypeOrClassSpec , . , tokens_ , Lex.

. , VivaCore

, GetToken, LookAhead, CanLookAhead.

DumpEx 258 258 91 262 93 59 303 123 282 42 258 LC_ID lc_id [ 6 ] ; struct { char * locale 5 5 1 1 1 1 6 1 4 1 6

XML . : Token, Lex, TokenContainer.

4)

(Parser)
(derivation tree- DT), . , VivaCore ( ST), , .

++. , . , , ,

Leaf.

3. , Ptree

const = 0 " ,

NonLeaf

Leaf.

, . Lis .

Ptree : Car, Cdr, Cadr, Cddr,

LastNth, Length, Eq.

, , int MyFoo(const float value) { if (value < 1.0) return sizeof(unsigned long *); return value * 4.0f < 10.0f ? 0 : 1; } , 4.1-4.4. , :

"

. ,

Ptree "v r ual bool IsLeaf() t .

'

'

&%$# "

Vv ,

e ,

Parser. NonLeaf .

4.1.

4.2.

3 2

2 2 3

4.3.

4.4.

( Encoding.

, Encoding.cc.

IsBuiltInTy e

". .cpp" , , , , , , . . . , .

, , PtreeDeclaration:[ 0 NonLeaf:[ LeafINT:int ]

. :

PtreeExprState ent ,

. ,

Ty eInfo, .

7
. ),

, , IsFunction, IsPointerTy e, .

treeDeclarator:[ Leaf:MyFoo Leaf:( NonLeaf:[ NonLeaf:[ NonLeaf:[ LeafCONST:const NonLeaf:[ LeafFLOAT:float ] ] treeDeclarator:[ Leaf:value ] ] ] Leaf:)

] [{ NonLeaf:[ treeIfStatement:[ LeafReserved:if Leaf:( treeInfixExpr:[ LeafName:value Leaf:< Leaf:1.0 ] Leaf:) treeReturnStatement:[

LeafReserved:return treeSizeofExpr:[ Leaf:sizeof Leaf:( NonLeaf:[ NonLeaf:[ LeafUNSIGNED:unsigned LeafLONG:long ] treeDeclarator:[ Leaf:* ] ] Leaf:) ] Leaf:; ] ] treeReturnStatement:[ LeafReserved:return treeCondExpr:[ treeInfixExpr:[ treeInfixExpr:[ LeafName:value Leaf:* Leaf:4.0f ] Leaf:< Leaf:10.0f ]

C C C C

Leaf:? Leaf:0 Leaf:: Leaf:1 ] Leaf:; ] ] Leaf:} }] ]

, -

, , XML.

: Parser, Ptree, Leaf, NonLeaf, Encoding, TypeInfo, Typeof, PtreeUtil.

5)
( , , , . Walker ClassWalker , , ClassBodyWalker. VivaCore, . , , :
Ptree* ClassWalker::TranslateUnary(Ptree* exp) { using namespace PtreeUtil;

[6])

Walker, ClassWalker, ClassBodyWalker. , ,

/ Walker ++.

++. ,

Ptree* unaryop = exp ->Car(); Ptree* right = PtreeUtil::Second(exp); Ptree* right2 = Translate(right); if(right == right2) return exp; else return new (GC_QuickAlloc) PtreeUnaryExpr(unaryop, PtreeUtil::List(right2)); }

, ,

, ( . . )

, .

, PtreeUnaryExpr. exp->Car(), PtreeUtil::Second(exp), . right2. . , , . , ,

, TranslateUnary. .

, PtreeUnaryExpr,

, , ClassWalker ClassBodyWalker. , Viva64, "throw":

Ptree* VivaWalker::TranslateThrow(Ptree *p) { Ptree *result = ClassWalker::TranslateThrow(p); Ptree* oprnd = PtreeUtil::Second(result); if (oprnd != NULL) { //if oprnd==NULL then this is "throw;". if (!CreateWiseType(oprnd)) {

return result; } if (IsErrorActive(115) && !ApplyRuleN10(oprnd ->m_wiseType.m_simpleType)) { AddError(VivaErrors::V115(), p, 115); } } return result; }

ClassWalker::TranslateThrow(p) . , . Environment, declTypeInfo:


TypeInfo declTypeInfo; if (env->Lookup(decl, declTypeInfo)) { ... }

. . Environment,

env

. : AbstractTranslatingWalker, Walker, ClassWalker, ClassBodyWalker, Class, Environment, Bind, Class, TemplateClass.

6)
, , . ( , . , , . . , , ). ,

++. VivaCore

++

. / ++.

OpenC++. . : Metaclass.

7)
, VivaCore. . , , XML, . XML . XML XML VivaCore . , XML . , C# . , , SGML. , . . , , ,

, VivaCore, Viva64.com . , VivaCore. ! ,

1. . Viva64 ? http://viva64.com/art-1-1-2081052208.html 2. OpenC++ library. http://www.viva64.com/go.php?url=16 3. Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools (2nd Edition). Addison Wesley, 2006, 1000 pages. 4. Flemming Nielson, Hanne R. Nielson, Chris Hankin. Principles of Program Analysis. Springer, 2004, 452 pages. 5. Semantic Designs site. http://www.viva64.com/go.php?url=19 6. Patrick Cousot. Static Analysis. Springer, 2001, 450 pages.

Вам также может понравиться