Skip to content

Commit

Permalink
impl #527
Browse files Browse the repository at this point in the history
  • Loading branch information
MaartenHilferink committed Oct 4, 2023
1 parent 2ace54d commit 71b4efd
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 39 deletions.
46 changes: 42 additions & 4 deletions clc/dll/src/OperConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,13 +1266,51 @@ namespace

#define PI 3.14159265358979323846

CommonOperGroup cog_true("true");
CommonOperGroup cog_false("false");
CommonOperGroup cog_pi("pi");
CommonOperGroup cog_true(token::true_);
CommonOperGroup cog_false(token::false_);
CommonOperGroup cog_greekpi(token::pi);
CommonOperGroup cog_funcpi("pi");

CommonOperGroup cog_null_b(token::null_b);
CommonOperGroup cog_null_w(token::null_w);
CommonOperGroup cog_null_u(token::null_u);
CommonOperGroup cog_null_u64(token::null_u64);
CommonOperGroup cog_null_c(token::null_c);
CommonOperGroup cog_null_s(token::null_s);
CommonOperGroup cog_null_i(token::null_i);
CommonOperGroup cog_null_i64(token::null_i64);
CommonOperGroup cog_null_f(token::null_f);
CommonOperGroup cog_null_d(token::null_d);
CommonOperGroup cog_null_sp(token::null_sp);
CommonOperGroup cog_null_wp(token::null_wp);
CommonOperGroup cog_null_ip(token::null_ip);
CommonOperGroup cog_null_up(token::null_up);
CommonOperGroup cog_null_fp(token::null_fp);
CommonOperGroup cog_null_dp(token::null_dp);

ConstParamOperator<Bool> cpt(&cog_true, true);
ConstParamOperator<Bool> cpf(&cog_false, false);
ConstParamOperator<Float64> cppi(&cog_pi, PI);
ConstParamOperator<Float64> cppig(&cog_greekpi, PI);
ConstParamOperator<Float64> cppif(&cog_funcpi, PI);

ConstParamOperator<UInt8> cpp_null_b(&cog_null_b, UNDEFINED_VALUE(UInt8));
ConstParamOperator<UInt16> cpp_null_w(&cog_null_w, UNDEFINED_VALUE(UInt16));
ConstParamOperator<UInt32> cpp_null_u(&cog_null_u, UNDEFINED_VALUE(UInt32));
ConstParamOperator<UInt64> cpp_null_u64(&cog_null_u64, UNDEFINED_VALUE(UInt64));
ConstParamOperator<Int8> cpp_null_c(&cog_null_c, UNDEFINED_VALUE(Int8));
ConstParamOperator<Int16> cpp_null_s(&cog_null_s, UNDEFINED_VALUE(Int16));
ConstParamOperator<Int32> cpp_null_i(&cog_null_i, UNDEFINED_VALUE(Int32));
ConstParamOperator<Int64> cpp_null_i64(&cog_null_i64, UNDEFINED_VALUE(Int64));

ConstParamOperator<Float32> cpp_null_f(&cog_null_f, UNDEFINED_VALUE(Float32));
ConstParamOperator<Float64> cpp_null_d(&cog_null_d, UNDEFINED_VALUE(Float64));

ConstParamOperator<SPoint> cpp_null_sp(&cog_null_sp, UNDEFINED_VALUE(SPoint));
ConstParamOperator<WPoint> cpp_null_wp(&cog_null_wp, UNDEFINED_VALUE(WPoint));
ConstParamOperator<IPoint> cpp_null_ip(&cog_null_ip, UNDEFINED_VALUE(IPoint));
ConstParamOperator<UPoint> cpp_null_up(&cog_null_up, UNDEFINED_VALUE(UPoint));
ConstParamOperator<FPoint> cpp_null_fp(&cog_null_fp, UNDEFINED_VALUE(FPoint));
ConstParamOperator<DPoint> cpp_null_dp(&cog_null_dp, UNDEFINED_VALUE(DPoint));

CommonOperGroup cog_asDataString("asDataString");
AsDataStringOperator g_AsDataString(&cog_asDataString);
Expand Down
34 changes: 4 additions & 30 deletions stx/dll/src/ExprParse.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
//<HEADER>
/*
Data & Model Server (DMS) is a server written in C++ for DSS applications.
Version: see srv/dms/rtc/dll/src/RtcVersion.h for version info.
// Copyright (C) 2023 Object Vision b.v.
// License: GNU GPL 3
/////////////////////////////////////////////////////////////////////////////

Copyright (C) 1998-2004 YUSE GSO Object Vision BV.
Documentation on using the Data & Model Server software can be found at:
http://www.ObjectVision.nl/DMS/
See additional guidelines and notes in srv/dms/Readme-srv.txt
This library is free software; you can use, redistribute, and/or
modify it under the terms of the GNU General Public License version 2
(the License) as published by the Free Software Foundation,
provided that this entire header notice and readme-srv.txt is preserved.
See LICENSE.TXT for terms of distribution or look at our web site:
http://www.objectvision.nl/DMS/License.txt
or alternatively at: http://www.gnu.org/copyleft/gpl.html
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. However, specific warranties might be
granted by an additional written contract for support, assistance and/or development
*/
//</HEADER>
#pragma once

#if !defined(__STX_EXPRPARSE_H)
#define __STX_EXPRPARSE_H
Expand Down Expand Up @@ -106,9 +83,6 @@ struct expr_grammar : public boost::spirit::grammar<expr_grammar<Prod>>
chlit<> COMMA(',');
chlit<> UNDERSCORE('_');

strlit<> TRUE("true");
strlit<> FALSE("false");

chlit<> LPAREN('(');
chlit<> RPAREN(')');

Expand Down
2 changes: 1 addition & 1 deletion stx/dll/src/ExprProd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void ExprProd::ProdFunctionCall()

void ExprProd::ProdIdentifier(iterator_t first, iterator_t last)
{
dms_assert(first != last);
assert(first != last);
m_Result.push_back(LispRef(GetTokenID_mt(&*first, &*last)));
}

Expand Down
4 changes: 2 additions & 2 deletions tic/dll/src/AbstrCalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ SharedStr AbstrCalculator::EvaluateExpr(const TreeItem* context, CharPtrRange ex
{
AbstrCalculatorRef calculator = ConstructFromDirectStr(context, resultStr, cr);
auto res = CalcResult(calculator, DataArray<SharedStr>::GetStaticClass());
dms_assert(res);
assert(res);
if (res->WasFailed(FR_Data))
res->ThrowFail();

Expand All @@ -594,7 +594,7 @@ SharedStr AbstrCalculator::EvaluateExpr(const TreeItem* context, CharPtrRange ex
if (res->WasFailed(FR_Data))
res->ThrowFail();

dms_assert(resDataItem);
assert(resDataItem);
if (resDataItem->WasFailed(FR_Data)) resDataItem->ThrowFail();
if (resDataItem->WasFailed()) context->Fail(resDataItem);
resultStr = GetValue<SharedStr>(resDataItem, 0);
Expand Down
23 changes: 23 additions & 0 deletions tic/dll/src/LispTreeType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,29 @@ namespace token {

TIC_CALL TokenID true_ = GetTokenID_st("true");
TIC_CALL TokenID false_ = GetTokenID_st("false");
TIC_CALL TokenID pi = GetTokenID_st("?");
TIC_CALL TokenID null_b = GetTokenID_st("null_b");
TIC_CALL TokenID null_w = GetTokenID_st("null_w");
TIC_CALL TokenID null_u = GetTokenID_st("null_u");
TIC_CALL TokenID null_u64 = GetTokenID_st("null_u64");
TIC_CALL TokenID null_c = GetTokenID_st("null_c");
TIC_CALL TokenID null_s = GetTokenID_st("null_s");
TIC_CALL TokenID null_i = GetTokenID_st("null_i");
TIC_CALL TokenID null_i64 = GetTokenID_st("null_i64");
TIC_CALL TokenID null_f = GetTokenID_st("null_f");
TIC_CALL TokenID null_d = GetTokenID_st("null_d");
TIC_CALL TokenID null_sp = GetTokenID_st("null_sp");
TIC_CALL TokenID null_wp = GetTokenID_st("null_wp");
TIC_CALL TokenID null_ip = GetTokenID_st("null_ip");
TIC_CALL TokenID null_up = GetTokenID_st("null_up");
TIC_CALL TokenID null_fp = GetTokenID_st("null_fp");
TIC_CALL TokenID null_dp = GetTokenID_st("null_dp");

TIC_CALL bool isConst(TokenID t)
{
assert(true_.GetNr() + 19 == null_dp.GetNr());
return t >= true_ && t <= null_dp;
}

TIC_CALL TokenID arrow = GetTokenID_st("arrow");
TIC_CALL TokenID lookup = GetTokenID_st("lookup");
Expand Down
23 changes: 21 additions & 2 deletions tic/dll/src/LispTreeType.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,29 @@ namespace token {
extern TIC_CALL TokenID not_;

extern TIC_CALL TokenID iif;

extern TIC_CALL TokenID true_;
extern TIC_CALL TokenID false_;

inline bool isConst(TokenID t) { return t == true_ || t == false_; }
extern TIC_CALL TokenID pi;

extern TIC_CALL TokenID null_b;
extern TIC_CALL TokenID null_w;
extern TIC_CALL TokenID null_u;
extern TIC_CALL TokenID null_u64;
extern TIC_CALL TokenID null_c;
extern TIC_CALL TokenID null_s;
extern TIC_CALL TokenID null_i;
extern TIC_CALL TokenID null_i64;
extern TIC_CALL TokenID null_f;
extern TIC_CALL TokenID null_d;
extern TIC_CALL TokenID null_sp;
extern TIC_CALL TokenID null_wp;
extern TIC_CALL TokenID null_ip;
extern TIC_CALL TokenID null_up;
extern TIC_CALL TokenID null_fp;
extern TIC_CALL TokenID null_dp;

TIC_CALL bool isConst(TokenID t);

extern TIC_CALL TokenID arrow;
extern TIC_CALL TokenID lookup;
Expand Down

0 comments on commit 71b4efd

Please sign in to comment.