📄 trans.h
字号:
* tp->smin => EK_NAME of declared type name of return value, else NULL. * * TK_PROCPTR: Procedure pointer with static link. * tp->basetype => TK_FUNCTION type. * tp->fbase => Internal Meaning struct associated with basetype. * tp->escale = Value of StaticLinks when type was declared. * * TK_CPROCPTR: Procedure pointer without static link. * tp->basetype => TK_FUNCTION type. * tp->fbase => Internal Meaning struct associated with basetype. * tp->escale = Value of StaticLinks = 0. * * TK_SPECIAL: Special strange data type. * Only TK_SPECIAL type at present is tp_jmp_buf. * */enum typekind { TK_NONE, TK_INTEGER, TK_CHAR, TK_BOOLEAN, TK_REAL, TK_VOID, TK_SUBR, TK_ENUM, TK_POINTER, TK_STRING, TK_RECORD, TK_ARRAY, TK_SET, TK_FILE, TK_FUNCTION, TK_PROCPTR, TK_SMALLSET, TK_SMALLARRAY, TK_CPROCPTR, TK_SPECIAL, TK_BIGFILE, TK_LAST} ;#ifdef DEFDUMPSchar *typekindnames[(int)TK_LAST] = { "TK_NONE", "TK_INTEGER", "TK_CHAR", "TK_BOOLEAN", "TK_REAL", "TK_VOID", "TK_SUBR", "TK_ENUM", "TK_POINTER", "TK_STRING", "TK_RECORD", "TK_ARRAY", "TK_SET", "TK_FILE", "TK_FUNCTION", "TK_PROCPTR", "TK_SMALLSET", "TK_SMALLARRAY", "TK_CPROCPTR", "TK_SPECIAL", "TK_BIGFILE"} ;#endif /*DEFDUMPS*/typedef struct S_type { enum typekind kind; /* Kind of type */ struct S_type *basetype; /* (above) */ struct S_type *indextype; /* (above) */ struct S_type *pointertype; /* Pointer to this type */ struct S_meaning *meaning; /* Name of this type, if any */ struct S_meaning *fbase; /* (above) */ struct S_expr *smin; /* (above) */ struct S_expr *smax; /* (above) */ unsigned issigned:1, /* (above) */ dumped:1, /* Has been dumped (for debugging) */ structdefd:1, /* (above) */ preserved:1; /* Declared with preservetypes = 1 */ short escale; /* (above) */} Type;/* "Expr" notes: * * Expression trees generally reflect C notation and semantics. For example, * EK_ASSIGN is not generated for string arguments; these would get an * EK_BICALL to strcpy instead. * * The data type of each expression node is stored in its "val.type" field. * The rest of the "val" field is used only when shown below. * The "nargs" field always contains the number of arguments; the "args" * array is allocated to that size and will contain non-NULL Expr pointers. * * EK_EQ, EK_NE, EK_LT, EK_GT, EK_LE, EK_GE: Relational operators. * ep->nargs = 2. * * EK_PLUS: Addition. * ep->nargs >= 2. * * EK_NEG: Negation. * ep->nargs = 1. * * EK_TIMES: Multiplication. * ep->nargs >= 2. * * EK_DIVIDE: Real division. * ep->nargs = 2. * * EK_DIV: Integer division. * ep->nargs = 2. * * EK_MOD: Integer modulo (C "%" operator). * ep->nargs = 2. * * EK_OR, EK_AND: Logical operators (C "&&" and "||"). * ep->nargs = 2. * * EK_NOT: Logical NOT (C "!" operator). * ep->nargs = 1. * * EK_BAND, EK_BOR, EK_BXOR: Bitwise operators (C "&", "|", "^"). * ep->nargs = 2. * * EK_BNOT: Bitwise NOT (C "~" operator). * ep->nargs = 1. * * EK_LSH, EK_RSH: Shift operators. * ep->nargs = 2. * * EK_HAT: Pointer dereference. * ep->nargs = 1. * * EK_INDEX: Array indexing. * ep->nargs = 2. * * EK_CAST: "Soft" type cast, change data type retaining value. * ep->type => New data type. * ep->nargs = 1. * * EK_ACTCAST: "Active" type cast, performs a computation as result of cast. * ep->type => New data type. * ep->nargs = 1. * * EK_LITCAST: Literal type cast. * ep->nargs = 2. * ep->args[0] => EK_TYPENAME expression for name of new data type. * ep->args[1] => Argument of cast. * * EK_DOT: Struct field extraction. * ep->nargs = 1. (Only one of the following will be nonzero:) * ep->val.i => MK_FIELD being extracted (cast to Meaning *), else 0. * ep->val.s => Literal name of field being extracted, else NULL. * * EK_COND: C conditional expression. * ep->nargs = 3. * ep->args[0] => Condition expression. * ep->args[1] => "Then" expression. * ep->args[2] => "Else" expression. * * EK_ADDR: Address-of operator. * ep->nargs = 1. * * EK_SIZEOF: Size-of operator. * ep->nargs = 1. * ep->args[0] => Argument expression, may be EK_TYPENAME. * * EK_CONST: Literal constant. * ep->nargs = 0 or 1. * ep->val = Value of constant. * ep->args[0] => EK_NAME of printf format string for constant, if any. * * EK_LONGCONST: Literal constant, type "long int". * (Same as for EK_CONST.) * * EK_VAR: Variable name. * ep->nargs = 0. * ep->val.i => Variable being referenced (cast to Meaning *). * * EK_ASSIGN: Assignment operator. * ep->nargs = 2. * ep->args[0] => Destination l-value expression. * ep->args[1] => Source expression. * * EK_POSTINC, EK_POSTDEC: Post-increment/post-decrement operators. * ep->nargs = 1. * * EK_MACARG: Placeholder for argument in expression for FuncMacro, etc. * ep->nargs = 0. * ep->val.i = Code selecting which argument. * * EK_CHECKNIL: Null-pointer check. * ep->nargs = 1. * * EK_BICALL: Call to literal function name. * ep->val.s => Name of function. * * EK_STRUCTCONST: Structured constant. * ep->nargs = Number of elements in constant. * (Note: constdefn points to an EK_CONST whose val.i points to this.) * * EK_STRUCTOF: Repeated element in structured constant. * ep->nargs = 1. * ep->val.i = Number of repetitions. * * EK_COMMA: C comma operator. * ep->nargs >= 2. * * EK_NAME: Literal variable name. * ep->nargs = 0. * ep->val.s => Name of variable. * * EK_CTX: Name of a context, with static links. * ep->nargs = 0. * ep->val.i => MK_FUNCTION or MK_MODULE to name (cast to Meaning *). * * EK_SPCALL: Special function call. * ep->nargs = 1 + number of arguments to function. * ep->args[0] => Expression which is the function to call. * ep->val.i = 1 if force non-starfunctions, 0 if not. * * EK_TYPENAME: Type name. * ep->nargs = 0. * ep->val.type => Type whose name should be printed. * * EK_FUNCTION: Normal function call. * ep->val.i => MK_FUNCTION being called (cast to Meaning *). * * EK_NEW: C++ "new" operator. * ep->nargs = 1 or 2. * ep->args[0] => EK_TYPENAME for type to allocated. * ep->args[1] => Array bound. * * EK_DELETE: C++ "delete" operator. * ep->nargs = 1. * ep->args[0] => Variable to be freed. * */enum exprkind { EK_EQ, EK_NE, EK_LT, EK_GT, EK_LE, EK_GE, EK_PLUS, EK_NEG, EK_TIMES, EK_DIVIDE, EK_DIV, EK_MOD, EK_OR, EK_AND, EK_NOT, EK_BAND, EK_BOR, EK_BXOR, EK_BNOT, EK_LSH, EK_RSH, EK_HAT, EK_INDEX, EK_CAST, EK_DOT, EK_COND, EK_ADDR, EK_SIZEOF, EK_ACTCAST, EK_CONST, EK_VAR, EK_FUNCTION, EK_ASSIGN, EK_POSTINC, EK_POSTDEC, EK_CHECKNIL, EK_MACARG, EK_BICALL, EK_STRUCTCONST, EK_STRUCTOF, EK_COMMA, EK_LONGCONST, EK_NAME, EK_CTX, EK_SPCALL, EK_LITCAST, EK_TYPENAME, EK_NEW, EK_DELETE, EK_LAST} ;#ifdef DEFDUMPSchar *exprkindnames[(int)EK_LAST] = { "EK_EQ", "EK_NE", "EK_LT", "EK_GT", "EK_LE", "EK_GE", "EK_PLUS", "EK_NEG", "EK_TIMES", "EK_DIVIDE", "EK_DIV", "EK_MOD", "EK_OR", "EK_AND", "EK_NOT", "EK_BAND", "EK_BOR", "EK_BXOR", "EK_BNOT", "EK_LSH", "EK_RSH", "EK_HAT", "EK_INDEX", "EK_CAST", "EK_DOT", "EK_COND", "EK_ADDR", "EK_SIZEOF", "EK_ACTCAST", "EK_CONST", "EK_VAR", "EK_FUNCTION", "EK_ASSIGN", "EK_POSTINC", "EK_POSTDEC", "EK_CHECKNIL", "EK_MACARG", "EK_BICALL", "EK_STRUCTCONST", "EK_STRUCTOF", "EK_COMMA", "EK_LONGCONST", "EK_NAME", "EK_CTX", "EK_SPCALL", "EK_LITCAST", "EK_TYPENAME", "EK_NEW", "EK_DELETE"} ;#endif /*DEFDUMPS*/typedef struct S_expr { enum exprkind kind; short nargs; Value val; struct S_expr *args[1]; /* (Actually, variable-sized) */} Expr;/* "Stmt" notes. * * Statements form linked lists along the "next" pointers. * All other pointers are NULL and unused unless shown below. * * SK_ASSIGN: Assignment or function call (C expression statement). * sp->exp1 => Expression to be evaluated. * sp->doinit = 1 if an EK_ASSIGN which should declare its lhs variable. * * SK_RETURN: C "return" statement. * sp->exp1 => Value to return, else NULL. * * SK_CASE: C "switch" statement. * sp->exp1 => Switch selector expression. * sp->stm1 => List of SK_CASELABEL statements, followed by list of * statements that make up the "default:" clause. * * SK_CASELABEL: C "case" label. * sp->exp1 => Case value. * sp->stm1 => List of SK_CASELABELs labelling the same clause, followed * by list of statements in that clause. * * SK_CASECHECK: Case-value-range-error, occurs in "default:" clause. * * SK_IF: C "if" statement. * sp->exp1 => Conditional expression. * sp->exp2 => Constant expression, "1" if this "if" should be else-if'd * on to parent "if". NULL => follow ElseIf parameter. * sp->stm1 => "Then" clause. * sp->stm2 => "Else" clause. * * SK_FOR: C "for" statement. * sp->exp1 => Initialization expression (may be NULL). * sp->exp2 => Conditional expression (may be NULL). * sp->exp3 => Iteration expression (may be NULL). * sp->stm1 => Loop body. * sp->doinit = 1 if exp1 should be written as a declaration. * * SK_REPEAT: C "do-while" statement. * sp->exp1 => Conditional expression (True = continue loop). * sp->stm1 => Loop body. * * SK_WHILE: C "while" statement. * sp->exp1 => Conditional expression. * sp->stm1 => Loop body. * * SK_BREAK: C "break" statement. * * SK_CONTINUE: C "continue" statement. * * SK_TRY: HP Pascal TRY-RECOVER statement. * sp->exp1->val.i = Global serial number of the TRY statement. * sp->exp2 = Non-NULL if must generate a label for RECOVER block. * sp->stm1 => TRY block. * sp->stm2 => RECOVER block. * * SK_GOTO: C "goto" statement.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -