예제 #1
0
void QGlobalCache::LoadBy(const std::string &query)
{
	auto results = database.QueryDatabase(query);
	if (!results.Success())
		return;

	for (auto row = results.begin(); row != results.end(); ++row)
		AddGlobal(0, QGlobal(row[0], atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5] ? atoi(row[5]) : 0xFFFFFFFF));
}
예제 #2
0
파일: iix.cpp 프로젝트: eernst/piler-64
void IIX::AddLocal(const char *Label, int LocalFrom, int LocalTo, int User)
{
    if (0 == m_GLIX)
        Quit("IIX::AddLocal: no GLIX");

    int GlobalFrom = m_GLIX->LocalToGlobal(Label, LocalFrom);
    int GlobalTo = GlobalFrom + (LocalTo - LocalFrom + 1);
    return AddGlobal(GlobalFrom, GlobalTo, User);
}
예제 #3
0
BOOL CBlockUnit::Compile()
{
  m_bError = FALSE;

  if (m_pEditor)
  {
    // Save before compiling
    m_pEditor->Save();
  }

  if (m_nType == T_FUNCTION)
  {
    // Cleanup all I/Os
    ClrInput();
    ClrOutput();
    ClrGlobal();
    ClrStack();
    ClrLibrary();

    // Compile the source code
    m_bError = (CompileBlock(this) == FALSE);

    // Add system timer variable
    AddGlobal(new CVariable("TIME"), 0);
    AddGlobal(new CVariable("DTIME"), 0);
  }
  else if (m_nType == T_SUBSYSTEM)
  {
    // Compile subsystem document
   m_bError  = (m_pDocument->Compile() == FALSE);

    // Update document
    m_pDocument->Update();
    m_pDocument->Check();
  }

  return !m_bError;
}
예제 #4
0
/* ParseDim - parse the 'DIM' statement */
static void ParseDim(ParseContext *c)
{
    char name[MAXTOKEN];
    VMVALUE value, size;
    int isArray;
    Token tkn;

    /* parse variable declarations */
    do {

        /* get variable name */
        isArray = ParseVariableDecl(c, name, &size);

        /* add to the global symbol table if outside a function definition */
        if (c->codeType == CODE_TYPE_MAIN) {

            /* check for initializers */
            if ((tkn = GetToken(c)) == '=') {
                if (isArray)
                    ParseArrayInitializers(c, size);
                else
                    value = ParseScalarInitializer(c);
            }

            /* no initializers */
            else {
                ClearArrayInitializers(c, size);
                SaveToken(c, tkn);
            }

            /* create a vector object for arrays */
            value = isArray ? StoreVector(c, (VMVALUE *)c->codeBuf, size) : 0;

            /* add the symbol to the global symbol table */
            AddGlobal(c, name, SC_VARIABLE, c->image->variableCount++, value);
        }

        /* otherwise, add to the local symbol table */
        else {
            if (isArray)
                ParseError(c, "local arrays are not supported");
            AddLocal(c, name, SC_VARIABLE, c->localOffset + F_SIZE + 1);
            ++c->localOffset;
        }

    } while ((tkn = GetToken(c)) == ',');

    Require(c, tkn, T_EOL);
}
예제 #5
0
/* ParseConstantDef - parse a 'DEF <name> =' statement */
static void ParseConstantDef(ParseContext *c, char *name)
{
    ParseTreeNode *expr;
    Symbol *sym;

    /* get the constant value */
    expr = ParseExpr(c);

    /* make sure it's a constant */
    if (!IsIntegerLit(expr))
        ParseError(c, "expecting a constant expression");

    /* add the symbol as a global */
    sym = AddGlobal(c, name, SC_CONSTANT, expr->u.integerLit.value, 0);

    FRequire(c, T_EOL);
}
예제 #6
0
/* ParseDef - parse the 'DEF' statement */
static void ParseDef(ParseContext *c)
{
    char name[MAXTOKEN];
    Token tkn;

    /* get the name being defined */
    FRequire(c, T_IDENTIFIER);
    strcpy(name, c->token);

    /* check for a constant definition */
    if ((tkn = GetToken(c)) == '=')
        ParseConstantDef(c, name);

    /* otherwise, assume a function definition */
    else {
        Symbol *sym;

        /* save the lookahead token */
        SaveToken(c, tkn);

        /* enter the function name in the global symbol table */
        sym = AddGlobal(c, name, SC_CONSTANT, 0, 0);

        /* start the code under construction */
        StartCode(c, sym->name, CODE_TYPE_FUNCTION);
        sym->value = c->code;

        /* get the argument list */
        if ((tkn = GetToken(c)) == '(') {
            if ((tkn = GetToken(c)) != ')') {
                int offset = 1;
                SaveToken(c, tkn);
                do {
                    FRequire(c, T_IDENTIFIER);
                    AddArgument(c, c->token, SC_VARIABLE, offset);
                    ++offset;
                } while ((tkn = GetToken(c)) == ',');
            }
            Require(c, tkn, ')');
        }
        else
            SaveToken(c, tkn);
    }

    FRequire(c, T_EOL);
}
예제 #7
0
파일: QGlobals.cpp 프로젝트: epicemu/Server
void QGlobalCache::LoadByCharID(uint32 charID)
{
	char errbuf[MYSQL_ERRMSG_SIZE];
	char *query = 0;
	MYSQL_RES *result;
	MYSQL_ROW row;

	if (database.RunQuery(query, MakeAnyLenString(&query, "select id, name, charid, npcid, zoneid, value, expdate from"
		" quest_globals where charid = %d && npcid = 0", charID), errbuf, &result))
	{
		while((row = mysql_fetch_row(result)))
		{
			AddGlobal(atoi(row[0]), QGlobal(std::string(row[1]), atoi(row[2]), atoi(row[3]), atoi(row[4]), row[5], row[6]?atoi(row[6]):0xFFFFFFFF));
		}
		mysql_free_result(result);
	}
	safe_delete_array(query);
}
예제 #8
0
파일: GraphView.cpp 프로젝트: ke2ny/MoBu
GraphView::GraphView()
	: FBView()
	, GraphManager(this)
{
	mDown=false;

	mW = 320;
	mH = 240;

	mClearColor = FBVector4d(0.5, 0.5, 0.5, 1.0);

	// startup time range (X)
	FBPlayerControl		lPlayer;
	mTimeSpan.Set( lPlayer.ZoomWindowStart, lPlayer.ZoomWindowStop );
	// startup value range (Y)
	mValueSpan = FBVector2d( -100.0, 100.0 );

	// min & max
	mTimeRange = FBVector2d( (double)mTimeSpan.GetStart().GetFrame(), (double)mTimeSpan.GetStop().GetFrame() );
	mValueRange = mValueSpan;

	AddGlobal( MANIPULATOR_GRAPH_SLIDER );
	AddCommand( "GraphFit" );
}
예제 #9
0
/* AddIntrinsic - add an intrinsic function to the global symbol table */
void AddIntrinsic(ParseContext *c, char *name, int index)
{
    AddGlobal(c, name, SC_CONSTANT, INTRINSIC_FLAG | index, 0);
}
예제 #10
0
/* AddGlobalConstantString - add a global constant string symbol to the symbol table */
Symbol *AddGlobalConstantString(ParseContext *c, const char *name, String *string)
{
    Symbol *sym = AddGlobal(c, &c->globals, name, SC_CONSTANT, &c->stringType, 0);
    sym->v.string = string;
    return sym;
}
예제 #11
0
/* AddFormalArgument - add a formal argument using the global heap */
Symbol *AddFormalArgument(ParseContext *c, SymbolTable *table, const char *name, Type *type, VMUVALUE offset)
{
    if (type->id == TYPE_ARRAY)
        type = ArrayTypeToPointerType(c, type);
    return AddGlobal(c, table, name, SC_LOCAL, type, offset);
}
예제 #12
0
/* AddGlobalConstantInteger - add a global constant integer symbol to the symbol table */
Symbol *AddGlobalConstantInteger(ParseContext *c, const char *name, VMVALUE value)
{
    Symbol *sym = AddGlobal(c, &c->globals, name, SC_CONSTANT, &c->integerType, 0);
    sym->v.value = value;
    return sym;
}
예제 #13
0
/* AddGlobalOffset - add a global symbol to the symbol table */
Symbol *AddGlobalOffset(ParseContext *c, const char *name, StorageClass storageClass, Type *type, VMUVALUE offset)
{
    return AddGlobal(c, &c->globals, name, storageClass, type, offset);
}
예제 #14
0
/* AddGlobalSymbol - add a global symbol to the symbol table */
Symbol *AddGlobalSymbol(ParseContext *c, const char *name, StorageClass storageClass, Type *type, Section *section)
{
    Symbol *sym = AddGlobal(c, &c->globals, name, storageClass, type, section ? section->offset : UNDEF_VALUE);
    sym->section = section;
    return sym;
}
예제 #15
0
파일: db_compiler.c 프로젝트: bihai/jhbasic
/* EnterBuiltInVariable - enter a built-in variable */
static void EnterBuiltInVariable(ParseContext *c, char *name, size_t size)
{
    uint8_t *p = ImageDataAlloc(c, size);
    AddGlobal(c, name, SC_VARIABLE,  (VMVALUE)(DATA_OFFSET + (p - (uint8_t *)c->dataBase)));
}
예제 #16
0
파일: db_compiler.c 프로젝트: bihai/jhbasic
/* EnterBuiltInFunction - enter a built-in function */
static void EnterBuiltInFunction(ParseContext *c, char *name, uint8_t *code, size_t codeSize)
{
    uint8_t *p = ImageTextAlloc(c, codeSize);
    memcpy(p, code, codeSize);
    AddGlobal(c, name, SC_CONSTANT,  (VMVALUE)(p - (uint8_t *)c->image));
}