mirror of
https://onedev.site.tesses.net/crosslang
synced 2026-02-09 01:25:45 +00:00
Remove OnItteration due to bugs in multithreaded registering in tytd
This commit is contained in:
@@ -863,7 +863,7 @@ namespace Tesses::CrossLang
|
|||||||
EnsureSymbol("]");
|
EnsureSymbol("]");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(tokens[i].type != LexTokenType::Identifier) throw std::exception();
|
if(tokens[i].type != LexTokenType::Identifier) throw std::runtime_error("Not an identifier (member)");
|
||||||
std::string name = tokens[i].text;
|
std::string name = tokens[i].text;
|
||||||
if(name == "operator")
|
if(name == "operator")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,100 +6,6 @@
|
|||||||
namespace Tesses::CrossLang
|
namespace Tesses::CrossLang
|
||||||
{
|
{
|
||||||
|
|
||||||
class OnItterationObj : public TNativeObject
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
GC* gc;
|
|
||||||
std::vector<TCallable*> callables;
|
|
||||||
std::shared_ptr<Tesses::Framework::FunctionalEvent<uint64_t>> fevent;
|
|
||||||
public:
|
|
||||||
OnItterationObj(GC* gc)
|
|
||||||
{
|
|
||||||
this->gc=gc;
|
|
||||||
this->fevent = std::make_shared<Tesses::Framework::FunctionalEvent<uint64_t>>(
|
|
||||||
[this](uint64_t n)->void{
|
|
||||||
this->Exec(n);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
Tesses::Framework::OnItteraton += this->fevent;
|
|
||||||
}
|
|
||||||
~OnItterationObj()
|
|
||||||
{
|
|
||||||
Tesses::Framework::OnItteraton -= this->fevent;
|
|
||||||
}
|
|
||||||
std::string TypeName()
|
|
||||||
{
|
|
||||||
return "OnItteration";
|
|
||||||
}
|
|
||||||
TObject CallMethod(GCList& ls, std::string key, std::vector<TObject> args)
|
|
||||||
{
|
|
||||||
if(key == "operator+")
|
|
||||||
{
|
|
||||||
TCallable* callable;
|
|
||||||
if(GetArgumentHeap(args,0,callable))
|
|
||||||
{
|
|
||||||
gc->BarrierBegin();
|
|
||||||
bool found=false;
|
|
||||||
for(auto item : this->callables)
|
|
||||||
{
|
|
||||||
if(item == callable) {found=true; break;}
|
|
||||||
}
|
|
||||||
if(!found)
|
|
||||||
{
|
|
||||||
this->callables.push_back(callable);
|
|
||||||
}
|
|
||||||
gc->BarrierEnd();
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
if(key == "operator-")
|
|
||||||
{
|
|
||||||
TCallable* callable;
|
|
||||||
if(GetArgumentHeap(args,0,callable))
|
|
||||||
{
|
|
||||||
gc->BarrierBegin();
|
|
||||||
|
|
||||||
for(auto index = this->callables.begin(); index < this->callables.end(); index++)
|
|
||||||
{
|
|
||||||
if(*index == callable) {
|
|
||||||
this->callables.erase(index);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gc->BarrierEnd();
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
if(key == "ToString")
|
|
||||||
{
|
|
||||||
gc->BarrierBegin();
|
|
||||||
std::string str = "Registered: " + std::to_string(this->callables.size());
|
|
||||||
gc->BarrierEnd();
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
return Undefined();
|
|
||||||
}
|
|
||||||
void Mark()
|
|
||||||
{
|
|
||||||
if(this->marked) return;
|
|
||||||
this->marked=true;
|
|
||||||
|
|
||||||
for(auto item : callables) item->Mark();
|
|
||||||
}
|
|
||||||
void Exec(uint64_t n)
|
|
||||||
{
|
|
||||||
gc->BarrierBegin();
|
|
||||||
for(auto item : callables)
|
|
||||||
{
|
|
||||||
gc->BarrierEnd();
|
|
||||||
GCList ls(gc);
|
|
||||||
item->Call(ls,{(int64_t)n});
|
|
||||||
gc->BarrierBegin();
|
|
||||||
}
|
|
||||||
gc->BarrierEnd();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
static TObject AstToTObject(GCList& ls,SyntaxNode node)
|
static TObject AstToTObject(GCList& ls,SyntaxNode node)
|
||||||
{
|
{
|
||||||
if(std::holds_alternative<std::nullptr_t>(node))
|
if(std::holds_alternative<std::nullptr_t>(node))
|
||||||
@@ -378,7 +284,6 @@ namespace Tesses::CrossLang
|
|||||||
}
|
}
|
||||||
void TStd::RegisterVM(GC* gc,TRootEnvironment* env)
|
void TStd::RegisterVM(GC* gc,TRootEnvironment* env)
|
||||||
{
|
{
|
||||||
|
|
||||||
env->permissions.canRegisterVM=true;
|
env->permissions.canRegisterVM=true;
|
||||||
GCList ls(gc);
|
GCList ls(gc);
|
||||||
TDictionary* dict = TDictionary::Create(ls);
|
TDictionary* dict = TDictionary::Create(ls);
|
||||||
@@ -458,13 +363,12 @@ namespace Tesses::CrossLang
|
|||||||
return Undefined();
|
return Undefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
auto ittrobj = TNativeObject::Create<OnItterationObj>(ls,gc);
|
|
||||||
|
|
||||||
|
|
||||||
dict->SetValue("OnItteration", ittrobj);
|
|
||||||
env->DeclareVariable("VM", dict);
|
env->DeclareVariable("VM", dict);
|
||||||
|
|
||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,11 +129,14 @@ namespace Tesses::CrossLang
|
|||||||
|
|
||||||
void GC::BarrierBegin()
|
void GC::BarrierBegin()
|
||||||
{
|
{
|
||||||
|
|
||||||
this->mtx->Lock();
|
this->mtx->Lock();
|
||||||
}
|
}
|
||||||
void GC::BarrierEnd()
|
void GC::BarrierEnd()
|
||||||
{
|
{
|
||||||
|
|
||||||
this->mtx->Unlock();
|
this->mtx->Unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
void GC::Watch(TObject obj)
|
void GC::Watch(TObject obj)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ namespace Tesses::CrossLang {
|
|||||||
|
|
||||||
if(GetObjectHeap(obj,callable))
|
if(GetObjectHeap(obj,callable))
|
||||||
{
|
{
|
||||||
return ToBool(callable->Call(ls,{}));
|
return ToBool(callable->Call(ls,{right}));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(std::holds_alternative<std::nullptr_t>(right)) {
|
else if(std::holds_alternative<std::nullptr_t>(right)) {
|
||||||
@@ -235,9 +235,21 @@ namespace Tesses::CrossLang {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
|
||||||
|
return dict == std::get<THeapObjectHolder>(right).obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
return dict == std::get<THeapObjectHolder>(right).obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
return dict == std::get<THeapObjectHolder>(right).obj;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -404,7 +416,7 @@ namespace Tesses::CrossLang {
|
|||||||
auto env = cse.back()->env;
|
auto env = cse.back()->env;
|
||||||
if(!env->GetRootEnvironment()->HandleBreakpoint(gc, env, res))
|
if(!env->GetRootEnvironment()->HandleBreakpoint(gc, env, res))
|
||||||
{
|
{
|
||||||
throw std::exception();
|
throw std::runtime_error("Breakpoint unhandled");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user