oplbacke.h
来自「在手机操作系统symbina上使用的一个脚本扩展语言的代码实现,可以参考用于自己」· C头文件 代码 · 共 582 行 · 第 1/2 页
H
582 行
// OPLBACKE.H
//
// Copyright (c) 1997-1999 Symbian Ltd. All rights reserved.
//
// Classes needed to produce an OPL translator back end
#ifndef __OPLBACKE_H__
#define __OPLBACKE_H__
#include <e32base.h>
#include <s32mem.h>
#include <texttran.h>
#include <opltdef.h>
#include <opltoken.h>
//////////////////////////////////////////////////////////////
//
// COplSymbol - A symbol table entry. References are made to
// to these within the PCODE, which is why they appear here.
//
//////////////////////////////////////////////////////////////
class COplSymbol : public CBase
{
public:
enum TClass
{
EConstant,
ELabel,
EGlobal,
ELocal,
EArgument,
EExternalDecl,
EOpxFunction,
EProcDecl,
EExternalRef,
EProcRef
};
virtual const TDesC& Name() const =0;
virtual TOplToken Token() const =0;
virtual TOplToken::TType Type() const =0;
inline COplSymbol::TClass Class() const;
inline void SetAddress(TUint anAddress);
inline TUint Address() const;
inline void ExternalizeL(RWriteStream& aStream) const;
protected:
COplSymbol::COplSymbol(COplSymbol::TClass aClass);
protected:
TClass iClass;
TUint iAddress;
private: // Stuff that enables it to be put in the symbol table.
friend class COplSymbolTable;
TInt iScope;
TSglQueLink iScopeLink;
TDblQueLink iHashLink;
};
///////////////////////////////////////////////////////////////////////
//
// Root of the 'real' symbols tree. A symbol of this class has a declaration
// (implicit or explicit) somewhere in the code.
//
///////////////////////////////////////////////////////////////////////
class COplReferenceSymbol;
class COplDeclarationSymbol : public COplSymbol
{
public:
static COplDeclarationSymbol *NewLC(COplSymbol::TClass, TOplToken aToken, TOplToken::TType aType,const TDesC& aName);
COplReferenceSymbol *NewReferenceLC();
const TDesC& Name() const;
TOplToken Token() const;
TOplToken::TType Type() const;
inline void SetToken(TOplToken aToken);
inline void SetType(TOplToken::TType aType);
~COplDeclarationSymbol();
protected:
COplDeclarationSymbol(COplSymbol::TClass aClass, TOplToken aToken,TOplToken::TType aType);
void ConstructL(const TDesC& aName);
protected:
HBufC *iName;
TOplToken iToken;
TOplToken::TType iType;
};
/////////////////////////////////////////////////////////////
//
// COplReferenceSymbol - a reference to a symbol which might be
// implicitly defined
//
/////////////////////////////////////////////////////////////
class COplReferenceSymbol : public COplSymbol
{
public:
const TDesC& Name() const;
TOplToken Token() const;
TOplToken::TType Type() const;
inline COplDeclarationSymbol& Declaration() const;
private:
friend class COplDeclarationSymbol;
COplReferenceSymbol(COplSymbol::TClass aClass, COplDeclarationSymbol& aSymbol);
private:
COplReferenceSymbol& operator=(COplReferenceSymbol&); // Stop the compiler whinging
private:
COplDeclarationSymbol& iDeclaration;
};
///////////////////////////////////////////////////////////
//
// COplAutomaticSymbol- Things declared on the local stack,
// i.e. LOCAL & GLOBAL
//
///////////////////////////////////////////////////////////
class COplAutomaticSymbol : public COplDeclarationSymbol
{
public:
inline TInt StringLength();
inline TInt ArraySize();
inline void SetStringLen(TInt aLength);
inline void SetArraySize(TInt aSize);
private:
friend class COplDeclarationSymbol;
inline COplAutomaticSymbol(TClass aClass, TOplToken aToken,TOplToken::TType aType);
private:
TInt iArraySize;
TInt iStringLength;
};
///////////////////////////////////////////////////////////
//
// TOpxAddress Converts a UINT to and OPX address and
// vice versa
//
///////////////////////////////////////////////////////////
class TOpxAddress
{
public:
inline TOpxAddress(TUint aModule,TUint aFunction);
inline TOpxAddress(TUint anAddress);
inline operator TUint() const;
inline TUint Module() const;
inline TUint Function() const;
private:
TUint iModule;
TUint iFunction;
};
///////////////////////////////////////////////////////////
//
// Something which is callable, i.e. it has an associated
// Argument signature
//
///////////////////////////////////////////////////////////
class COplCallSymbol : public COplDeclarationSymbol
{
public:
inline TOplSignature& Signature();
private:
friend class COplDeclarationSymbol;
inline COplCallSymbol(TClass aClass, TOplToken aToken,TOplToken::TType aType);
private:
TOplSignature iSignature;
};
//////////////////////////////////////////////////////////
//
// A Constant define.
//
//////////////////////////////////////////////////////////
class COplConstantSymbol : public COplDeclarationSymbol
{
public:
~COplConstantSymbol();
inline TOplConstant& Value();
private:
friend class COplDeclarationSymbol;
inline COplConstantSymbol(TClass aClass, TOplToken aToken,TOplToken::TType aType);
private:
TOplConstant iValue;
};
///////////////////////////////////////////////////////////////
//
// TLabelReference - a refernce to a label. It has position in a stream
// and it has a base from which to calculate the relative distance to teh label
//
////////////////////////////////////////////////////////////////
class TLabelReference
{
public:
inline TLabelReference(TStreamPos aPos, TInt aBase) : iPos(aPos), iBase(aBase) {}
inline TStreamPos Position() const { return iPos;}
inline TInt Base() const { return iBase;}
private:
TStreamPos iPos;
TInt iBase;
};
//////////////////////////////////////////////////////////////
//
// A Label symbol
//
//////////////////////////////////////////////////////////////
const TUint KOplLabelReferenceGran=8;
class COplLabelSymbol : public COplDeclarationSymbol
{
public:
inline void Define();
inline TBool IsDefined() const;
inline void AddReferenceL(const TLabelReference& aReference);
inline const CArrayFixFlat<TLabelReference>& References() const;
private:
friend class COplDeclarationSymbol;
COplLabelSymbol(TClass aClass, TOplToken aToken, TOplToken::TType aType);
private:
TBool isDefined;
CArrayFixFlat<TLabelReference> iReferences;
};
////////////////////////////////////////////
//
// COplParseApp - base class for an app
//
////////////////////////////////////////////
class COplModuleLexer;
class COpl16ModuleBackEnd;
class COplParseApp : public CBase
{
public:
virtual void ParseL(COpl16ModuleBackEnd& aBackEnd,TBool aLocatingError)=0;
};
////////////////////////////////////////////
//
// COplParseOpx - Declaration of an OPX
//
////////////////////////////////////////////
const TInt KOplParseOpxFunctionGran=8;
class COplParseOpx : public CBase
{
public:
static COplParseOpx *NewLC();
~COplParseOpx();
void SetNameL(const TDesC& aName);
inline const TDesC& Name() const;
inline void SetUid(TUid aUid);
inline TUid Uid() const;
inline void SetVersion(TUint aVersion);
inline TUint Version() const;
private:
COplParseOpx();
private:
HBufC *iName;
TUid iUid;
TUint iVersion;
};
////////////////////////////////////////////
//
// COplProcHeader - Internal model of a Procedure header
//
////////////////////////////////////////////
const TInt KOplParseProcArrayGran=8;
class COplProcHeader : public CBase
{
public:
inline TOplToken::TType Type();
inline const CArrayFix<COplSymbol*>& Arguments() const;
inline const CArrayFix<COplSymbol*>& Externals() const;
inline const CArrayFix<COplSymbol*>& Globals() const;
inline const CArrayFix<COplSymbol*>& Locals() const;
inline const CArrayFix<COplSymbol*>& ProcCalls() const;
inline const CArrayFix<COplSymbol*>& Labels() const;
private:
friend class COplModuleParser;
static COplProcHeader *NewLC(TOplToken::TType aType);
void AddSymbolL(COplSymbol& pSym);
private:
COplProcHeader(TOplToken::TType aType);
private:
TOplToken::TType iType; // Return type of the procedure
CArrayFixFlat<COplSymbol*> iArguments; // The arguments to the procedure
CArrayFixFlat<COplSymbol*> iExternals; // Externals erferences by the procedure
CArrayFixFlat<COplSymbol*> iGlobals; // Globals declared within the prpocedure
CArrayFixFlat<COplSymbol*> iLocals; // Locals declared within this procedure
CArrayFixFlat<COplSymbol*> iProcCalls; // Procedures called within this procedure
CArrayFixFlat<COplSymbol*> iLabels; // Labels within the Qcode
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?