Skip to content

Commit

Permalink
Update Concert to version 9.6.alpha
Browse files Browse the repository at this point in the history
* Update Concert to version 9.6.alpha.
* Change detach and join keyword logic.
  • Loading branch information
puckowski committed Aug 9, 2024
1 parent d081810 commit 1a53b9c
Show file tree
Hide file tree
Showing 29 changed files with 512 additions and 288 deletions.
Binary file not shown.
Binary file not shown.
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/fileList.bin
Binary file not shown.
4 changes: 4 additions & 0 deletions Concert/Lang3/Lang3.vcxproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
<LocalDebuggerCommandArguments>test.txt 1</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommandArguments>image.cc 1</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
Binary file modified Concert/Lang3/Release/Lang3.iobj
Binary file not shown.
Binary file modified Concert/Lang3/Release/Lang3.ipdb
Binary file not shown.
469 changes: 213 additions & 256 deletions Concert/Lang3/Release/Lang3.log

Large diffs are not rendered by default.

Binary file modified Concert/Lang3/Release/Lang3.tlog/CL.command.1.tlog
Binary file not shown.
Binary file modified Concert/Lang3/Release/Lang3.tlog/CL.read.1.tlog
Binary file not shown.
Binary file not shown.
Binary file modified Concert/Lang3/Release/Lang3.tlog/link.read.1.tlog
Binary file not shown.
Binary file modified Concert/Lang3/Release/main.obj
Binary file not shown.
Binary file modified Concert/Lang3/Release/vc143.pdb
Binary file not shown.
Binary file added Concert/Lang3/castle.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 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.5";
const std::wstring SOFTWARE_VERSION_CODE = L"1507";
const std::wstring SOFTWARE_VERSION_STRING = L"0.0.9.6";
const std::wstring SOFTWARE_VERSION_CODE = L"1527";
const std::wstring SOFTWARE_AUTHOR = L"Daniel Puckowski";

extern std::unordered_map<std::wstring, std::wstring> varLockMap;
Expand All @@ -47,6 +47,7 @@ extern thread_local int returnVarInt;
extern thread_local bool createdRetVar;
extern thread_local int tryBlockCount;

extern int threadCount;
extern std::mutex callNameMutex;
extern std::vector<std::wstring> callNameStack;
extern bool debugEnabled;
Expand Down
Binary file added Concert/Lang3/homogeneity_test.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
246 changes: 246 additions & 0 deletions Concert/Lang3/image.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
import image;
import math;

string inputFile;
inputFile = "castle.jpg";

string imgData1 = "imgData1";
call read_channel_data : inputFile, imgData1;

int imageChannelLength = imgData1.width * imgData1.height;
println "Width x Height: ", imgData1.width, " ", imgData1.height;
println "Image channel length: ", imageChannelLength;
int outputLength = imageChannelLength * 3;

int homogeneityOutput outputLength;

int imageInput imageChannelLength;

function collapseChannels : using imageInput, using imgData1.red, using imgData1.green, using imgData1.blue, int as length;
int index = 0;
int accum;

while index < length;
accum = 0;

accum += red[index];
accum += green[index];
accum += blue[index];

accum = accum / 3;

imageInput[index] = accum;

index = index + 1;

int mod = index % 1000;

if mod == 0;
println index;
end;
end;
return;

call collapseChannels : imageInput, imgData1.red, imageData1.green, imageData1.blue, imageChannelLength;

int high;
int new_hi;
int new_low;
int userThreshold;

userThreshold = 40;
high = userThreshold;

new_hi = 255;
new_low = 0;

function process : using imageInput, using homogeneityOutput, int as start, int as endIndex, using inputWidth;
lock m;
int rowStart;
int colStart;

int rowEnd;
int colEnd;

rowStart = start + 1;
rowEnd = endIndex - 1;
unlock m;

colEnd = inputWidth;

int maxDiff;

int aStart;
int aEnd;
int bStart;
int bEnd;

aEnd = 1;
bEnd = 1;

int index;
int diff;
int diff2;

int tempRow;

while rowStart <= rowEnd;
colStart = 1;

while colStart < colEnd;
maxDiff = 0;

aStart = -1;
bStart = -1;

while aStart <= aEnd;
while bStart <= bEnd;
index = rowStart * inputWidth;
index = index - inputWidth;
index = index + colStart;

diff = imageInput[index];

index = (rowStart + aStart) * inputWidth;
index = index - inputWidth;
index = index + (colStart + bStart);

diff2 = imageInput[index];

diff = diff - diff2;
call absolute_value : diff -> diff;

if diff > maxDiff;
maxDiff = diff;
end;

bStart = bStart + 1;
end;

aStart = aStart + 1;
bStart = -1;
end;

index = rowStart * inputWidth;
index = index - inputWidth;
index = index + colStart;

homogeneityOutput[index] = maxDiff;

colStart = colStart + 1;
end;

rowStart = rowStart + 1;
end;
return;

int targetNumberOfThreads;
targetNumberOfThreads = 4;

mutex m;

function createThreads : int as targetNumberOfThreads, using imgData1, using imageInput, using homogeneityOutput;
int rowsPerThread = imgData1.height;
int inputWidth = imgData1.width;
rowsPerThread = rowsPerThread / targetNumberOfThreads;
int start = 1;
int endIndex = rowsPerThread;

int numberOfThreads = 0;
int oneLessThanTarget = targetNumberOfThreads - 1;

while numberOfThreads < targetNumberOfThreads;
if numberOfThreads < oneLessThanTarget;
endIndex = endIndex + 1;
end;

detach process : imageInput, homogeneityOutput, start, endIndex, inputWidth;

if numberOfThreads < oneLessThanTarget;
endIndex = endIndex - 1;
end;

numberOfThreads = numberOfThreads + 1;

start = endIndex;
endIndex = endIndex + rowsPerThread;
println endIndex;
end;
return;

println "Starting...";

join createThreads : targetNumberOfThreads, imgData1, imageInput, homogeneityOutput;

println "Writing homogeneity array...";

object out1;
int out1.red imageChannelLength;
int out1.green imageChannelLength;
int out1.blue imageChannelLength;
int out1.width 1;
out1.width = imgData1.width;
int out1.height 1;
out1.height = imgData1.height;

int hi = 0;
int lastRow = imageChannelLength - out1.width;
int widthMinusOne = out1.width - 1;

while hi < imageChannelLength;
if hi < out1.width;
out1.red[hi] = 0;
out1.green[hi] = 0;
out1.blue[hi] = 0;

hi = hi + 1;

continue;
end;

if hi >= lastRow;
out1.red[hi] = 0;
out1.green[hi] = 0;
out1.blue[hi] = 0;

hi = hi + 1;

continue;
end;

int mod = hi % out1.width;

if mod == 0;
out1.red[hi] = 0;
out1.green[hi] = 0;
out1.blue[hi] = 0;

hi = hi + 1;

continue;
end;

if mod == widthMinusOne;
out1.red[hi] = 0;
out1.green[hi] = 0;
out1.blue[hi] = 0;

hi = hi + 1;

continue;
end;

out1.red[hi] = homogeneityOutput[hi];
out1.green[hi] = homogeneityOutput[hi];
out1.blue[hi] = homogeneityOutput[hi];

hi = hi + 1;
end;

string outputFile = "homogeneity_test.jpg";
int writeResult = 0;
call write_channel_data : outputFile, "out1" -> writeResult;

println "Write result: ", writeResult;

println "Done.";
22 changes: 22 additions & 0 deletions Concert/Lang3/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,27 @@ void exec(int &line, bool detached, CodeStore* myCodeStore, WorkspaceStore* myWo
{
execLoop(tokens);
}
catch (const std::exception& exc)
{
if (debugEnabled == true)
{
std::cout << std::endl;
std::cout << "exception occurred: " << exc.what() << std::endl;
std::cout << "current line: " << (currentLine + 1) << std::endl;
for (std::wstring tok : tokens)
{
std::wcout << tok << " ";
}
std::cout << std::endl;
std::cout << "current thread id: " << std::this_thread::get_id() << std::endl;
std::cout << "main thread id: " << mainThreadId << std::endl;
std::cout << "call stack: " << std::endl;
for (auto it = callNameStack.rbegin(); it != callNameStack.rend(); ++it)
{
std::wcout << *it << std::endl;
}
}
}
catch (...)
{
if (debugEnabled == true)
Expand Down Expand Up @@ -370,6 +391,7 @@ void exec(int &line, bool detached, CodeStore* myCodeStore, WorkspaceStore* myWo
{
delete myCodeStore;
delete myWorkspaceStore;
threadCount--;
}
}

Expand Down
31 changes: 8 additions & 23 deletions Concert/Lang3/keywordDetach.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ void executeKeywordDetach(const int &tokensSize, std::vector<std::wstring> &toke

Var* v = nullptr;
int r1;
bool createdV = false;

for (int i = 2; i < tokensSize2; ++i)
for (int i = 2, tI = 2; i < tokensSize2; ++i, ++tI)
{
if (tokens2[i] == L"using")
{
i++;

Var* var = getVar(tokens[i - 1], r1);
Var* var = getVar(tokens[tI], r1);

ws->getStore()->addVar(var);
var->reassignCount++;
Expand All @@ -43,48 +41,35 @@ void executeKeywordDetach(const int &tokensSize, std::vector<std::wstring> &toke
}
else
{
auto type = RESERVED_WORD_IDENTIFIER_MAP.find(tokens[i]);

if (type != RESERVED_WORD_IDENTIFIER_MAP.end())
{
v = getVarFromLastWorkspace(callStack.front(), type->second, r1, createdV);
}
else
{
v = getVarFromLastWorkspace(callStack.front(), r1, createdV);
}
v = gWorkspaceStore->getStore()->getVar(callStack.front(), r1);

callStack.erase(callStack.begin());

if (tokens[i + 2] == L"&")
if (tokens[tI] == L"&")
{
i += 3;

gWorkspaceStore->getStore()->addVarAliasWithPointer(v, r1, tokens[i]);
gWorkspaceStore->getStore()->addVarAliasWithPointer(v, r1, tokens[tI]);
}
else
{
i += 2;

ws->getStore()->addVar(tokens[i], v->type, v->size);
Var* v2 = ws->getStore()->getVar(tokens[i], r1);
ws->getStore()->addVar(tokens[tI], v->type, v->size);
Var* v2 = ws->getStore()->getVar(tokens[tI], r1);

for (int n = 0; n < v->size; ++n)
{
execAssignOperator(v2, n, v, n);
}
}

if (createdV)
{
delete v;
}
}
}

bool b = true;
int linetmp = 0;
std::thread t(exec, std::ref(linetmp), b, newCodeStore, ws, 0, 0);
threadCount++;
t.detach();
}

Expand Down
Loading

0 comments on commit 1a53b9c

Please sign in to comment.