mirror of
https://github.com/ValKmjolnir/Nasal-Interpreter.git
synced 2026-07-22 10:58:47 +08:00
basical elements
This commit is contained in:
+8
-21
@@ -445,35 +445,22 @@ NasalHash& NasalHash::operator=(const NasalHash &Source)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void NasalHash::SearchElement(std::string &ElementName)
|
||||
HashUnit NasalHash::SearchElement(std::string &ElementName)
|
||||
{
|
||||
HashUnit *temp=head;
|
||||
while(temp->next)
|
||||
{
|
||||
temp=temp->next;
|
||||
if(temp->VarName==ElementName)
|
||||
{
|
||||
if(temp->Type=="int")
|
||||
std::cout<<*((int *)temp->data);
|
||||
else if(temp->Type=="float")
|
||||
std::cout<<*((float *)temp->data);
|
||||
else if(temp->Type=="double")
|
||||
std::cout<<*((double *)temp->data);
|
||||
else if(temp->Type=="char")
|
||||
std::cout<<*((char *)temp->data);
|
||||
else if(temp->Type=="long long int")
|
||||
std::cout<<*((long long int *)temp->data);
|
||||
else if(temp->Type=="string")
|
||||
std::cout<<*((std::string *)temp->data);
|
||||
else if(temp->Type=="array")
|
||||
((NasalList *)temp->data)->PrintList();
|
||||
else if(temp->Type=="hash")
|
||||
((NasalHash *)temp->data)->PrintHash();
|
||||
return;
|
||||
}
|
||||
return *temp;
|
||||
}
|
||||
std::cout<<"[Error] Could not find \""<<ElementName<<"\""<<std::endl;
|
||||
return;
|
||||
HashUnit nil_hash;
|
||||
nil_hash.data=NULL;
|
||||
nil_hash.next=NULL;
|
||||
nil_hash.Type="null";
|
||||
nil_hash.VarName="null";
|
||||
return nil_hash;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user