本文整理匯總了C++中AddSymbol函數的典型用法代碼示例。如果您正苦於以下問題:C++ AddSymbol函數的具體用法?C++ AddSymbol怎麽用?C++ AddSymbol使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AddSymbol函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: InitPasm
static void
InitPasm(int flags)
{
HwReg *hwreg;
InstrModifier *modifiers;
int i;
if (gl_p2) {
instr = instr_p2;
hwreg = hwreg_p2;
modifiers = modifiers_p2;
} else {
instr = instr_p1;
hwreg = hwreg_p1;
modifiers = modifiers_p1;
}
/* add hardware registers */
for (i = 0; hwreg[i].name != NULL; i++) {
AddSymbol(&reservedWords, hwreg[i].name, SYM_HWREG, (void *)&hwreg[i]);
}
/* add instructions */
for (i = 0; instr[i].name != NULL; i++) {
AddSymbol(&pasmWords, instr[i].name, SYM_INSTR, (void *)&instr[i]);
}
/* instruction modifiers */
for (i = 0; modifiers[i].name != NULL; i++) {
AddSymbol(&pasmWords, modifiers[i].name, SYM_INSTRMODIFIER, (void *)&modifiers[i]);
}
}
示例2: initLexer
void
initLexer(int flags)
{
int i;
/* add our reserved words */
for (i = 0; i < N_ELEMENTS(init_words); i++) {
AddSymbol(&reservedWords, init_words[i].name, SYM_RESERVED, (void *)init_words[i].val);
}
/* add builtin functions */
for (i = 0; i < N_ELEMENTS(builtinfuncs); i++) {
AddSymbol(&reservedWords, builtinfuncs[i].name, SYM_BUILTIN, (void *)&builtinfuncs[i]);
}
/* and builtin constants */
for (i = 0; i < N_ELEMENTS(constants); i++) {
AddSymbol(&reservedWords, constants[i].name, constants[i].type, AstInteger(constants[i].val));
}
/* C keywords */
for (i = 0; i < N_ELEMENTS(c_words); i++) {
AddSymbol(&ckeywords, c_words[i], SYM_RESERVED, NULL);
}
/* add the PASM instructions */
InitPasm(flags);
}
示例3: SetErrorCaptureValues
static void SetErrorCaptureValues(
DATA_OBJECT_PTR returnValue)
{
struct multifield *theMultifield;
theMultifield = (struct multifield *) CreateMultifield(2L);
if (ErrorString != NULL)
{
SetMFType(theMultifield,1,STRING);
SetMFValue(theMultifield,1,AddSymbol(ErrorString));
}
else
{
SetMFType(theMultifield,1,SYMBOL);
SetMFValue(theMultifield,1,FalseSymbol);
}
if (WarningString != NULL)
{
SetMFType(theMultifield,2,STRING);
SetMFValue(theMultifield,2,AddSymbol(WarningString));
}
else
{
SetMFType(theMultifield,2,SYMBOL);
SetMFValue(theMultifield,2,FalseSymbol);
}
SetpType(returnValue,MULTIFIELD);
SetpDOBegin(returnValue,1);
SetpDOEnd(returnValue,2);
SetpValue(returnValue,(void *) theMultifield);
}
示例4: SetupInstanceModDupCommands
/***************************************************
NAME : SetupMessageHandlers
DESCRIPTION : Sets up internal symbols and
fucntion definitions pertaining to
message-handlers. Also creates
system handlers
INPUTS : None
RETURNS : Nothing useful
SIDE EFFECTS : Functions and data structures
initialized
NOTES : Should be called before
SetupInstanceModDupCommands() in
INSMODDP.C
***************************************************/
globle void SetupMessageHandlers()
{
InstallPrimitive(&HandlerGetInfo,HANDLER_GET);
InstallPrimitive(&HandlerPutInfo,HANDLER_PUT);
#if ! RUN_TIME
INIT_SYMBOL = (SYMBOL_HN *) AddSymbol(INIT_STRING);
IncrementSymbolCount(INIT_SYMBOL);
DELETE_SYMBOL = (SYMBOL_HN *) AddSymbol(DELETE_STRING);
IncrementSymbolCount(DELETE_SYMBOL);
AddClearFunction("defclass",CreateSystemHandlers,-100);
#if ! BLOAD_ONLY
SELF_SYMBOL = (SYMBOL_HN *) AddSymbol(SELF_STRING);
IncrementSymbolCount(SELF_SYMBOL);
AddConstruct("defmessage-handler","defmessage-handlers",
ParseDefmessageHandler,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
DefineFunction2("undefmessage-handler",'v',PTIF UndefmessageHandlerCommand,
"UndefmessageHandlerCommand","23w");
#endif
DefineFunction2("send",'u',PTIF SendCommand,"SendCommand","2*uuw");
#if DEBUGGING_FUNCTIONS
DefineFunction2("preview-send",'v',PTIF PreviewSendCommand,"PreviewSendCommand","22w");
DefineFunction2("ppdefmessage-handler",'v',PTIF PPDefmessageHandlerCommand,
"PPDefmessageHandlerCommand","23w");
DefineFunction2("list-defmessage-handlers",'v',PTIF ListDefmessageHandlersCommand,
"ListDefmessageHandlersCommand","02w");
#endif
#if IMPERATIVE_MESSAGE_HANDLERS
DefineFunction2("next-handlerp",'b',PTIF NextHandlerAvailable,"NextHandlerAvailable","00");
FuncSeqOvlFlags("next-handlerp",TRUE,FALSE);
DefineFunction2("call-next-handler",'u',
PTIF CallNextHandler,"CallNextHandler","00");
FuncSeqOvlFlags("call-next-handler",TRUE,FALSE);
DefineFunction2("override-next-handler",'u',
PTIF CallNextHandler,"CallNextHandler",NULL);
FuncSeqOvlFlags("override-next-handler",TRUE,FALSE);
#endif
DefineFunction2("dynamic-get",'u',PTIF DynamicHandlerGetSlot,"DynamicHandlerGetSlot","11w");
DefineFunction2("dynamic-put",'u',PTIF DynamicHandlerPutSlot,"DynamicHandlerPutSlot","1**w");
DefineFunction2("get",'u',PTIF DynamicHandlerGetSlot,"DynamicHandlerGetSlot","11w");
DefineFunction2("put",'u',PTIF DynamicHandlerPutSlot,"DynamicHandlerPutSlot","1**w");
#endif
#if DEBUGGING_FUNCTIONS
AddWatchItem("messages",0,&WatchMessages,36,NULL,NULL);
AddWatchItem("message-handlers",0,&WatchHandlers,35,
DefmessageHandlerWatchAccess,DefmessageHandlerWatchPrint);
#endif
}
示例5: LowcaseFunction
globle void LowcaseFunction(
DATA_OBJECT_PTR returnValue)
{
DATA_OBJECT theArg;
int i, slen;
char *osptr, *nsptr;
/*================================================*/
/* Function lowcase expects exactly one argument. */
/*================================================*/
if (ArgCountCheck("lowcase",EXACTLY,1) == -1)
{
SetpType(returnValue,STRING);
SetpValue(returnValue,(void *) AddSymbol(""));
return;
}
/*==================================================*/
/* The argument should be of type symbol or string. */
/*==================================================*/
if (ArgTypeCheck("lowcase",1,SYMBOL_OR_STRING,&theArg) == FALSE)
{
SetpType(returnValue,STRING);
SetpValue(returnValue,(void *) AddSymbol(""));
return;
}
/*======================================================*/
/* Allocate temporary memory and then copy the original */
/* string or symbol to that memory, while lowercasing */
/* upper case alphabetic characters. */
/*======================================================*/
osptr = DOToString(theArg);
slen = strlen(osptr) + 1;
nsptr = (char *) gm2(slen);
for (i = 0 ; i < slen ; i++)
{
if (isupper(osptr[i]))
{ nsptr[i] = (char) tolower(osptr[i]); }
else
{ nsptr[i] = osptr[i]; }
}
/*========================================*/
/* Return the lowercased string and clean */
/* up the temporary memory used. */
/*========================================*/
SetpType(returnValue,GetType(theArg));
SetpValue(returnValue,(void *) AddSymbol(nsptr));
rm(nsptr,slen);
}
示例6: return
globle SYMBOL_HN *SetStrategyCommand()
{
DATA_OBJECT argPtr;
char *argument;
int oldStrategy = Strategy;
/*=====================================================*/
/* Check for the correct number and type of arguments. */
/*=====================================================*/
if (ArgCountCheck("set-strategy",EXACTLY,1) == -1)
{ return((SYMBOL_HN *) AddSymbol(GetStrategyName(GetStrategy()))); }
if (ArgTypeCheck("set-strategy",1,SYMBOL,&argPtr) == FALSE)
{ return((SYMBOL_HN *) AddSymbol(GetStrategyName(GetStrategy()))); }
argument = DOToString(argPtr);
/*=============================================*/
/* Set the strategy to the specified strategy. */
/*=============================================*/
if (strcmp(argument,"depth") == 0)
{ SetStrategy(DEPTH_STRATEGY); }
else if (strcmp(argument,"breadth") == 0)
{ SetStrategy(BREADTH_STRATEGY); }
else if (strcmp(argument,"lex") == 0)
{ SetStrategy(LEX_STRATEGY); }
else if (strcmp(argument,"mea") == 0)
{ SetStrategy(MEA_STRATEGY); }
else if (strcmp(argument,"complexity") == 0)
{ SetStrategy(COMPLEXITY_STRATEGY); }
else if (strcmp(argument,"simplicity") == 0)
{ SetStrategy(SIMPLICITY_STRATEGY); }
else if (strcmp(argument,"random") == 0)
{ SetStrategy(RANDOM_STRATEGY); }
else
{
ExpectedTypeError1("set-strategy",1,
"symbol with value depth, breadth, lex, mea, complexity, simplicity, or random");
return((SYMBOL_HN *) AddSymbol(GetStrategyName(GetStrategy())));
}
/*=======================================*/
/* Return the old value of the strategy. */
/*=======================================*/
return((SYMBOL_HN *) AddSymbol(GetStrategyName(oldStrategy)));
}
示例7: ExpandStringWithChar
globle char *StringPrintForm(
char *str)
{
int i = 0, pos = 0, max = 0;
char *theString = NULL;
void *thePtr;
theString = ExpandStringWithChar('"',theString,&pos,&max,max+80);
while (str[i] != EOS)
{
if ((str[i] == '"') || (str[i] == '\\'))
{
theString = ExpandStringWithChar('\\',theString,&pos,&max,max+80);
theString = ExpandStringWithChar(str[i],theString,&pos,&max,max+80);
}
else
{ theString = ExpandStringWithChar(str[i],theString,&pos,&max,max+80); }
i++;
}
theString = ExpandStringWithChar('"',theString,&pos,&max,max+80);
thePtr = AddSymbol(theString);
rm(theString,max);
return(ValueToString(thePtr));
}
示例8: AddSymbol
void ArcoderModel::Reset()
{
m_cumulativeFreqs.clear();
// m_freqs.clear();
m_cumulativeFreqs.push_back(0);
m_symbolToIndex.clear();
m_indexToSymbol.clear();
m_symbols.clear();
m_lastIndex = 1;
AddSymbol(kNewSymbolCode);
AddSymbol(kEOFSymbolCode);
}
示例9: address
/************************************************************
NAME : WildDeleteHandler
DESCRIPTION : Deletes a handler from a class
INPUTS : 1) Class address (Can be NULL)
2) Message Handler Name (Can be NULL)
3) Type name ("primary", etc.)
RETURNS : 1 if successful, 0 otherwise
SIDE EFFECTS : Handler deleted if possible
NOTES : None
************************************************************/
static int WildDeleteHandler(
DEFCLASS *cls,
SYMBOL_HN *msym,
char *tname)
{
int mtype;
if (msym == NULL)
msym = (SYMBOL_HN *) AddSymbol("*");
if (tname != NULL)
{
mtype = HandlerType("undefmessage-handler",tname);
if (mtype == MERROR)
return(0);
}
else
mtype = -1;
if (cls == NULL)
{
int success = 1;
for (cls = (DEFCLASS *) GetNextDefclass(NULL) ;
cls != NULL ;
cls = (DEFCLASS *) GetNextDefclass((void *) cls))
if (DeleteHandler(cls,msym,mtype,FALSE) == 0)
success = 0;
return(success);
}
return(DeleteHandler(cls,msym,mtype,TRUE));
}
示例10: AddSymbol
void WriteELF::Write(const vector<uint64_t>& instructions, const DebugInfo& info, const char* filename)
{
// File name symbol
{ auto& sym = AddSymbol(filename);
sym.st_info = (STB_LOCAL<<4) | STT_FILE;
sym.st_shndx = SHN_ABS;
}
const size_t code_size = instructions.size() * sizeof(uint64_t);
// Code fragment symbol, name = file name
if (!NoStandardSymbols)
{ string name = stripextension(strippath(filename));
replacenonalphanum(name);
AddGlobalSymbol(name).st_size = code_size;
// End Symbol
name.append("_end");
AddGlobalSymbol(name).st_value = code_size;
// Size symbol
name.erase(name.size() - 4);
name.append("_size");
auto& sym = AddGlobalSymbol(name);
sym.st_shndx = SHN_ABS;
sym.st_value = code_size;
}
// Export global symbol table
for (auto sym : info.GlobalsByName)
{ auto& value = AddGlobalSymbol(sym.first);
value.st_value = (Elf32_Addr)sym.second.iValue;
if (sym.second.Type == V_INT)
value.st_shndx = SHN_ABS;
}
// write header
WriteRaw(Hdr);
// write section table
WriteRaw(Sect0);
WriteRaw(SectSNST);
Elf32_Shdr sect = SectCode;
sect.sh_size = code_size;
WriteRaw(sect);
sect = SectSym;
sect.sh_offset += code_size;
size_t sym_size = Symbols.size() * sizeof(Elf32_Sym);
sect.sh_size = sym_size;
WriteRaw(sect);
sect = SectSymST;
sect.sh_offset += code_size + sym_size;
sect.sh_size = SymbolNames.size() + 1;
WriteRaw(sect);
// write section names
WriteRaw(SNST);
// write code
checkedwrite(Target, &instructions.front(), code_size);
// write symbol table
checkedwrite(Target, &Symbols.front(), sizeof(Elf32_Sym) * Symbols.size());
// write symbol names
checkedwrite(Target, SymbolNames.c_str(), SymbolNames.size() + 1);
}
示例11: process_except_file
static void process_except_file( char *filename )
/***********************************************/
{
FILE *fp;
char line[ MAX_LINE_LEN ];
char *p;
if( filename != NULL ) {
fp = fopen( filename, "rt" );
if( fp == NULL ) {
printf( "Cannot open input file: %s.\n", filename );
return;
}
while( fgets( line, MAX_LINE_LEN , fp ) != NULL ) {
p = line + strlen( line );
while( p >= line ) {
if( ( *p == '\0' )
|| ( *p == ' ' )
|| ( *p == '\n' ) ) {
*p = '\0';
p--;
} else {
break;
}
}
AddSymbol( pubdef_tab, line, NULL );
}
fclose( fp );
}
}
示例12: AddVariable
/* 添加一個變量到符號表中 */
Symbol AddVariable (char *name, Type ty, int sclass)
{
VariableSymbol p;
CALLOC (p);
p->kind = SK_Variable;
p->name = name;
p->ty = ty;
/* 變量的類別 */
p->sclass = sclass;
/* 全局變量,或靜態變量 */
if (0 == Level || sclass == TK_STATIC) {
/* 添加全局變量 */
*GlobalTail = (Symbol)p;
GlobalTail = &p->next;
} else if (TK_EXTERN != sclass) {
/* 局部變量(FSYM 指向當前函數) */
*FSYM->lastv = (Symbol)p;
FSYM->lastv = &p->next;
}
return AddSymbol (Identifiers, (Symbol)p);
}
示例13: m_position
/// Primary Constructor
/// @param position Zero-based index of the position within the system where the
/// barline is anchored
/// @param symbolType Type of symbol to add (see symbolTypes enum for values)
/// @param activeSymbol Symbol that must be active for the symbol to be
/// triggered (see activeSymbols enum for values)
/// @param repeatNumber Repeat number that must be active for the symbol to be
/// triggered (0 = none)
Direction::Direction(wxUint32 position, wxByte symbolType, wxByte activeSymbol,
wxByte repeatNumber) : m_position(position)
{
//------Last Checked------//
// - Jan 11, 2005
wxASSERT(IsValidPosition(position));
AddSymbol(symbolType, activeSymbol, repeatNumber);
}
示例14: test_boolrel
/*
Testing for Franc Ivankovic's CNF conversion code, ongoing, Jan 2010 -- JP.
*/
static void test_boolrel(void){
struct module_t *m;
int status;
Asc_CompilerInit(0); /* no simplification of expressions for this test */
Asc_PutEnv(ASC_ENV_LIBRARY "=models");
/* load the file */
#define TESTFILE "boolrel"
m = Asc_OpenModule("test/compiler/" TESTFILE ".a4c",&status);
CU_ASSERT(status == 0);
/* parse it */
CU_ASSERT(0 == zz_parse());
/* find the model */
CU_ASSERT(FindType(AddSymbol(TESTFILE))!=NULL);
/* instantiate it */
struct Instance *sim = SimsCreateInstance(AddSymbol(TESTFILE), AddSymbol("sim1"), e_normal, NULL);
CU_ASSERT_FATAL(sim!=NULL);
/* call the on_load method */
struct Name *name = CreateIdName(AddSymbol("on_load"));
CU_ASSERT(Proc_all_ok == Initialize(GetSimulationRoot(sim),name,"sim1", ASCERR, WP_STOPONERR, NULL, NULL));
/* Check that x := 2 was NOT executed (after error statement) */
struct Instance *inst;
struct Instance *root = GetSimulationRoot(sim);
CU_ASSERT(NULL != root);
CU_ASSERT(NULL != (inst = ChildByChar(root,AddSymbol("rel1"))));
CONSOLE_DEBUG("Instance kind = %d",InstanceKind(inst));
CU_ASSERT(InstanceKind(inst)==LREL_INST);
char *out = WriteLogRelToString(inst,root);
CONSOLE_DEBUG("Relation: %s",out);
ASC_FREE(out);
/* clean up */
sim_destroy(sim);
Asc_CompilerDestroy();
#undef TESTFILE
}
示例15: Reset
void ArcoderModel::InitUniformModel(int i_symbolCount)
{
Reset();
for (int i = 0; i < i_symbolCount; i++)
{
AddSymbol(i);
}
}