/* * EXPORT.H * * (c)Copyright 1993-2014, Matthew Dillon, All Rights Reserved. See the * COPYRIGHT file at the base of the distribution. */ /* * Headers needed by others using this library */ #include #include #include #include "lex.h" #include "sym.h" #include "type.h" #include "decl.h" #include "exp.h" #include "stmt.h" #include "parse.h" #include "insn.h" #include "context.h" /* * debug_lex.c */ void LexDebugLine(token_t *tok); /* * decl.c */ Declaration *FindDeclId(SemGroup *db, string_t id, int *eno); Declaration *FindDeclIdLevel(SemGroup *db, string_t id, int level, int *eno); Declaration *FindDeclByIndex(SemGroup *sg, int index); void DeclPrintError(Declaration *d, int type); Declaration *FindDeclPath(LexRef *lexRef, SemGroup *osg, SemGroup *sg, Type *nomatch, string_t *ary, int mask, int *visibility, int level, int *eno); Declaration *FindDeclPathAltContext(LexRef *lexRef, SemGroup *osg, SemGroup *sg, Type *nomatch, string_t *ary, int mask, int *visibility, int level, int *eno); void *FindDLLSymbol(SemGroup *osg, SemGroup *sg, string_t id); int DeclarationCacheable(Declaration *d); /* * exp.c */ void ExpPrintError(Exp *exp, int type); int64_t resolveGetConstExpInt64(Exp *exp); float128_t resolveGetConstExpFloat128(Exp *exp); /* * lex.c */ Lex *LexOpen(const char *path, token_t *tok); void LexClose(Lex **plex); int LexRedactToken(token_t *tok, int bytes); int LexPeekToken(token_t *tok); int LexToken(token_t *tok); int LexSkipToken(token_t *tok, int type); int LexStripQuotes(token_t *tok, token_t *tmp); int LexError(token_t *tok, int err); void LexPrintError(token_t *tok); void LexPrintRef(LexRef *lr, int type); void LexInitRef(LexRef *lr, token_t *tok); void LexDupRef(LexRef *s, LexRef *d); void LexDoneRef(LexRef *lr); const char *LexErrStr(token_t *tok); /* * misc.c */ void LibRuneInit(void); /* * heap.c */ void *heapAlloc(PointerStor *ps, Type *type); /* * parse.c */ int ParseOpen(Stmt *st, Parse **pp, void **dll); void ParseDone(Parse *p); void ParseClose(Parse **pp); void AddImportPath(const char *path, int flags); void PrefixImportPaths(const char *basePath); /* * parse1.c */ int ParseModule(Parse *p, Stmt *st, int t); int ParseStmt(Parse *p, int t, Stmt **pst); int ParseDeclarationStmt(Parse *p, int t, int idRequired, Stmt **pst, int dop, Scope *scope); /* * parse2.c */ int ParseScopeQual(Parse *p, int t, Scope *scope); int ParseStorageQual(Parse *p, int t, int *pmask); int ParseDeclaration(Parse *p, int t, Declaration **pd, int idRequired, int dop, Scope *scope); int ParseType(Parse *p, int t, Type **ptype, int sqflags); int ParseDeclType(Parse *p, int t, Type **ptype, SemGroup **psg, int scopeFlags, int rqflags, string_t *id, int idRequired); /* * parse3.c */ int ParseExp(Parse *p, int t, Exp **pexp); int ParseParenthesizedExp(Parse *p, int t, Exp **pexp, int docomp); int ParseBracketedExp(Parse *p, int t, Exp **pexp); int ParseNotExp(Parse *p, int t, Exp **pexp); /* * resolve.c */ void ResolveProject(Parse *p, Stmt *st); void CollapseProject(Stmt *st); /* * stmt.c */ Stmt *BuildRootImportStmt(const char *path); void StmtPrintError(Stmt *st, int type); /* * strtable.c */ string_t StrTableEscapeQuotedString(const char *str, int len, int term); string_t StrTableAlloc(const char *str, int len, int special); string_t StrTableToken(token_t *tok); string_t StrTableInt(int v); string_t StrTableDup(string_t str); int StrTableSpecial(string_t id); int StrTableLen(string_t id); int StrCmpToken(string_t id, token_t *tok); void ReplaceStrTable(string_t *pstr, string_t id); void RelStrTable(string_t *pstr); const char *StripPathId(const char *path, int *len); int SimpleIntToken(token_t *tok, int *rv); int SimpleRunesizeToken(token_t *tok, runesize_t *rv); int StrTableEnumerate(string_t id); /* * sym.c */ int SymKeywordFind(const char *ptr, int len, int t); /* * type.c */ char *TypeToStr(Type *type, char **pstr); int SameType(Type *t1, Type *t2, int sqFlags2); int SimilarType(Type *t1, Type *t2); int SimilarSemGroup(SemGroup *s1, SemGroup *s2); int MatchType(Type *super, Type *type); void InternalRegisterType(const char *str, const char *linkname, Type *type); Type *InternalRegisteredTypeLookup(string_t id); void initType(Type *type, typelist_t *list, int op); void initQualType(Type *type, typelist_t *list, int op, int sqflags); void initPtrType(Type *type, Type *ptrto, int sqflags); void initCPtrType(Type *type, Type *ptrto, int sqflags); SemGroup *BaseType(Type **ptype); GlobInfo *GetGlobInfo(const char *label, runesize_t beg_off, runesize_t end_off, SemGroup *rssg, Type *type); /* * High-level Interpreter and Generator */ runctx_p RunUnresolvedStmt(runctx_p ct, Stmt *st); genctx_p GenUnresolvedStmt(genctx_p ct, Stmt *st); void RunUnresolvedExp(runctx_p ct, rundata_t *data, Exp *exp); int64_t Run64DefaultExp(runctx_p ct, Exp *exp); gendata_t *GenUnresolvedExp(genctx_p ct, Exp *exp); extern int RuneInlineComplexity; extern typelist_t DynamicTypeList; extern typelist_t CompoundTypeList; extern typelist_t ArgsTypeList; extern typelist_t StorageTypeList; extern void **DefaultDynamicVector; extern Type DynamicRValueType; extern Type DynamicLValueType; extern Type NumericType; extern Type IntegralType; extern Type SIntegerType; extern Type UIntegerType; extern Type VoidType; extern Type BoolType; extern Type Int8Type; extern Type UInt8Type; extern Type Int16Type; extern Type UInt16Type; extern Type Int32Type; extern Type UInt32Type; extern Type Int64Type; extern Type UInt64Type; extern Type Int128Type; extern Type UInt128Type; extern Type FloatType; extern Type Float32Type; extern Type Float64Type; extern Type Float128Type; extern Type CCharType; extern Type StrType; /* NOTE: const char *, chars are unsigned */ extern Type CharPtrType; extern Type CharPtrPtrType; extern Type VoidPtrType; extern Type VoidRefType; extern Type CVoidPtrType; extern Type LVoidPtrType; extern Type PointerType; /* generic pointer placeholder */ extern Type PointerInfoType; extern Type LexRefType; /* run-time access class tie-ins */ extern Type ScopeType; extern Type DeclarationType; extern Type SemGroupType; extern Type TypeType; extern Type FILLERTypeType; extern Type FILLERDeclType; extern Type IntPtrType; extern Type UIntPtrType; extern Type OffType; extern Type SizeType; extern Type *BaseTypeAry[]; extern typereglist_t TypeRegList;