コード例 #1
0
void SgIncrementalStack::AddPoints(SgBWSet* set)
{
    int nu = PopInt();
    SgBlackWhite col = PopInt();
    SgPointSet& s = (*set)[col];
    for (int i = 1; i <= nu; ++i)
    {
        SgPoint p = PopPoint();
        s.Include(p);
    }
}
コード例 #2
0
void SgIncrementalStack::AddPoints(SgPointSet* set)
{
    int nu = PopInt();
    SgEmptyBlackWhite col = PopInt();
    SG_UNUSED(col);
    for (int i = 1; i <= nu; ++i)
    {
        SgPoint p = PopPoint();
        set->Include(p);
    }
}
コード例 #3
0
ファイル: Library.cpp プロジェクト: tt-jsr/VMEngine
 void lib_substr(Machine& machine)
 {
     int len = PopInt(machine);
     int startPos = PopInt(machine);
     std::string s = PopString(machine);
     if (len == 0)
     {
         len = std::string::npos;
     }
     std::string r = s.substr(startPos, len);
     machine.stack.Push(r);
 }
コード例 #4
0
void SgIncrementalStack::SubtractAndAddPoints(SgBWSet* subtractset,
                                       SgPointSet* addset)
{
    int nu = PopInt();
    SgBlackWhite col = PopInt();
    SgPointSet& s1 = (*subtractset)[col];
    SgPointSet& s2 = (*addset);
    for (int i = 1; i <= nu; ++i)
    {
        SgPoint p = PopPoint();
        s1.Exclude(p);
        s2.Include(p);
    }
}
コード例 #5
0
ファイル: pragma.c プロジェクト: PanchoManera/cc65
static void WarnPragma (StrBuf* B)
/* Enable/disable warnings */
{
    long   Val;
    int    Push;

    /* A warning name must follow */
    IntStack* S = GetWarning (B);
    if (S == 0) {
        return;
    }

    /* Comma follows */
    if (!GetComma (B)) {
        return;
    }

    /* Check for the "push" or "pop" keywords */
    switch (ParsePushPop (B)) {

        case PP_NONE:
            Push = 0;
            break;

        case PP_PUSH:
            Push = 1;
            break;

        case PP_POP:
            /* Pop the old value and bail out */
            PopInt (S);
            return;

        case PP_ERROR:
            /* Bail out */
            return;

        default:
            Internal ("Invalid result from ParsePushPop");
    }

    /* Boolean argument follows */
    if (HasStr (B, "true") || HasStr (B, "on")) {
        Val = 1;
    } else if (HasStr (B, "false") || HasStr (B, "off")) {
        Val = 0;
    } else if (!SB_GetNumber (B, &Val)) {
        Error ("Invalid pragma argument");
        return;
    }

    /* Set/push the new value */
    if (Push) {
        PushInt (S, Val);
    } else {
        IS_Set (S, Val);
    }
}
コード例 #6
0
ファイル: Library.cpp プロジェクト: tt-jsr/VMEngine
 void lib_arr_get(Machine& machine)
 {
     int idx = PopInt(machine);
     std::vector<Data> vec = PopArray(machine);
     if (idx < 0 || idx >= (int)vec.size())
     {
         std::stringstream strm;
         strm << "Index out of range";
         throw std::exception(strm.str().c_str());
     }
     Data d = vec[idx];
     machine.stack.Push(d);
 }
コード例 #7
0
ファイル: pragma.c プロジェクト: PanchoManera/cc65
static void IntPragma (StrBuf* B, IntStack* Stack, long Low, long High)
/* Handle a pragma that expects an int paramater */
{
    long  Val;
    int   Push;

    /* Check for the "push" or "pop" keywords */
    switch (ParsePushPop (B)) {

        case PP_NONE:
            Push = 0;
            break;

        case PP_PUSH:
            Push = 1;
            break;

        case PP_POP:
            /* Pop the old value and bail out */
            PopInt (Stack);
            return;

        case PP_ERROR:
            /* Bail out */
            return;

        default:
            Internal ("Invalid result from ParsePushPop");

    }

    /* Integer argument follows */
    if (!GetNumber (B, &Val)) {
        return;
    }

    /* Check the argument */
    if (Val < Low || Val > High) {
        Error ("Pragma argument out of bounds (%ld-%ld)", Low, High);
        return;
    }

    /* Set/push the new value */
    if (Push) {
        PushInt (Stack, Val);
    } else {
        IS_Set (Stack, Val);
    }
}
コード例 #8
0
ファイル: lists.cpp プロジェクト: gumpliao/label
int ClearIntList(IntList* list)
{
	if (list == NULL)
	{
		printf("ClearIntList: List is not initialised...\n");
		return -1;
	}

	while (list->count > 0)
	{
		PopInt(list);
	}

	return 0;
}
コード例 #9
0
ファイル: Library.cpp プロジェクト: tt-jsr/VMEngine
 void lib_strcmp(Machine& machine)
 {
     int ignoreCase = PopInt(machine);
     std::string a2 = PopString(machine);
     std::string a1 = PopString(machine);
     int n = 0;
     if (ignoreCase)
     {
         n = _stricmp(a1.c_str(), a2.c_str());
     }
     else
     {
         n = ::strcmp(a1.c_str(), a2.c_str());
     }
     machine.stack.Push(n);
 }
コード例 #10
0
ファイル: pragma.c プロジェクト: PanchoManera/cc65
static void FlagPragma (StrBuf* B, IntStack* Stack)
/* Handle a pragma that expects a boolean paramater */
{
    StrBuf Ident = AUTO_STRBUF_INITIALIZER;
    long   Val;
    int    Push;


    /* Try to read an identifier */
    int IsIdent = SB_GetSym (B, &Ident, 0);

    /* Check if we have a first argument named "pop" */
    if (IsIdent && SB_CompareStr (&Ident, "pop") == 0) {
        PopInt (Stack);
        /* No other arguments allowed */
        return;
    }

    /* Check if we have a first argument named "push" */
    if (IsIdent && SB_CompareStr (&Ident, "push") == 0) {
        Push = 1;
        if (!GetComma (B)) {
            goto ExitPoint;
        }
        IsIdent = SB_GetSym (B, &Ident, 0);
    } else {
        Push = 0;
    }

    /* Boolean argument follows */
    if (IsIdent) {
        Val = BoolKeyword (&Ident);
    } else if (!GetNumber (B, &Val)) {
        goto ExitPoint;
    }

    /* Set/push the new value */
    if (Push) {
        PushInt (Stack, Val);
    } else {
        IS_Set (Stack, Val);
    }

ExitPoint:
    /* Free the identifier */
    SB_Done (&Ident);
}