• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

自作言語nullptrのインタープリターです。


Commit MetaInfo

修订版54c9ccaa2b2a4d4ba22188987566ef2404ad0e59 (tree)
时间2015-08-13 00:05:27
作者VOSystems <diverge.vosystems@gmai...>
CommiterVOSystems

Log Message

begin to create Load Identifier function

更改概述

差异

Binary files a/nullptr.sdf and b/nullptr.sdf differ
--- a/nullptr/Module.cpp
+++ b/nullptr/Module.cpp
@@ -13,7 +13,7 @@ nullptr interpreter
1313 using namespace std;
1414 using namespace VOSystemsNullptr::Core;
1515
16-inline VOSystemsNullptr::System::ModuleFunction SearchDLL(VOSystemsNullptr::System::Module module, string name);
16+inline LibraryFunction SearchDLL(Library lib, string name);
1717
1818 bool Module::Connect(std::string name)
1919 {
@@ -43,16 +43,16 @@ bool Module::Run(std::string name, BasicTypes::Int* paramInt, BasicTypes::String
4343
4444 switch(m_mf.mode){
4545 case System::NotFound:
46- case System::ReturnBool:
46+ case System::BoolType:
4747 default:
4848 return false;
4949 break;
50- case System::ReturnInt:
50+ case System::IntType:
5151 Core::IntFunc ifunc=(Core::IntFunc)GetProcAddress(m_module,"runRI");
5252 m_int=(*ifunc)(name,paramInt,paramString);
5353
5454 break;
55- case System::ReturnString:
55+ case System::StringType:
5656 Core::StrFunc sfunc=(Core::StrFunc)GetProcAddress(m_module,"runRS");
5757 m_str=(*sfunc)(name,paramInt,paramString);
5858 break;
@@ -72,18 +72,18 @@ bool Module::DisConnect(void)
7272 }
7373 }
7474
75-VOSystemsNullptr::System::ModuleFunction Module::DllSearch(std::string name)
75+LibraryFunction Module::DllSearch(std::string name)
7676 {
7777 this->m_modules.size();
7878 vector<thread> th(this->m_modules.size());
79- vector<future<System::ModuleFunction>> fu(this->m_modules.size());
79+ vector<future<LibraryFunction>> fu(this->m_modules.size());
8080
8181 for(size_t C=0; C<this->m_modules.size(); C++){
82- System::Module mod=m_modules[C];
82+ Library mod=m_modules[C];
8383 fu[C]=async([mod,name](string){SearchDLL(mod,name);});//th[C]=thread([mod,name](){SearchDLL(mod,name);});
8484 }
8585
86- vector<System::ModuleFunction> result(this->m_modules.size());
86+ vector<LibraryFunction> result(this->m_modules.size());
8787 for(size_t C=0; C<this->m_modules.size(); C++){
8888 result[C]=fu[C].get();
8989 if(!result[C].mode==System::NotFound){
@@ -91,19 +91,19 @@ VOSystemsNullptr::System::ModuleFunction Module::DllSearch(std::string name)
9191 }
9292 }
9393
94- VOSystemsNullptr::System::ModuleFunction mf;
95- mf.mode=VOSystemsNullptr::System::NotFound;
94+ LibraryFunction mf;
95+ mf.mode=System::NotFound;
9696 return mf;
9797 }
9898
99-inline VOSystemsNullptr::System::ModuleFunction SearchDLL(VOSystemsNullptr::System::Module module, string name)
99+inline LibraryFunction SearchDLL(Library lib, string name)
100100 {
101- for(size_t C=0; C<module.size(); C++){
102- if(module[C].name==name){
103- return module[C];
101+ for(size_t C=0; C<lib.size(); C++){
102+ if(lib[C].name==name){
103+ return lib[C];
104104 }
105105 }
106- VOSystemsNullptr::System::ModuleFunction mf;
106+ LibraryFunction mf;
107107 mf.mode=VOSystemsNullptr::System::NotFound;
108108 return mf;
109109 }
\ No newline at end of file
--- a/nullptr/Module.h
+++ b/nullptr/Module.h
@@ -11,20 +11,28 @@ namespace VOSystemsNullptr
1111 {
1212 namespace Core
1313 {
14+ struct LibraryFunction{
15+ std::string name,dllname;
16+ unsigned char mode;
17+ unsigned char ArguInt,ArguBool,ArguString;
18+ };
19+
20+ typedef std::vector<struct LibraryFunction> Library;
21+
1422 typedef BasicTypes::String (*StrFunc)(std::string, BasicTypes::Int*,BasicTypes::String*);
1523 typedef BasicTypes::Int (*IntFunc)(std::string, BasicTypes::Int*,BasicTypes::String*);
1624
1725 class Module
1826 {
1927 private:
20- std::vector<System::Module> m_modules;
28+ std::vector<Library> m_modules;
2129 std::string m_CurrentConnectModuleName;
2230 HMODULE m_module;
23- System::ModuleFunction m_mf;
31+ LibraryFunction m_mf;
2432 BasicTypes::Int m_int;
2533 BasicTypes::String m_str;
2634
27- VOSystemsNullptr::System::ModuleFunction DllSearch(std::string name);
35+ LibraryFunction DllSearch(std::string name);
2836 public:
2937 bool Connect(std::string name);
3038 bool Run(std::string name, BasicTypes::Int* paramInt, BasicTypes::String* paramString);
--- a/nullptr/Preprocessor.cpp
+++ b/nullptr/Preprocessor.cpp
@@ -122,7 +122,7 @@ void Preprocessor::Trim(void)
122122 }while(!line.empty());
123123 }
124124
125-void Preprocessor::Load(System::Module& module)
125+void Preprocessor::LoadLib(Library& module)
126126 {
127127 regex func_regex(R"(.+ .+(Int \d+\s*,\s*String \d+\s*,\s*bool \d+\s*);*)");
128128 regex bool_regex(R"(bool .+(Int \d+\s*,\s*String \d+\s*,\s*bool \d+\s*);*)");
@@ -136,20 +136,20 @@ void Preprocessor::Load(System::Module& module)
136136 do{
137137 line=fop();
138138 if(regex_match(line,func_regex)){
139- System::ModuleFunction mf;
139+ LibraryFunction mf;
140140 mf.dllname=m_modulefiles[C];
141141 string::iterator start;
142142
143143 if(regex_match(line,bool_regex)){
144- mf.mode=System::ReturnBool;
144+ mf.mode=System::BoolType;
145145 start=line.begin()+5;
146146
147- }else if(regex_match(line,bool_regex)){
148- mf.mode=System::ReturnInt;
147+ }else if(regex_match(line,int_regex)){
148+ mf.mode=System::IntType;
149149 start=line.begin()+4;
150150
151- }else if(regex_match(line,bool_regex)){
152- mf.mode=System::ReturnString;
151+ }else if(regex_match(line,str_regex)){
152+ mf.mode=System::StringType;
153153 start=line.begin()+7;
154154
155155 }else{
@@ -173,4 +173,32 @@ void Preprocessor::Load(System::Module& module)
173173 }
174174 }while(!line.empty());
175175 }
176+}
177+
178+void Preprocessor::LoadId(System::IdentifierList& list)
179+{
180+ regex
181+ bool_regex(R"(bool[\s\t]+.+)"),
182+ int_regex(R"(Int[\s\t]+.+)"),
183+ str_regex(R"(String[\s\t]+.+)");
184+
185+ System::FileOperator fope(m_src,";");
186+ string line;
187+ System::Identifier id;
188+
189+ do{
190+ line=fope();
191+
192+ if(regex_match(line,bool_regex)){
193+ id.type=System::BoolType;
194+
195+ }else if(regex_match(line,int_regex)){
196+ id.type=System::IntType;
197+
198+ }else if(regex_match(line,str_regex)){
199+ id.type=System::StringType;
200+
201+ }
202+
203+ }while(!line.empty());
176204 }
\ No newline at end of file
--- a/nullptr/Preprocessor.h
+++ b/nullptr/Preprocessor.h
@@ -17,7 +17,8 @@ namespace VOSystemsNullptr
1717 Preprocessor(std::string source);
1818 void Extract(void);
1919 void Trim(void);
20- void Load(System::Module& module);
20+ void LoadLib(Library& module);
21+ void LoadId(System::IdentifierList& list);
2122 };
2223 }
2324 }
\ No newline at end of file
--- a/nullptr/nullptr.h
+++ b/nullptr/nullptr.h
@@ -82,28 +82,22 @@ namespace VOSystemsNullptr
8282 }
8383
8484 namespace System{
85+
86+ enum Types{
87+ NotFound=0,
88+ BoolType=1,
89+ IntType=2,
90+ StringType=4,
91+ };
92+
8593 typedef struct _Identifier{
8694 std::string name;
8795 std::streamoff pos;
96+ unsigned char type;
8897 }Identifier;
8998
9099 typedef std::vector<Identifier> IdentifierList;
91100
92- enum ModuleMode{
93- NotFound=0,
94- ReturnBool=1,
95- ReturnInt=2,
96- ReturnString=4,
97- };
98-
99- struct ModuleFunction{
100- std::string name,dllname;
101- unsigned char mode;
102- unsigned char ArguInt,ArguBool,ArguString;
103- };
104-
105- typedef std::vector<struct ModuleFunction> Module;
106-
107101 class FileOperator
108102 {
109103 private: