int Get_SLD_FileNo(char *ThisName) { SYMBOL sym; SYMBOL *theSym; int n; int len; len = strlen(ThisName); for (n=0; n<len; n++) { if (ThisName[n] == '/') ThisName[n] = '\\'; } theSym = FindSymbolsOld(ThisName,section_SLD_File,section_SLD_File); if (theSym) return theSym->Value; sym.Section = section_SLD_File; sym.Type = LocalScope; // Was 0 sym.Value = Current_SLD_FileNo++; sym.LocalScope = 0; StoreSymbol(&sym,ThisName); return Current_SLD_FileNo - 1; }
SYMBOL * AddSysCall(char *ThisName, int Value, int Param, int RetType, char *istr) { SYMBOL sym; SYMBOL *theSym; char *iptr = 0; int len; theSym = FindSymbolsOld(ThisName,section_SysCall,section_SysCall); if (theSym) Error(Error_Fatal, "SysCall '%s' has already been defined", ThisName); if (istr) { len = strlen(istr); iptr = NewPtr(len + 2); if (!iptr) Error(Error_Fatal, "failed to allocate syscall interface"); strcpy(iptr, istr); } sym.Section = section_SysCall; sym.Type = 0; sym.Value = Value; sym.LocalScope = 0; sym.Params = Param; sym.RetType = RetType; sym.Interface = iptr; return StoreSymbol(&sym,ThisName); }
SYMBOL * RedefENumString(char *ThisName, char *str) { SYMBOL sym; SYMBOL *theSym; theSym = FindSymbolsOld(ThisName,section_Script,section_Script); if (theSym) { // Allow redefinition theSym->Interface = CreateRedefString(str, theSym->Interface); if (isdigit(*str)) theSym->Value = atoi(str); return theSym; } // Create new string sym.Section = section_Script; sym.Type = 0; sym.Value = 0; sym.LocalScope = 0; sym.Interface = CreateRedefString(str, 0); if (isdigit(*str)) sym.Value = atoi(str); return StoreSymbol(&sym,ThisName); }
SYMBOL * RedefENum(char *ThisName,int Value) { SYMBOL sym; SYMBOL *theSym; char str[32]; // Build string sprintf(str, "%i", Value); // see if the symbols exists theSym = FindSymbolsOld(ThisName,section_Script,section_Script); if (theSym) { // Allow redefinition theSym->Value = Value; theSym->Interface = CreateRedefString(str, theSym->Interface); return theSym; } sym.Section = section_Script; sym.Type = 0; sym.Value = Value; sym.LocalScope = 0; sym.Interface = CreateRedefString(str, 0); return StoreSymbol(&sym,ThisName); }
SYMBOL * AddFileSym(char *ThisName,int Value) { SYMBOL sym; if (Pass != 1) return 0; sym.Section = section_File; sym.Type = 0; sym.Value = Value; sym.LocalScope = 0; // sym.Extern = 0; return StoreSymbol(&sym,ThisName); }
SYMBOL * AddToken(char *ThisName,int Value) { SYMBOL sym; SYMBOL *theSym; theSym = FindSymbolsOld(ThisName,section_Token,section_Token); if (theSym) Error(Error_Fatal, "Token '%s' has already been defined", ThisName); // printf("Token '%s' = %d\n", ThisName, Value); sym.Section = section_Token; sym.Type = 0; sym.Value = Value; sym.LocalScope = 0; return StoreSymbol(&sym,ThisName); }
void MakeIndexedResource(char *name, int index) { SYMBOL *Sym; SYMBOL sym; if (name[0] == 0) return; Sym = FindSymbolsOld(name,section_Resource,section_Resource); if (Sym) { Error(Error_Skip, "Symbol '%s' is already defined",name); return; } sym.Section = section_Resource; sym.Type = 0; sym.Value = index; StoreSymbol(&sym,name); }
void MakeNewResource(char *name) { SYMBOL *Sym; SYMBOL sym; if (name[0] == 0) return; Sym = FindSymbolsOld(name,section_Resource,section_Resource); // Symbol found if (Sym) { if (Pass == 1) Error(Error_Skip, "Symbol '%s' is already defined",name); Sym->Value = CurrentResource; return; } // Symbol not found if (Pass == 2) { Error(Error_Skip, "Strange error symbol '%s' defined in second pass",name); return; } sym.Section = section_Resource; sym.Type = 0; sym.Value = CurrentResource; sym.LocalScope = LocalScope; StoreSymbol(&sym,name); }