Skip to content

Commit

Permalink
Update Concert to version 9.5
Browse files Browse the repository at this point in the history
* Update Concert to version 9.5.
* Add localtime_ns function to date standard library for time with
  nanoseconds.
  • Loading branch information
puckowski committed Jul 30, 2024
1 parent 6bb8bd6 commit 719fdcf
Show file tree
Hide file tree
Showing 22 changed files with 84 additions and 9 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Concert/.vs/Lang3/v17/.suo
Binary file not shown.
Binary file modified Concert/.vs/Lang3/v17/Browse.VC.db
Binary file not shown.
Binary file modified Concert/.vs/Lang3/v17/Browse.VC.db-shm
Binary file not shown.
Binary file modified Concert/.vs/Lang3/v17/fileList.bin
Binary file not shown.
Binary file added Concert/.vs/slnx.sqlite
Binary file not shown.
Binary file modified Concert/Lang3/Release/Lang3.iobj
Binary file not shown.
Binary file modified Concert/Lang3/Release/Lang3.ipdb
Binary file not shown.
4 changes: 3 additions & 1 deletion Concert/Lang3/Release/Lang3.log
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ C:\Users\fooba\Downloads\Concert Programming Language (0.0.8.4.1)\Lang3 - Copy\L
C:\Users\fooba\Downloads\Concert Programming Language (0.0.8.4.1)\Lang3 - Copy\Lang3 - Copy\Lang3\threadLibrary.h(34,74): warning C4100: 'argumentsSize': unreferenced formal parameter
C:\Users\fooba\Downloads\Concert Programming Language (0.0.8.4.1)\Lang3 - Copy\Lang3 - Copy\Lang3\dateLibrary.h(41,8): warning C4459: declaration of 'returnVar' hides global declaration
C:\Users\fooba\Downloads\Concert Programming Language (0.0.8.4.1)\Lang3 - Copy\Lang3 - Copy\Lang3\header.h(36,26): message : see declaration of 'returnVar'
C:\Users\fooba\Downloads\Concert Programming Language (0.0.8.4.1)\Lang3 - Copy\Lang3 - Copy\Lang3\dateLibrary.h(91,14): warning C4459: declaration of 'returnVar' hides global declaration
C:\Users\fooba\Downloads\Concert Programming Language (0.0.8.4.1)\Lang3 - Copy\Lang3 - Copy\Lang3\header.h(36,26): message : see declaration of 'returnVar'
C:\Users\fooba\Downloads\Concert Programming Language (0.0.8.4.1)\Lang3 - Copy\Lang3 - Copy\Lang3\keywordBreak.h(10,31): warning C4459: declaration of 'currentLine' hides global declaration
C:\Users\fooba\Downloads\Concert Programming Language (0.0.8.4.1)\Lang3 - Copy\Lang3 - Copy\Lang3\header.h(44,25): message : see declaration of 'currentLine'
C:\Users\fooba\Downloads\Concert Programming Language (0.0.8.4.1)\Lang3 - Copy\Lang3 - Copy\Lang3\keywordTry.h(14,29): warning C4459: declaration of 'currentLine' hides global declaration
Expand Down Expand Up @@ -165,7 +167,7 @@ C:\Users\fooba\Downloads\Concert Programming Language (0.0.8.4.1)\Lang3 - Copy\L
_Fn=int (__cdecl *)(int)
]
Generating code
99 of 4493 functions ( 2.2%) were compiled, the rest were copied from previous compilation.
99 of 4513 functions ( 2.2%) were compiled, the rest were copied from previous compilation.
0 functions were new in current compilation
9 functions had inline decision re-evaluated but remain unchanged
Finished generating code
Expand Down
Binary file modified Concert/Lang3/Release/main.obj
Binary file not shown.
Binary file modified Concert/Lang3/Release/vc143.pdb
Binary file not shown.
50 changes: 50 additions & 0 deletions Concert/Lang3/dateLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,54 @@ void libraryDateLocaltime(std::vector<std::wstring>& arguments, const int& argum
}
}

void libraryDateLocaltimeNs(std::vector<std::wstring>& arguments, const int& argumentsSize)
{
int r1;
bool createdVar;
Var* formatVar = getVar(arguments[2], r1, createdVar);

switch (formatVar->type)
{
case TYPE_STRING:
{
std::wstring* pstr = static_cast<std::wstring*>(formatVar->data);
std::wstring format = pstr[r1];
const wchar_t* formatCStr = format.c_str();

auto now = std::chrono::system_clock::now();
std::time_t now_time = std::chrono::system_clock::to_time_t(now);
auto now_us = std::chrono::time_point_cast<std::chrono::microseconds>(now);
auto now_ns = std::chrono::time_point_cast<std::chrono::nanoseconds>(now);

struct tm timeinfo;
localtime_s(&timeinfo, &now_time);

std::wstringstream wss;
wss << std::put_time(&timeinfo, formatCStr);

auto duration_since_epoch = now.time_since_epoch();
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(duration_since_epoch) % 1000;
auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(duration_since_epoch) % 1000;
auto nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(duration_since_epoch) % 1000;

wss << L'.' << std::setw(3) << std::setfill(L'0') << milliseconds.count()
<< L'.' << std::setw(3) << std::setfill(L'0') << microseconds.count()
<< L'.' << std::setw(3) << std::setfill(L'0') << nanoseconds.count();

std::wstring formatted_datetime = wss.str();

Var* returnVar = getVar(arguments[argumentsSize - 1], returnVarInt, createdRetVar);
std::wstring* returnData = static_cast<std::wstring*>(returnVar->data);

returnData[returnVarInt] = formatted_datetime;

break;
}
}

if (createdVar) {
delete formatVar;
}
}

#endif
4 changes: 2 additions & 2 deletions Concert/Lang3/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class WorkspaceStore;
class ObjectStore;

const std::wstring SOFTWARE_NAME = L"Concert";
const std::wstring SOFTWARE_VERSION_STRING = L"0.0.9.4";
const std::wstring SOFTWARE_VERSION_CODE = L"1425";
const std::wstring SOFTWARE_VERSION_STRING = L"0.0.9.5";
const std::wstring SOFTWARE_VERSION_CODE = L"1428";
const std::wstring SOFTWARE_AUTHOR = L"Daniel Puckowski";

extern std::unordered_map<std::wstring, std::wstring> varLockMap;
Expand Down
6 changes: 6 additions & 0 deletions Concert/Lang3/keywordCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,12 @@ void executeKeywordCall(const int &tokensSize, std::vector<std::wstring> &tokens

break;
}
case DATE_LOCALTIME_NS:
{
libraryDateLocaltimeNs(tokens, tokensSize);

break;
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions Concert/Lang3/standardLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ enum LibraryFunction
MATH_EXP = 63,
THREAD_HARDWARE_CONCURRENCY = 64,
THREAD_SLEEP = 65,
DATE_LOCALTIME = 66
DATE_LOCALTIME = 66,
DATE_LOCALTIME_NS = 67
};

std::vector<std::wstring>* stringLibraryFunctions = new std::vector<std::wstring>{ L"substring" , L"find", L"contains", L"length", L"to_int", L"to_double", L"char_at", L"wchar_at", L"char_to_string", L"wchar_to_string",
Expand All @@ -80,7 +81,7 @@ std::vector<std::wstring>* mathLibraryFunctions = new std::vector<std::wstring>{
L"long_to_double", L"double_to_long", L"absolute_value", L"sqrt", L"log10", L"round", L"floor", L"ceil", L"sin", L"cos", L"tan", L"get_pi", L"set_precision", L"exp" };
std::vector<std::wstring>* regexLibraryFunctions = new std::vector<std::wstring>{ L"regex_search", L"regex_match", L"regex_replace" };
std::vector<std::wstring>* threadLibraryFunctions = new std::vector<std::wstring>{ L"get_thread_id", L"hardware_concurrency", L"sleep" };
std::vector<std::wstring>* dateLibraryFunctions = new std::vector<std::wstring>{ L"localtime" };
std::vector<std::wstring>* dateLibraryFunctions = new std::vector<std::wstring>{ L"localtime", L"localtime_ns" };

thread_local const std::map<const std::wstring, std::vector<std::wstring>*> LIBRARY_IMPORT_MAP =
{
Expand Down Expand Up @@ -154,7 +155,8 @@ const std::map<const std::wstring, const LibraryFunction> LIBRARY_FUNCTION_MAP =
{ L"exp", MATH_EXP },
{ L"hardware_concurrency", THREAD_HARDWARE_CONCURRENCY },
{ L"sleep", THREAD_SLEEP },
{ L"localtime", DATE_LOCALTIME }
{ L"localtime", DATE_LOCALTIME },
{ L"localtime_ns", DATE_LOCALTIME_NS }
};
const std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<const std::wstring, const LibraryFunction>>>> LIBRARY_FUNCTION_MAP_END = LIBRARY_FUNCTION_MAP.end();

Expand Down
5 changes: 5 additions & 0 deletions Concert/Lang3/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,8 @@ string timeFormatted = "";
call localtime : "%Y-%m-%d %H:%M:%S" -> timeFormatted;

println timeFormatted;

timeFormatted = "";
call localtime_ns : "%Y-%m-%d %H:%M:%S" -> timeFormatted;

println timeFormatted;
Loading

0 comments on commit 719fdcf

Please sign in to comment.