Пример #1
0
static
Value *
eval(const Ast *expr) {
	switch(expr->class) {
	case N_CALL:
		return call(expr);
	case N_ASSIGNMENT:
		return assignment(expr);
	case N_IDENTIFIER:
		return identifier(expr);
	case N_NEG:
		return _neg(expr);
	case N_NOT:
		return _not(expr);
	case N_EQ:
		return _eq(expr);
	case N_NEQ:
		return _neq(expr);
	case N_AND:
		return _and(expr);
	case N_IOR:
		return _ior(expr);
	case N_XOR:
		return _neq(expr); // alias
	case N_LT:
		return _lt(expr);
	case N_LE:
		return _le(expr);
	case N_GE:
		return _ge(expr);
	case N_GT:
		return _gt(expr);
	case N_ADD:
		return _add(expr);
	case N_SUB:
		return _sub(expr);
	case N_MUL:
		return _mul(expr);
	case N_DIV:
		return _div(expr);
	case N_POW:
		return _pow(expr);
	case N_MOD:
		return _mod(expr);
	case N_BOOLEAN:
		return _bool(expr);
	case N_INTEGER:
		return _int(expr);
	case N_FLOAT:
		return _float(expr);
	case N_STRING:
		return _string(expr);
	case N_SET:
		return _set(expr);
	case N_R:
		return _relation(expr);
	}
printf("EVALFAIL %d ", expr->class); pn(expr);
	assert(false && "should not be reached");
}
Пример #2
0
void Parser::conjunct_list() {
    _bool();
    if (lookahead == "&&") {
        match("&&");
        conjunct_list();
    }
}
Пример #3
0
static void _test_parse_bool(void *fixture)
{
	static struct pb_test _tests[] = {
		{"", false, false},
		{"fish", false, false},
		{"true", false, false},
		{"false", false, false},
		{"1", true, true},
		{" \t 1\t\t", true, true},
		{"0", true, false},
		{"  \t0  ", true, false}
	};

	unsigned i;

	for (i = 0; i < DM_ARRAY_SIZE(_tests); i++) {
		bool result;
		struct pb_test *t = _tests + i;

		if (t->parsed) {
			if (!_parse_bool(t->input, &result))
				test_fail("_parse_bool('%s') unexpectedly failed", t->input);
			if (result != t->result)
				test_fail("_parse_bool('%s') -> %s", t->input, _bool(result));
		} else {
			if (_parse_bool(t->input, &result))
				test_fail("_parse_bool('%s') unexpectedly succeeded", t->input);
		}
	}
}
Пример #4
0
 carve::mesh::MeshSet<3> *createMesh(const Options &options) const {
   Options::const_iterator i;
   carve::mesh::MeshOptions opts;
   i = options.find("avoid_cavities");
   if (i != options.end()) {
     opts.avoid_cavities(_bool((*i).second));
   }
   return new carve::mesh::MeshSet<3>(points, faceCount, faceIndices, opts);
 }
Пример #5
0
 carve::mesh::MeshSet<3> *createMesh(const Options &options,double EPSILON2 = 1e-10, bool flipBadFaces=false ) const {
   Options::const_iterator i;
   carve::mesh::MeshOptions opts;
   i = options.find("avoid_cavities");
   if (i != options.end()) {
     opts.avoid_cavities(_bool((*i).second));
   }
   return new carve::mesh::MeshSet<3>(points, faceCount, faceIndices,opts, EPSILON2, flipBadFaces );
 }
Пример #6
0
	void Test()
	{
	
		DBGTRACE(_T("--------------------------------------------------"));

		Variant _int(99);
		DBGTRACE(_T("%s : %d"), _int.GetString().c_str(), _int.GetInt());
		
		Variant _float(1.5f);
		DBGTRACE(_T("%s : %f"), _float.GetString().c_str(), _float.GetFloat());

		Variant _bool(true);
		DBGTRACE(_T("%s : %d"), _bool.GetString().c_str(), _bool.GetBool());
	}
Пример #7
0
INT_PTR CSetPgApps::OnButtonClicked(HWND hDlg, HWND hBtn, WORD nCtrlId)
{
	// First we process "Main" buttons, controlling application list
	switch (nCtrlId)
	{
	case cbAppDistinctReload:
		DoReloadApps();
		return 0;
	case cbAppDistinctAdd:
		DoAppAdd();
		return 0;
	case cbAppDistinctDel:
		DoAppDel();
		return 0;
	case cbAppDistinctUp:
	case cbAppDistinctDown:
		DoAppMove(nCtrlId == cbAppDistinctUp);
		return 0;
	}

	BOOL bChecked;
	int iCur = mb_SkipSelChange ? -1 : (int)SendDlgItemMessage(hDlg, lbAppDistinct, LB_GETCURSEL, 0,0);
	AppSettings* pApp = (iCur < 0) ? NULL : gpSet->GetAppSettingsPtr(iCur);
	_ASSERTE((iCur<0) || (pApp && pApp->AppNames));

	if (!pApp)
	{
		_ASSERTE(pApp!=NULL);
		return 0;
	}

	switch (nCtrlId)
	{
	case rbAppDistinctElevatedOn:
	case rbAppDistinctElevatedOff:
	case rbAppDistinctElevatedIgnore:
		pApp->Elevated = isChecked(hDlg, rbAppDistinctElevatedOn) ? 1
			: isChecked(hDlg, rbAppDistinctElevatedOff) ? 2
			: 0;
		mb_Refill = true;
		mb_Redraw = true;
		break;


	case cbColorsOverride:
		bChecked = isChecked(mh_Child, nCtrlId);
		DoEnableControls(cbColorsOverride);
		pApp->OverridePalette = _bool(bChecked);
		mb_Redraw = true;
		// Обновить палитры
		gpSet->PaletteSetStdIndexes();
		// Обновить консоли (считаем, что меняется только TextAttr, Popup не трогать
		gpSetCls->UpdateTextColorSettings(TRUE, FALSE, pApp);
		break;

	case cbCursorOverride:
		bChecked = isChecked(mh_Child, nCtrlId);
		DoEnableControls(cbCursorOverride);
		pApp->OverrideCursor = _bool(bChecked);
		mb_Redraw = true;
		break;

	case rCursorH:
	case rCursorV:
	case rCursorB:
	case rCursorR:
	case cbCursorColor:
	case cbCursorBlink:
	case cbCursorIgnoreSize:
	case cbInactiveCursor:
	case rInactiveCursorH:
	case rInactiveCursorV:
	case rInactiveCursorB:
	case rInactiveCursorR:
	case cbInactiveCursorColor:
	case cbInactiveCursorBlink:
	case cbInactiveCursorIgnoreSize:
		OnButtonClicked_Cursor(mh_Child, nCtrlId, isChecked(hDlg, nCtrlId), pApp);
		mb_Redraw = true;
		break;

	case cbExtendFontsOverride:
		bChecked = isChecked(mh_Child, nCtrlId);
		DoEnableControls(cbExtendFontsOverride);
		pApp->OverrideExtendFonts = isChecked2(mh_Child, nCtrlId);
		mb_Redraw = true;
		break;
	case cbExtendFonts:
		pApp->isExtendFonts = isChecked2(mh_Child, nCtrlId);
		mb_Redraw = true;
		break;

	case cbClipboardOverride:
		bChecked = isChecked(mh_Child, nCtrlId);
		DoEnableControls(cbClipboardOverride);
		pApp->OverrideClipboard = isChecked2(mh_Child, nCtrlId);
		break;

	case rPasteM1MultiLine:
	case rPasteM1FirstLine:
	case rPasteM1SingleLine:
	case rPasteM1Nothing:
		switch (nCtrlId)
		{
		case rPasteM1MultiLine:
			pApp->isPasteAllLines = plm_Default; break;
		case rPasteM1FirstLine:
			pApp->isPasteAllLines = plm_FirstLine; break;
		case rPasteM1SingleLine:
			pApp->isPasteAllLines = plm_SingleLine; break;
		case rPasteM1Nothing:
			pApp->isPasteAllLines = plm_Nothing; break;
		}
		break;
	case cbPasteM1Posix:
		pApp->isPosixAllLines = isChecked2(mh_Child, nCtrlId) ? pxm_Auto : pxm_Intact; break;
	case rPasteM2MultiLine:
	case rPasteM2FirstLine:
	case rPasteM2SingleLine:
	case rPasteM2Nothing:
		switch (nCtrlId)
		{
		case rPasteM2MultiLine:
			gpSet->AppStd.isPasteFirstLine = plm_MultiLine; break;
		case rPasteM2FirstLine:
			gpSet->AppStd.isPasteFirstLine = plm_FirstLine; break;
		case rPasteM2SingleLine:
			gpSet->AppStd.isPasteFirstLine = plm_Default; break;
		case rPasteM2Nothing:
			gpSet->AppStd.isPasteFirstLine = plm_Nothing; break;
		}
		break;
	case cbPasteM2Posix:
		pApp->isPosixFirstLine = isChecked2(mh_Child, nCtrlId) ? pxm_Auto : pxm_Intact; break;

	case cbCTSDetectLineEnd:
		pApp->isCTSDetectLineEnd = isChecked2(mh_Child, nCtrlId);
		break;
	case cbCTSBashMargin:
		pApp->isCTSBashMargin = isChecked2(mh_Child, nCtrlId);
		break;
	case cbCTSTrimTrailing:
		pApp->isCTSTrimTrailing = isChecked(mh_Child, nCtrlId);
		break;
	case cbCTSClickPromptPosition:
		pApp->isCTSClickPromptPosition = isChecked(mh_Child, nCtrlId);
		break;
	case cbCTSDeleteLeftWord:
		pApp->isCTSDeleteLeftWord = isChecked(mh_Child, nCtrlId);
		break;

	}

	return 0;
}
Пример #8
0
bool CVConLine::ParseLine(bool abForce, unsigned anTextWidth, unsigned anFontWidth, unsigned anRow, wchar_t* apConCharLine, CharAttr* apConAttrLine, const wchar_t* const ConCharLine2, const CharAttr* const ConAttrLine2)
{
	const bool bNeedAlloc = (MaxBufferSize < anTextWidth);
	TextWidth = anTextWidth;
	FontWidth = anFontWidth;
	row = anRow;
	ConCharLine = apConCharLine;
	ConAttrLine = apConAttrLine;
	PartsCount = 0;

	NextDialog = true;
	NextDialogX = 0;
	CurDialogX1 = CurDialogX2 = CurDialogI = 0;
	CurDialogFlags = 0;

	isFilePanel = (mn_DialogAllFlags & (FR_LEFTPANEL|FR_RIGHTPANEL|FR_FULLPANEL)) != 0;

	//TODO: Extend to other old-scool managers?
	isFixFrameCoord = mp_RCon->isFar();

	if (bNeedAlloc && !AllocateMemory())
		return false;

	const bool bEnhanceGraphics = gpSet->isEnhanceGraphics;
	const bool bUseAlternativeFont = _bool(gpSet->isFixFarBorders);

	for (unsigned j = 0; j < TextWidth;)
	{
		bool bPair = ((j+1) < TextWidth);
		ucs32 wc = ucs32_from_wchar(ConCharLine+j, bPair);
		unsigned j2 = j + (bPair ? 2 : 1);

		const CharAttr attr = ConAttrLine[j];

		VConTextPart* p = TextParts+(PartsCount++);

		//TODO: DBCS cell number, it may differ from j
		p->Init(j, j, this);

		// Process Far Dialogs to justify rectangles and frames
		TextPartFlags dlgBorder = j ? isDialogBorderCoord(j) : TRF_None;

		/* *** Now we split our text line into parts with characters one "family" *** */

		_ASSERTE(p->Flags == TRF_None);

		if (dlgBorder)
		{
			p->Flags = dlgBorder | TRF_SizeFixed
				| (isCharBorderVertical(wc) ? TRF_TextPseudograph : TRF_None)
				//| (isCharSpaceSingle(wc) ? TRF_TextSpacing : TRF_None)
				| ((bUseAlternativeFont && isCharAltFont(wc)) ? TRF_TextAlternative : TRF_None)
				| ((bEnhanceGraphics && isCharProgress(wc)) ? TRF_TextProgress : TRF_None)
				;
		}
		else if (isCharSpaceSingle(wc))
		{
			// CJK Double-width space will be processed under isCharCJK
			p->Flags = TRF_TextSpacing;
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharSpaceSingle(ConCharLine[j2]))
				j2++;
		}
		else if (isCharSeparate(wc))
		{
			p->Flags = TRF_TextSeparate;
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharSeparate(ConCharLine[j2]))
				j2++;
		}
		// isCharProgress must be checked before isCharScroll!
		else if (bEnhanceGraphics && isCharProgress(wc))
		{
			p->Flags = TRF_TextProgress
				| ((bUseAlternativeFont && isCharAltFont(wc)) ? TRF_TextAlternative : TRF_None)
				;
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharProgress(ConCharLine[j2]))
				j2++;
		}
		// isCharScroll has wider range than isCharProgress, and comes after it
		else if (bEnhanceGraphics && isCharScroll(wc))
		{
			p->Flags = TRF_TextScroll
				| ((bUseAlternativeFont && isCharAltFont(wc)) ? TRF_TextAlternative : TRF_None)
				;
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharScroll(ConCharLine[j2]))
				j2++;
		}
		else if (bEnhanceGraphics && isCharTriangles(wc))
		{
			p->Flags = TRF_TextTriangles;
		}
		// Miscellaneous borders
		else if (isCharPseudographics(wc))
		{
			// Processed separately from isCharAltFont, because last may cover larger range
			p->Flags = TRF_TextPseudograph;
			if (bUseAlternativeFont && isCharAltFont(wc))
			{
				p->Flags |= TRF_TextAlternative;
				wchar_t wc2;
				if (!bPair)
				while ((j2 < TextWidth) && (ConAttrLine[j2] == attr)
					&& isCharPseudographics((wc2=ConCharLine[j2]))
					&& (!bEnhanceGraphics || !isCharScroll(wc2))
					&& !isCharBorderVertical(wc2)
					&& isCharAltFont(wc2))
					j2++;
			}
			else
			{
				wchar_t wc2;
				if (!bPair)
				while ((j2 < TextWidth) && (ConAttrLine[j2] == attr)
					&& isCharPseudographics((wc2=ConCharLine[j2]))
					&& (!bEnhanceGraphics || !isCharScroll(wc2))
					&& !isCharBorderVertical(wc2)
					)
					j2++;
			}
		}
		else if (isCharCJK(wc)) // Double-width characters (CJK, etc.)
		{
			// Processed separately from isCharAltFont, because last may cover larger range
			p->Flags = TRF_TextCJK;
			if (bUseAlternativeFont && isCharAltFont(wc))
			{
				p->Flags |= TRF_TextAlternative;
				wchar_t wc2;
				if (!bPair)
				while ((j2 < TextWidth) && (ConAttrLine[j2] == attr)
					&& isCharCJK((wc2=ConCharLine[j2]))
					&& isCharAltFont(wc2))
					j2++;
			}
			else
			{
				if (!bPair)
				while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharCJK(ConCharLine[j2]))
					j2++;
			}
		}
		else if (bUseAlternativeFont && isCharAltFont(wc))
		{
			p->Flags = TRF_TextAlternative;
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr) && isCharScroll(ConCharLine[j2]))
				j2++;
		}
		else
		{
			p->Flags = TRF_TextNormal;
			wchar_t wc2;
			// That's more complicated as previous branches,
			// we must break on all chars mentioned above
			if (!bPair)
			while ((j2 < TextWidth) && (ConAttrLine[j2] == attr)
				&& !isCharSpaceSingle((wc2=ConCharLine[j2]))
				&& !isCharSeparate(wc2)
				&& !isCharProgress(wc2)
				&& !isCharScroll(wc2)
				&& !isCharPseudographics(wc2)
				&& (wc2 != L'}') // Far Manager Panels mark "file name is trimmed"
				&& !(bUseAlternativeFont && isCharAltFont(wc2))
				//TODO: RTL/LTR
				)
				j2++;
		}

		/* *** We shall prepare this token (default/initial widths must be set) *** */
		_ASSERTE(j2>j);
		p->SetLen(j2-j, FontWidth);

		#if 0
		TotalLineWidth += p->TotalWidth;
		MinLineWidth += p->MinWidth;
		#endif

		/* Next part */
		j = j2;
	}

	return true;
}