mirror of
https://git.tesses.org/tesses50/crosslang.git
synced 2026-11-30 17:51:53 +00:00
Add htmlparser, conditional variables, make alloc_threshold overridable in prefs.json
This commit is contained in:
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
|
||||
namespace Tesses::CrossLang {
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
+39
-2
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
@@ -97,6 +117,23 @@ TDictionary *CreateThread(GCList &ls, TCallable *callable, bool detached) {
|
||||
return dict;
|
||||
}
|
||||
void GC::Start() {
|
||||
using namespace Tesses::Framework::Serialization::Json;
|
||||
auto prefsFile = GetCrossLangConfigDir() / "prefs.json";
|
||||
if (Tesses::Framework::Filesystem::LocalFS->FileExists(prefsFile)) {
|
||||
try {
|
||||
JToken tkn = Json::Decode(
|
||||
Tesses::Framework::Filesystem::Helpers::ReadAllText(
|
||||
Tesses::Framework::Filesystem::LocalFS, prefsFile));
|
||||
JObject root;
|
||||
int64_t ittrs;
|
||||
if (TryGetJToken(tkn, root) &&
|
||||
root.TryGetValueAsType("alloc_threshold", ittrs)) {
|
||||
this->threshold = static_cast<uint32_t>(ittrs);
|
||||
}
|
||||
} catch (...) {
|
||||
this->threshold = ALLOC_THRESHOLD;
|
||||
}
|
||||
}
|
||||
|
||||
this->tpool = new Tesses::Framework::Lazy<
|
||||
Tesses::Framework::Threading::ThreadPool *>(
|
||||
@@ -113,7 +150,7 @@ void GC::Start() {
|
||||
this->thrd = new Thread([this]() -> void {
|
||||
while (this->IsRunning()) {
|
||||
this->BarrierBegin();
|
||||
while (this->IsRunning() && (this->allocs < ALLOC_THRESHOLD))
|
||||
while (this->IsRunning() && (this->allocs < this->threshold))
|
||||
this->cond.Wait(&this->mtx);
|
||||
this->allocs = 0;
|
||||
std::vector<THeapObject *> to_delete;
|
||||
@@ -146,7 +183,7 @@ void GC::Watch(TObject obj) {
|
||||
this->objects.insert(_item);
|
||||
auto nowAllocs = ++this->allocs;
|
||||
this->BarrierEnd();
|
||||
if (nowAllocs >= ALLOC_THRESHOLD)
|
||||
if (nowAllocs >= this->threshold)
|
||||
this->cond.Signal();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
|
||||
namespace Tesses::CrossLang {
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
CrossLang is a dynamically-typed scripting language built on
|
||||
TessesFramework, named in honor of Jesus's sacrifice.
|
||||
|
||||
Copyright (C) 2026 Mike Nolan
|
||||
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "CrossLang.hpp"
|
||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||
@@ -2727,6 +2747,31 @@ execute:
|
||||
if (stk->mustReturn) {
|
||||
|
||||
stk->mustReturn = false;
|
||||
|
||||
gc->BarrierBegin();
|
||||
GCList ls(gc);
|
||||
std::vector<TCallable *> callable;
|
||||
while (!cse.empty()) {
|
||||
auto r = cse.back();
|
||||
auto e = r->env;
|
||||
for (uint32_t i = 0; i < r->scopes; i++) {
|
||||
if (!e->defers.empty()) {
|
||||
ls.Add(e);
|
||||
callable.insert(callable.end(),
|
||||
e->defers.begin(),
|
||||
e->defers.end());
|
||||
}
|
||||
e = e->GetParentEnvironment();
|
||||
}
|
||||
cse.erase(cse.end() - 1);
|
||||
}
|
||||
gc->BarrierEnd();
|
||||
|
||||
for (auto item : callable) {
|
||||
GCList ls2(gc);
|
||||
item->Call(ls2, {});
|
||||
}
|
||||
|
||||
if (cse.size() > 1) {
|
||||
GCList ls(gc);
|
||||
TObject o = cse[cse.size() - 1]->Pop(ls);
|
||||
|
||||
Reference in New Issue
Block a user