SBSPSS/Utils/Scripter/var.cpp

112 lines
1.9 KiB
C++
Raw Normal View History

2000-12-08 21:42:35 +01:00
/*=========================================================================
var.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "var.h"
2000-12-12 21:51:59 +01:00
#ifndef _LEXER_H
#include "lexer.h"
#endif
2000-12-08 21:42:35 +01:00
/* Std Lib
------- */
#include <stdio.h>
#include <string.h>
/* Data
---- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
static char *s_globalVarNames[]=
{
"lives",
};
static int s_numGlobalVarNames=sizeof(s_globalVarNames)/sizeof(char *);
static char *s_localVarNames[]=
{
2000-12-20 21:15:24 +01:00
"tmp0",
2000-12-08 21:42:35 +01:00
"tmp1",
"tmp2",
"tmp3",
2000-12-20 21:15:24 +01:00
"tmp4",
"tmp5",
"tmp6",
"tmp7",
"tmp8",
"tmp9",
2000-12-08 21:42:35 +01:00
};
static int s_numLocalVarNames=sizeof(s_localVarNames)/sizeof(char *);
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2000-12-12 21:51:59 +01:00
extern mylexer s_lexer;
2000-12-08 21:42:35 +01:00
extern int lookupVarName(char *_name)
{
int i,vnum;
vnum=0;
// Global vars
for(i=0;i<s_numGlobalVarNames;i++,vnum++)
{
2000-12-12 17:29:42 +01:00
if(strcmp(_name,s_globalVarNames[i])==0)
2000-12-08 21:42:35 +01:00
{
return vnum;
}
}
// Local vars
for(i=0;i<s_numLocalVarNames;i++,vnum++)
{
2000-12-12 17:29:42 +01:00
if(strcmp(_name,s_localVarNames[i])==0)
2000-12-08 21:42:35 +01:00
{
return vnum;
}
}
printf("Unknown variable $%s\n",_name);
2000-12-12 21:51:59 +01:00
s_lexer.error();
2000-12-08 21:42:35 +01:00
return -1;
}
/*===========================================================================
end */