示例#1
0
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
0
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
0
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
0
/***************************************************
  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
0
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
0
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
0
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
0
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
0
/************************************************************
  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
0
文件: WriteELF.cpp 项目: maazl/vc4asm
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
0
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
0
/* 添加一个变量到符号表中 */
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
0
/// 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
0
/*
	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
0
void ArcoderModel::InitUniformModel(int i_symbolCount)
{
  Reset();

  for (int i = 0; i < i_symbolCount; i++)
  {
    AddSymbol(i);
  }
}
示例#16
0
globle BOOLEAN GetFactSlot(
  void *vTheFact,
  char *slotName,
  DATA_OBJECT *theValue)
  {
   struct fact *theFact = (struct fact *) vTheFact;
   struct deftemplate *theDeftemplate;
   int whichSlot;

   /*===============================================*/
   /* Get the deftemplate associated with the fact. */
   /*===============================================*/

   theDeftemplate = theFact->whichDeftemplate;

   /*==============================================*/
   /* Handle retrieving the slot value from a fact */
   /* having an implied deftemplate. An implied    */
   /* facts has a single multifield slot.          */
   /*==============================================*/

   if (theDeftemplate->implied)
     {
      if (slotName != NULL) return(FALSE);
      theValue->type = theFact->theProposition.theFields[0].type;
      theValue->value = theFact->theProposition.theFields[0].value;
      SetpDOBegin(theValue,1);
      SetpDOEnd(theValue,((struct multifield *) theValue->value)->multifieldLength);
      return(TRUE);
     }

   /*===================================*/
   /* Make sure the slot name requested */
   /* corresponds to a valid slot name. */
   /*===================================*/

   if (FindSlot(theDeftemplate,(SYMBOL_HN *) AddSymbol(slotName),&whichSlot) == NULL)
     { return(FALSE); }

   /*======================================================*/
   /* Return the slot value. If the slot value wasn't set, */
   /* then return FALSE to indicate that an appropriate    */
   /* slot value wasn't available.                         */
   /*======================================================*/

   theValue->type = theFact->theProposition.theFields[whichSlot-1].type;
   theValue->value = theFact->theProposition.theFields[whichSlot-1].value;
   if (theValue->type == MULTIFIELD)
     {
      SetpDOBegin(theValue,1);
      SetpDOEnd(theValue,((struct multifield *) theValue->value)->multifieldLength);
     }

   if (theValue->type == RVOID) return(FALSE);

   return(TRUE);
  }
示例#17
0
globle int DefineFunction2(
  char *name,
  int returnType,
  int (*pointer)(void),
  char *actualName,
  char *restrictions)
  {
   struct FunctionDefinition *newFunction;

   if ( (returnType != 'a') &&
        (returnType != 'b') &&
        (returnType != 'c') &&
        (returnType != 'd') &&
        (returnType != 'f') &&
        (returnType != 'i') &&
        (returnType != 'j') &&
        (returnType != 'k') &&
        (returnType != 'l') &&
        (returnType != 'm') &&
        (returnType != 'n') &&
#if OBJECT_SYSTEM
        (returnType != 'o') &&
#endif
        (returnType != 's') &&
        (returnType != 'u') &&
        (returnType != 'v') &&
#if OBJECT_SYSTEM
        (returnType != 'x') &&
#endif
        (returnType != 'w') )
     { return(0); }

   newFunction = get_struct(FunctionDefinition);
   newFunction->callFunctionName = (SYMBOL_HN *) AddSymbol(name);
   newFunction->returnValueType = (char) returnType;
   newFunction->functionPointer = pointer;
   newFunction->next = GetFunctionList();
   newFunction->actualFunctionName = actualName;
   if (restrictions != NULL)
     {
      if (((int) (strlen(restrictions)) < 2) ? TRUE :
          ((! isdigit(restrictions[0]) && (restrictions[0] != '*')) ||
           (! isdigit(restrictions[1]) && (restrictions[1] != '*'))))
        restrictions = NULL;
     }
   newFunction->restrictions = restrictions;
   newFunction->parser = NULL;
   newFunction->overloadable = TRUE;
   newFunction->sequenceuseok = TRUE;
   newFunction->usrData = NULL;

   IncrementSymbolCount(newFunction->callFunctionName);
   ListOfFunctions = newFunction;
   AddHashFunction(newFunction);

   return(1);
  }
示例#18
0
/* 添加Typedef 自定义类型到符号表中 */
Symbol AddTypedefName (char *name, Type ty) 
{
    Symbol p;
    CALLOC (p);

    p->kind = SK_TypedefName;
    p->name = name;
    p->ty = ty;
    return AddSymbol (Identifiers, p);
}
示例#19
0
文件: scanner.c 项目: mingpen/OpenNT
//---------------------------------------------------------------------------
// AddSymbol
//
// This function adds the given symbol to the symbol tree.
//
// RETURNS:     TRUE if successful, or FALSE if an error occurs.
//---------------------------------------------------------------------------
BOOL NEAR AddSymbol (SYMNODE *pTree, LPSTR szSym)
{
    register    INT     i;

    // Simple binary tree insert code.  If already in tree, set its fDef flag
    // to TRUE.
    //-----------------------------------------------------------------------
    i = _fstricmp (pTree->szSym, szSym);
    if (!i)
        return (pTree->fDef = TRUE);
    if (i < 0)
        {
        if (pTree->left)
            return (AddSymbol (pTree->left, szSym));
        return ((pTree->left = NewSymNode (szSym)) ? TRUE : FALSE);
        }
    if (pTree->right)
        return (AddSymbol (pTree->right, szSym));
    return ((pTree->right = NewSymNode (szSym)) ? TRUE : FALSE);
}
示例#20
0
/* 添加类型到符号表中 */
Symbol AddTag (char *name, Type ty)
{
    Symbol p;
    CALLOC (p); 
    /* 类型的类别码, 名字和类型 */
    p->kind = SK_Tag;
    p->name = name;
    p->ty = ty;

    return AddSymbol (Tags, p);
}
示例#21
0
Symbol *UniqueSymbol(Scope *fScope, Type *fType, symbolkind kind)
{
    static int nextTmp = 0;
    static SourceLoc tmpLoc = { 0, 0 };
    char buf[256];
    int atom;
  
    sprintf(buf, "@TMP%d", nextTmp++);
    atom = AddAtom(atable, buf);
    return AddSymbol(&tmpLoc, fScope, atom, fType, kind);
} // UniqueSymbol
示例#22
0
Symbol *UniqueSymbol( CgContext *cg, Scope *fScope, Type *fType, SymbolKind kind)
{
  static int nextTmp = 0;
  static SourceLoc tmpLoc = { 0, 0 };
  char buf[256];
  Atom atom;
  
  sprintf(buf, "@TMP%d", nextTmp++);
  atom = cg->GetAtom(buf);
  return AddSymbol( cg, &tmpLoc, fScope, atom, fType, kind);
} // UniqueSymbol
示例#23
0
globle char *LongIntegerToString(
  long number)
  {
   char buffer[30];
   void *thePtr;

   sprintf(buffer,"%ld",number);

   thePtr = AddSymbol(buffer);
   return(ValueToString(thePtr));
  }
示例#24
0
/* 添加一个常量到常量符号表中 */
Symbol AddEnumConstant (char *name, Type ty, int val) 
{
    Symbol p;
    CALLOC (p);

    p->kind = SK_EnumConstant;
    p->name = name;
    p->ty   = ty;
    /* 常量的值 */
    p->val.i[0] = val;

    return AddSymbol (Identifiers, p);
}
示例#25
0
KEffect2ParaInfo2 *KEffectInfo::AddFloat(const sChar *name,sInt offset,sF32 min,sF32 max,sF32 step,sInt count)
{
  KEffect2ParaInfo2 *info;
  sInt anim = 0;

  offset = offset/4;
  if(*name=='*')
  {
    name++;
    if(count==1) { AddSymbol(name,offset,sST_SCALAR); anim = EAT_SCALAR; }
    if(count==4) { AddSymbol(name,offset,sST_VECTOR); anim = EAT_VECTOR; }
  }

  info = AddPara(name,offset,EPT_FLOAT);
  info->Min = min;
  info->Max = max;
  info->Step = step;
  info->Count = count;
  info->AnimType = anim;

  return info;
}
示例#26
0
// atomic operations
Nfa* AtomicMakeNfaBySingleC( Context* con, const char c ) {
	AddSymbol( con, c );
	Nfa* ret = AddNfa( con );
	Node* start = AddNode( con );
	State* ss = MakeState( con );
	AddState( start, ss);
	Node* end = AddNode( con );
	ss = MakeState( con );
	AddState( end, ss);
	AddEdge( start, end, c );
	ret->starts = start;
	ret->accepts = end;
	return ret;
}
示例#27
0
static
int BrowRootInit(char *sim_name)
{
  struct Instance *ptr;
  if (!sim_name) {
    return 1;
  }
  InitInstList();    /* initialize the g_instlist */
  ptr = Asc_FindSimulationRoot(AddSymbol(sim_name));
  if (ptr) {
    g_root = g_curinst = ptr;
    g_depth = 1;
    g_instlist[g_depth] = g_root; /* we only use positions 1 forward */
    Asc_SetCurrentSim(Asc_FindSimulationTop(AddSymbol(sim_name)));
    return 0;
  } else {
    g_root = g_curinst = NULL;
    InitInstList();
    g_depth = 0;
    Asc_SetCurrentSim(NULL);
    return 1;
  }
}
示例#28
0
// cons
	GlobalScope::
	GlobalScope() :
		AbstractScope(),
		m_bDirty(false),
		m_symbols(NULL),
		m_functions(NULL),
		m_labels(NULL)
{
	// ECMA defined globals
	// See section 15.1.1
	AddSymbol("NaN");
	AddSymbol("Infinity");
	//AddSymbol("undefined");
	//AddFunction("eval");
	AddFunction("parseInt");
	AddFunction("parseFloat");
	AddFunction("isNaN");
	AddFunction("isFinite");
	AddFunction("decodeURI");
	AddFunction("decodeURIComponent");
	AddFunction("encodeURI");
	AddFunction("encodeURIComponent");
};
示例#29
0
globle char *FloatToString(
  double number)
  {
   char floatString[40];
   int i;
   char x;
   void *thePtr;

   sprintf(floatString,"%.16g",number);

   for (i = 0; (x = floatString[i]) != '\0'; i++)
     {
      if ((x == '.') || (x == 'e'))
        {
         thePtr = AddSymbol(floatString);
         return(ValueToString(thePtr));
        }
     }

   strcat(floatString,".0");

   thePtr = AddSymbol(floatString);
   return(ValueToString(thePtr));
  }
示例#30
0
void PredefineIntMacro(const char *name, int value) {
    SourceLoc location = {0, 0};
    Symbol *symbol = NULL;
    MacroSymbol macro = {0, NULL, NULL, 0, 0};
    yystypepp val = {0, 0.0, 0, {0}};
    int atom = 0;

    macro.body = NewTokenStream(name, macros->pool);
    val.sc_int = value;
    snprintf(val.symbol_name, MAX_SYMBOL_NAME_LEN+1, "%d", value);
    RecordToken(macro.body, CPP_INTCONSTANT, &val);
    atom = LookUpAddString(atable, name);
    symbol = AddSymbol(&location, macros, atom, MACRO_S);
    symbol->details.mac = macro;
}