⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 support.h

📁 cg编译器
💻 H
📖 第 1 页 / 共 2 页
字号:
    decl *params;       // Actual paramaters to function declaration
    expr *initexpr;     // Initializer
};

typedef struct exprhead_rec {
    nodekind kind;
    Type *type;
    int IsLValue;
    int IsConst;
    int HasSideEffects;
    void *tempptr[4];  // Used by backends
} exprhead;

struct symb_rec {
    nodekind kind;
    Type *type;
    int IsLValue;
    int IsConst;
    int HasSideEffects;
    void *tempptr[4];
    opcode op;
    Symbol *symbol;
};

typedef union scalar_constant_rec {
    float f;
    int i;
} scalar_constant;

typedef struct constant_rec {
    nodekind kind;
    Type *type;
    int IsLValue;
    int IsConst;
    int HasSideEffects;
    void *tempptr[4];
    opcode op;
    int subop;
    scalar_constant val[4];
} constant;

typedef struct unary_rec {
    nodekind kind;
    Type *type;
    int IsLValue;
    int IsConst;
    int HasSideEffects;
    void *tempptr[4];
    opcode op;
    int subop;
    expr *arg;
} unary;

typedef struct binary_rec {
    nodekind kind;
    Type *type;
    int IsLValue;
    int IsConst;
    int HasSideEffects;
    void *tempptr[4];
    opcode op;
    int subop;
    expr *left, *right;
} binary;

typedef struct trinary_rec {
    nodekind kind;
    Type *type;
    int IsLValue;
    int IsConst;
    int HasSideEffects;
    void *tempptr[4];
    opcode op;
    int subop;
    expr *arg1, *arg2, *arg3;
} trinary;

union expr_rec {
    exprhead common;
    symb sym;
    constant co;
    unary un;
    binary bin;
    trinary tri;
};


typedef struct common_stmt_rec {
    stmtkind kind;
    stmt *next;
    SourceLoc loc;
} common_stmt;

typedef struct expr_stmt_rec {
    stmtkind kind;
    stmt *next;
    SourceLoc loc;
    expr *exp;
} expr_stmt;

typedef struct if_stmt_rec {
    stmtkind kind;
    stmt *next;
    SourceLoc loc;
    expr *cond;
    stmt *thenstmt;
    stmt *elsestmt;
} if_stmt;

typedef struct while_stmt_rec {
    stmtkind kind;
    stmt *next;
    SourceLoc loc;
    expr *cond;
    stmt *body;
} while_stmt;

typedef struct for_stmt_rec {
    stmtkind kind;
    stmt *next;
    SourceLoc loc;
    stmt *init;
    expr *cond;
    stmt *step;
    stmt *body;
} for_stmt;

typedef struct block_stmt_rec {
    stmtkind kind;
    stmt *next;
    SourceLoc loc;
    stmt *body;
} block_stmt;

typedef struct return_stmt_rec {
    stmtkind kind;
    stmt *next;
    SourceLoc loc;
    expr *exp;
} return_stmt;

typedef struct discard_stmt_rec {
    stmtkind kind;
    stmt *next;
    SourceLoc loc;
    expr *cond;
} discard_stmt;

typedef struct comment_stmt_rec {
    stmtkind kind;
    stmt *next;
    SourceLoc loc;
    int str;
} comment_stmt;

union stmt_rec {
    common_stmt commonst;
    expr_stmt exprst;
    if_stmt ifst;
    while_stmt whilest;
    for_stmt forst;
    block_stmt blockst;
    return_stmt returnst;
    discard_stmt discardst;
    comment_stmt commentst;
};

extern dtype CurrentDeclTypeSpecs;

decl *NewDeclNode(SourceLoc *loc, int atom, dtype *type);
symb *NewSymbNode(opcode op, Symbol *fSymb);
constant *NewIConstNode(opcode op, int fval, int base);
constant *NewBConstNode(opcode op, int fval, int base);
constant *NewFConstNode(opcode op, float fval, int base);
constant *NewFConstNodeV(opcode op, float *fval, int len, int base);
unary *NewUnopNode(opcode op, expr *arg);
unary *NewUnopSubNode(opcode op, int subop, expr *arg);
binary *NewBinopNode(opcode op, expr *left, expr *right);
binary *NewBinopSubNode(opcode op, int subop, expr *left, expr *right);
trinary *NewTriopNode(opcode op, expr *arg1, expr *arg2, expr *arg3);
trinary *NewTriopSubNode(opcode op, int subop, expr *arg1, expr *arg2, expr *arg3);

symb *DupSymbNode(const symb *fSymb);
constant *DupConstNode(const constant *fconst);
unary *DupUnaryNode(const unary *fun);
binary *DupBinaryNode(const binary *fbin);
trinary *DupTrinaryNode(const trinary *ftri);
expr *DupNode(const expr *fExpr);

expr_stmt *NewExprStmt(SourceLoc *loc, expr *fExpr);
if_stmt *NewIfStmt(SourceLoc *loc, expr *fExpr, stmt *thenStmt, stmt *elseStmt);
if_stmt *SetThenElseStmts(SourceLoc *loc, stmt *ifStmt, stmt *thenStmt, stmt *elseStmt);
while_stmt *NewWhileStmt(SourceLoc *loc, stmtkind kind, expr *fExpr, stmt *body);
for_stmt *NewForStmt(SourceLoc *loc, stmt *fExpr1, expr *fExpr2, stmt *fExpr3, stmt *body);
block_stmt *NewBlockStmt(SourceLoc *loc, stmt *fStmt);
return_stmt *NewReturnStmt(SourceLoc *loc, Scope *fScope, expr *fExpr);
discard_stmt *NewDiscardStmt(SourceLoc *loc, expr *fExpr);
comment_stmt *NewCommentStmt(SourceLoc *loc, const char *str);

/************************************* dtype functions: *************************************/

Type *GetTypePointer(SourceLoc *loc, const dtype *fDtype);
dtype *SetDType(dtype *fDtype, Type *fType);
dtype *NewDType(dtype *fDtype, Type *baseType, int category);

int SetTypeCategory(SourceLoc *loc, int atom, dtype *fType, int category, int Force);
int SetTypeQualifiers(SourceLoc *loc, dtype *fType, int qualifiers);
int SetTypeDomain(SourceLoc *loc, dtype *fType, int domain);
int SetTypeMisc(SourceLoc *loc, dtype *fType, int misc);
int SetTypePacked(SourceLoc *loc, dtype *fType);
int SetStorageClass(SourceLoc *loc, dtype *fType, int storage);

/********************************** Parser Semantic Rules: ***********************************/

expr *Initializer(SourceLoc *loc, expr *fExpr);
expr *InitializerList(SourceLoc *loc, expr *list, expr *fExpr);
expr *ArgumentList(SourceLoc *loc, expr *flist, expr *fExpr);
expr *ExpressionList(SourceLoc *loc, expr *flist, expr *fExpr);
decl *AddDecl(decl *first, decl *last);
stmt *AddStmt(stmt *first, stmt *last);
stmt *CheckStmt(stmt *fStmt);
decl *Function_Definition_Header(SourceLoc *loc, struct decl_rec *fDecl);
decl *Param_Init_Declarator(SourceLoc *loc, Scope *fScope, decl *fDecl, expr *fExpr);
stmt *Init_Declarator(SourceLoc *loc, Scope *fScope, decl *fDecl, expr *fExpr);
decl *Declarator(SourceLoc *loc, struct decl_rec *fDecl, int semantics);
decl *Array_Declarator(SourceLoc *loc, decl *fDecl, int size, int Empty);

Symbol *AddFormalParamDecls(Scope *fScope, decl *params);
decl *SetFunTypeParams(Scope *fScope, decl *func, decl *params, decl *actuals);
decl *FunctionDeclHeader(SourceLoc *loc, Scope *fScope, decl *func);

Type *StructHeader(SourceLoc *loc, Scope *fScope, int ctype, int tag);

Symbol *DefineVar(SourceLoc *loc, Scope *fScope, int atom, Type *fType);
Symbol *DefineTypedef(SourceLoc *loc, Scope *fScope, int atom, Type *fType);
Symbol *DeclareFunc(SourceLoc *loc, Scope *fScope, Symbol *fSymb, int atom, Type *fType,
                Scope *locals, Symbol *params);

void DefineFunction(SourceLoc *loc, Scope *fScope, struct decl_rec *func, union stmt_rec *body);
int GlobalInitStatements(Scope *fScope, union stmt_rec *fStmt);

expr *BasicVariable(SourceLoc *loc, int name);

int IsLValue(const expr *fExpr);
int IsConst(const expr *fExpr);
int IsArrayIndex(const expr *fExpr);
int ConvertType(expr *fExpr, Type *toType, Type *fromType, expr **result, int IgnorePacked,
                int Explicit);
expr *CastScalarVectorMatrix(expr *fExpr, int fbase, int tbase, int len, int len2);
int ConvertNumericOperands(int baseop, expr **lexpr, expr **rexpr, int lbase, int rbase,
                           int llen, int rlen, int llen2, int rlen2);
expr *CheckBooleanExpr(SourceLoc *loc, expr *fExpr, int AllowVector);

expr *NewUnaryOperator(SourceLoc *loc, int fop, int name, expr *fExpr, int IntegralOnly);
expr *NewBinaryOperator(SourceLoc *loc, int fop, int name, expr *lExpr, expr *rExpr,
                        int IntegralOnly);
expr *NewBinaryBooleanOperator(SourceLoc *loc, int fop, int name, expr *lExpr, expr *rExpr);
expr *NewBinaryComparisonOperator(SourceLoc *loc, int fop, int name, expr *lExpr, expr *rExpr);
expr *NewConditionalOperator(SourceLoc *loc, expr *bExpr, expr *lExpr, expr *rExpr);
expr *NewSwizzleOperator(SourceLoc *loc, expr *fExpr, int ident);
expr *NewMatrixSwizzleOperator(SourceLoc *loc, expr *fExpr, int ident);
expr *NewVectorConstructor(SourceLoc *loc, Type *fType, expr *fExpr);
expr *NewCastOperator(SourceLoc *loc, expr *fExpr, Type *toType);
expr *NewMemberSelectorOrSwizzleOrWriteMaskOperator(SourceLoc *loc, expr *fExpr, int ident);
expr *NewIndexOperator(SourceLoc *loc, expr *fExpr, expr *ixExpr);
expr *NewFunctionCallOperator(SourceLoc *loc, expr *funExpr, expr *actuals);

expr *NewSimpleAssignment(SourceLoc *loc, expr *fvar, expr *fExpr, int InInit);
stmt *NewSimpleAssignmentStmt(SourceLoc *loc, expr *fvar, expr *fExpr, int InInit);
stmt *NewCompoundAssignmentStmt(SourceLoc *loc, opcode op, expr *fvar, expr *fExpr);
/***
stmt *NewMaskedAssignment(SourceLoc *loc, int mask, expr *fExpr, stmt *fStmt);
stmt *NewConditionalAssignment(SourceLoc *loc, expr *fCond, expr *fExpr, stmt *fStmt);
***/

/********************************** Traversal Routeins: ******************************************/

expr *ApplyToNodes(expr *(*pre)(expr *, void *, int), expr *(*post)(expr *, void *, int),
                expr *fExpr, void *arg1, int arg2);
#define PreApplyToNodes(F, E, A1, A2) ApplyToNodes(F, 0, E, A1, A2)
#define PostApplyToNodes(F, E, A1, A2) ApplyToNodes(0, F, E, A1, A2)

void ApplyToExpressions(expr *(*pre)(expr *, void *, int), expr *(*post)(expr *, void *, int),
                stmt *fStmt, void *arg1, int arg2);
#define PreApplyToExpressions(F, E, A1, A2) ApplyToExpressions(F, 0, E, A1, A2)
#define PostApplyToExpressions(F, E, A1, A2) ApplyToExpressions(0, F, E, A1, A2)

void ApplyToExpressionsLocal(expr *(*pre)(expr *, void *, int), expr *(*post)(expr *, void *, int),
                stmt *fStmt, void *arg1, int arg2);
#define PreApplyToExpressionsLocal(F, E, A1, A2) ApplyToExpressionsLocal(F, 0, E, A1, A2)
#define PostApplyToExpressionsLocal(F, E, A1, A2) ApplyToExpressionsLocal(0, F, E, A1, A2)

void ApplyToTopExpressions(expr *(*fun)(expr *, void *, int), stmt *fStmt, void *arg1, int arg2);

stmt *ApplyToStatements(stmt *(*pre)(stmt *, void *, int), stmt *(*post)(stmt *, void *, int),
                stmt *fStmt, void *arg1, int arg2);
#define PreApplyToStatements(F, E, A1, A2) ApplyToStatements(F, 0, E, A1, A2)
#define PostApplyToStatements(F, E, A1, A2) ApplyToStatements(0, F, E, A1, A2)

void PostApplyToChildStatements(stmt *(*fun)(stmt *, void *, int), stmt *fStmt, void *arg1,
                int arg2);

/************************************** misc: ************************************************/
void InitTempptr(expr *e, void *arg1, int arg2);
/********************************** Error checking: ******************************************/

void RecordErrorPos(SourceLoc *loc);
void MarkErrorPosHit(SourceLoc *loc);
void CheckAllErrorsGenerated(void);

typedef struct ErrorLocRec
{
  // The source location at which the error token was encountered.
  SourceLoc loc;
  // 1 iff an error was found on this line or before this line after
  // the previous error token.
  int hit;
  struct ErrorLocRec * next;
} ErrorLoc;

// Beginning and end of list of error locations, sorted by line.
extern ErrorLoc * ErrorLocsFirst;
extern ErrorLoc * ErrorLocsLast;

#endif // !defined(__SUPPORT_H)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -