Catalog · How the catalog works
turbo-script.pas
- ★ 1 on GitHub
Anyone may press Interesting, signed in or not. It helps others find this project.
README
The Open Source TurboScript Infrastructure Framework
The execution speed of the script is close to the machine assembly language.
StaticClass Type -> Record Type -> Object Type -> Class Type
Purpose(Target):
- It can be a Interpreter.
- You can write your Interpreter by yourself.
- It's the fastest/smallest byte-code virtual machine.
- It can be a JITter like .Net.
- You can write your CLR(.Net) implementation like mono by yourself.
- It can be an Embeddable/Independence Compiler to generate the real machine code for processors.
- You can write your compiler by yourself.
- You can add your new syntax by yourself.
- It can be fully configurable.
- The Type System can be fully configurable and self-explained.
- It can be type-safety(StrongType): the types can have the typeInfo at runtime or not. (decided by yourself!)
- It can be named type. the types have the name of the type at runtime or not. (decided by yourself!)
Features:
- Highly Reusable Objects Engine
- Clearly demarcated layers
- Highly Separable.Components(Classes)
- Highly Scalable Engine
- Highly Configurable
- StrongType Supports or not
- The external function can Load On demand or PreLoad(Module).
- Self-explained Common Type System.
- distributed virtual machine.
- the CLR can call the functions in DLL or Host.
- the host can call any function in CLR.
- Executor Class Configurable(choose freely)
- Interpreter
- JITter
- Highly Configurable
- Highly Extensible Engine Highly Extensible Common Type System: all types(include system types) can be defined by developer themselves.
- High Speed with small footprint.
- Top Security
Roadmap:
I. The first Phase - Codename: TurboScript V 0.7[Done]: the simple execution efficiency test of the TurboScript engine is here: TurboCompiler: TurboForthCompiler TurboSymbol TurboModule TurboExecutor: TTurboInterpreter, TTurboX86Interpreter TurboAppDomain TurboModule Loader: TTurboModule File Loader
V 0.8: the Mini Compile-time/Runtime Core TurboPascalCompiler: TurboPascal RTL Library. TTurboModule DB Loader
V1.0: TurboCSharpCompiler, TurboBasicCompiler ... TurboTranslator TTurboJITExecutor TurboDebugger TTurboModule Web Loader
V1.1: Re-write the Mini Compile-time/Runtime Core with another languages(eg, C) to boot anther OS.
II. The Second Phase- Codename: TurboCompiler V2.0: TurboExecuteFileFormat: TurboExecuteFileFormat
III. The Third Phase - Codename: TurboUML V3.0: Design your all source code by UML editor like the Model Maker Tools. And generates the any supported high level language source code or compiles into execute binary file directly from UML automatically.
Layers:
- TurboModule Compiler
- TurboSymbol
- TurboTranslator
- TurboCompiler: compile the source into the TurboScript Virtual Machine code stream.
- TurboASMCompiler, TurboForthCompiler, TurboPascalCompiler, TurboCSharpCompiler, TurboBasicCompiler, etc
- TurboExecuteFileFormat: encode the translated native code stream to executable file formats which the OS supported.
- TurboPEFileFormat, TurboELFFileFormat
- TurboModule Executor
- TurboModule
- TurboExecutor
- TTurboInterpreter, TTurboX86Interpreter, TTurboJITExecutor
- TurboAppDomain
- TurboDebugger
- TurboModule Loader
- TTurboModule File Loader: load TurboScript module from File.
- TTurboModule DB Loader : load TurboScript module from DB.
- TTurboModule Web Loader : load TurboScript module from Web.
TurboModule Layer: the TurboScript Virtual Machine code in the memory. It's the smallest TurboScript Virtual Machine code unit in the memory. the TurboModule can be treated as a CLR Static Class.
TurboCompiler Layer: The Turbo Compiler compile the source into the TurboScript Virtual Machine code stream. Core Layer: TurboSymbol:
- Redesign the TurboSymbol Architecture(Compiler)
Application Layer: V1.0: USE THE COCO/R Tokenizer, Parser(the COCO/R implemented. TODO: Modify the COCO/R source to speedup.) TurboASMCompiler, TurboForthCompiler, TurboPascalCompiler, TurboCSharpCompiler, TurboBasicCompiler:
- Translate the source to the TurboSymbols.
- save to file stream
TurboTranslator Layer: translate the Virtual Machine Code into native code. TurboTranslator: abstract Translator TurboX86Translator: translate the Virtual Machine Code into the native code of X86 processors. TurboJitTranslator: translate the Virtual Machine Code into the simple genernal JITter native code.
TurboExecuteFileFormat: encode the translated native code stream to executable file formats which the OS supported. TurboExecuteFileFormat: abstract Executable Binary File Format. TurboPEFileFormat: Encode the native code to Windows PE File Format; TurboELFFileFormat: Encode the native code to Linux ELF File Format;
TurboExecutor Layer: The execution mechanism of the TurboScript Virtual Machine code stream.
TTurboInterpreter: TTurboX86Interpreter: the fastest interpreter(X86 optimal). TTurboJITExecutor: the Just In Time(JIT) executor. JITter can be security of the Virtual Machine Code.
TurboAppDomain: the minimal run-able script unit. It manages a TurboModule and an TurboExecutor.
TurboAccessor Layer: load and manage TurboModules in the memory. TTurboAccessor: the pure abstract accessor class: the module accessor and ModuleManager are derived from it. TTurboModuleAccessor: Abstract TurboModule Accessor[singleton] TTurboModuleManager: The TurboScript Module Manager. the GTurboModuleManager global variable manages all the loaded(cached) modules. And register the new ModuleAccessor to GTurboModuleManager.
Require method return the specified module. It first
searches in the memory if not found, try load the module
through registered module accessors.TTurboModuleFileAccessor: load TurboScript module from File. TTurboModuleDBAccessor: load TurboScript module from DB. TTurboModuleWebAccessor: load TurboScript module from Web.
Dependency Layers:
TurboCompiler --> TurboSymbol(symbol-tree) --> TurboModule(Virtual Machine Code) --> TurboExecutor ^
TurboAccessorTurboExecutor [-->TurboTranslator(Real Machine Code) --> TurboExecuteFileFormat(executable binary file formt)]
TurboAppDomain__|--> TurboModule |--> TurboExecutor
TurboSymbol Class Architecture(Compiler)
The first phrase of the TurboSymbol has done.
TurboCustomSymbol
* Public
* + Line, Column property
* + UnResolvedRefs Property: UnResolved symbol reference list of this symbol.
* + RefCount Property the count of this symbol is referenced.
* + OnError Event: TTurboCompilerErrorEvent = procedure(const Sender: TurboSymbol; const aErrCode: Integer) of object;
* + CompileError(const aErrCode: Integer);
* + Compile Method Compile this symbol and ResolveRefs when IsCompileAllowed.
* + ReferenceTo(const aSymbol: TurboSymbol) Method Reference this symbol into another symbol(MUST BE MethodSymbol or ModuleSymbol) and increase the RefCount. (????????????aSymbol????????????????????????,??????????????????+1)
* + ResolveRefs Method resolve all the address in the UnResolvedRefs list and clear the list when compile successful.
* + IsCompileAllowed:Boolean Virtual Method The symbol will be compiled only this returns true(RefCount > 0)
* + Assign(const aSymbol: TTurboCustomSymbol) Virtual Method Copy name and value of another symbol object.
* Protected
* + iCompile Virtual Method(Abstract)
* + iReferenceTo Virtual Method(Abstract) (????????????????????????,?????? UnResolvedRefRec ??????????????????????????????:UnResolvedRefs)
* + ResolveAddr Virtual Method(Abstract) (????????????????????????????????????????????????,????????????????????????,????????????. ????????????ResolveRefs ??????.)TurboSymbol(TurboCustomSymbol)
* + OwnerSymbol: TTurboModuleSymbol Property [^Todo: change type TTurboModuleSymbol to TTurboSymbol ]
* + CompileError(const aErrCode: Integer);
* + IsPublic: Boolean
* + IsTyped: Boolean
* + IsNamed: Boolean
* + override IsCompileAllowed:Boolean Virtual Method Return true()
* * Compile: Compile the symbol into the OwnerSymbol. (????????????OwnerSymbol??????)TTurboConstSymbol(TurboSymbol)
* + override iCompile Virtual Method (??????????????????,???????????????,????????????????????????????????????,??????????????????????????? Module.)
* + override iReferenceTo Virtual Method (??????????????? Method ??????! ?????????????????????????????????????????????????????????,???????????????????????? UnResolvedRefs(?????????????????????))
* + override ResolveAddr Virtual Method (????????????????????????????????????????????????????????????????????????aSymbol????????????.)TTurboVariableSymbol(TTurboConstSymbol)
* + override iCompile Virtual Method (????????????Public??????,???????????????????????????????????????????????????, ???Module ??? DataMemory?????????????????????,???????????????????????????.)
* + override iReferenceTo Virtual Method (??????????????? Method ??????! ??????????????????????????????,?????????????????????????????? UnResolvedRefs(?????????????????????))
* + override ResolveAddr Virtual Method (?????????????????????????????????????????????aSymbol????????????.)TTurboMethodSymbol(TurboSymbol)
* + override iCompile Virtual Method (?????????????????????????????????????????????(CompileRefSymbols),???????????? CodeFieldStyle ??????????????????.)
* + override iReferenceTo Virtual Method (??????????????? Method ??????! ?????? CodeFieldStyle ??????????????????,??????????????????????????????,?????????????????????????????? UnResolvedRefs(?????????????????????))
* + override ResolveAddr Virtual Method (?????? CodeFieldStyle ??????, ?????????????????????????????????????????????aSymbol????????????.)
* + BodyInit[^]: ???????????????????????????,???????????????: ????????????????????????????????? OwnerSymbol ?????????, ?????????????????????????????????,????????????????????????.
* + BodyFinal[^]: ????????????????????????,????????????! ??????????????????????????????????????????????????????????????????.????????????????????????????????????????????????????????????????????????TTurboModuleSymbol
如果没有OwnerSymbol的,就认为是主Module: 正在编译的Module, 否则就是 Module 的引用.[^]
* + override iCompile Virtual Method (???????????????OwnerSymbol, ????????????. ????????????????????????module,)
* + override iReferenceTo Virtual Method None (???,???????????????OK)
* + override ResolveAddr Virtual Method None (???)TurboTypeSymbol
* + override iCompile Virtual Method (?????????????????????????????????,?????????????????????????????? OwnerSymbol ???????????? RegisteredTypes ???.)
* + override iReferenceTo Virtual Method None (???,???????????????OK)
* + override ResolveAddr Virtual Method None (???)
