├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .vscode └── launch.json ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── TODO.md ├── apply-license.sh ├── benchmark └── sum │ ├── sum.js │ └── sum.zen ├── doc ├── Doc.txt ├── annotations.md ├── binary-entity-format.txt ├── garbage-collector.md ├── generator │ └── University.zen └── introduction.md ├── example ├── BinarySearch.zen ├── BubbleSort.zen ├── MaxInteger.zen ├── PaymentCalculator.zen ├── SelectionSort.zen ├── SimpleDownloader.zen ├── ThrowStatement.zen ├── factorial │ └── factorial.zen ├── knn │ └── knn.z ├── linear-search │ └── LinearSearch.zen ├── read │ └── Read.z ├── student │ └── Student.zen └── sum-of-array │ └── SumOfArray.zen ├── include └── com │ └── onecube │ └── zen │ ├── Configuration.h │ ├── assembler │ └── AssemblyToken.h │ ├── compiler │ ├── Compiler.h │ ├── ast │ │ ├── ASTAnnotation.h │ │ ├── ASTAnnotationType.h │ │ ├── ASTAnnotations.h │ │ ├── ASTHelper.h │ │ ├── ASTListener.h │ │ ├── ASTNode.h │ │ ├── ASTNodeType.h │ │ ├── ASTPrinter.h │ │ ├── ASTWalker.h │ │ ├── ASTWalkerState.h │ │ ├── ExpressionAnnotation.h │ │ └── context │ │ │ ├── AdditiveExpressionContext.h │ │ │ ├── AndExpressionContext.h │ │ │ ├── AnnotatedComponentDeclarationContext.h │ │ │ ├── AnnotationAttributeContext.h │ │ │ ├── AnnotationContext.h │ │ │ ├── AnnotationTypeContext.h │ │ │ ├── AnnotationsContext.h │ │ │ ├── AssertStatementContext.h │ │ │ ├── AssignmentExpressionContext.h │ │ │ ├── BreakStatementContext.h │ │ │ ├── CatchClauseContext.h │ │ │ ├── CatchFilterContext.h │ │ │ ├── ClassDeclarationContext.h │ │ │ ├── ClassExtendsClauseContext.h │ │ │ ├── ClassMemberContext.h │ │ │ ├── ClassSuiteContext.h │ │ │ ├── CompilationUnitContext.h │ │ │ ├── ComponentDeclarationContext.h │ │ │ ├── CompoundStatementContext.h │ │ │ ├── ConditionalExpressionContext.h │ │ │ ├── ConstantDeclarationContext.h │ │ │ ├── ConstantDeclaratorContext.h │ │ │ ├── Context.h │ │ │ ├── ContinueStatementContext.h │ │ │ ├── ElseClauseContext.h │ │ │ ├── ElseIfClauseContext.h │ │ │ ├── EmptyStatementContext.h │ │ │ ├── EnumerateContext.h │ │ │ ├── EnumerationBaseClauseContext.h │ │ │ ├── EnumerationDeclarationContext.h │ │ │ ├── EnumerationSuiteContext.h │ │ │ ├── EqualityExpressionContext.h │ │ │ ├── ExclusiveOrExpressionContext.h │ │ │ ├── ExpressionContext.h │ │ │ ├── ExpressionsContext.h │ │ │ ├── FinallyClauseContext.h │ │ │ ├── ForParameterContext.h │ │ │ ├── ForStatementContext.h │ │ │ ├── FunctionArgumentsContext.h │ │ │ ├── FunctionBodyContext.h │ │ │ ├── FunctionDeclarationContext.h │ │ │ ├── FunctionParametersContext.h │ │ │ ├── IfClauseContext.h │ │ │ ├── IfStatementContext.h │ │ │ ├── ImportDeclarationContext.h │ │ │ ├── InclusiveOrExpressionContext.h │ │ │ ├── IterativeStatementContext.h │ │ │ ├── LabelClauseContext.h │ │ │ ├── ListExpressionContext.h │ │ │ ├── LogicalAndExpressionContext.h │ │ │ ├── LogicalOrExpressionContext.h │ │ │ ├── MapEntriesContext.h │ │ │ ├── MapEntryContext.h │ │ │ ├── MapExpressionContext.h │ │ │ ├── MemberAccessContext.h │ │ │ ├── MultiplicativeExpressionContext.h │ │ │ ├── NewExpressionContext.h │ │ │ ├── PostfixExpressionContext.h │ │ │ ├── PostfixOperatorContext.h │ │ │ ├── PrimaryExpressionContext.h │ │ │ ├── RelationalExpressionContext.h │ │ │ ├── ReturnStatementContext.h │ │ │ ├── ShiftExpressionContext.h │ │ │ ├── SimpleStatementContext.h │ │ │ ├── StatementContext.h │ │ │ ├── StatementSuiteContext.h │ │ │ ├── SubscriptContext.h │ │ │ ├── SynchronizeStatementContext.h │ │ │ ├── ThrowStatementContext.h │ │ │ ├── TryClauseContext.h │ │ │ ├── TryStatementContext.h │ │ │ ├── TypeNameContext.h │ │ │ ├── UnaryExpressionContext.h │ │ │ ├── VariableDeclarationContext.h │ │ │ ├── VariableDeclaratorContext.h │ │ │ ├── WhileStatementContext.h │ │ │ ├── WithParameterContext.h │ │ │ ├── WithParametersContext.h │ │ │ └── WithStatementContext.h │ ├── generator │ │ ├── BinaryEntityBuilder.h │ │ ├── BinaryEntityGenerator.h │ │ ├── ConstantPoolBuilder.h │ │ └── DataChannel.h │ ├── lexer │ │ ├── Lexer.h │ │ ├── LexerError.h │ │ ├── Token.h │ │ ├── TokenChannel.h │ │ ├── TokenStream.h │ │ └── TokenType.h │ ├── parser │ │ ├── Parser.h │ │ └── ParserError.h │ ├── support │ │ ├── Error.h │ │ ├── ErrorCode.h │ │ ├── ErrorHandler.h │ │ └── StackTrace.h │ └── symbol-table │ │ ├── ClassSymbol.h │ │ ├── FunctionSignature.h │ │ ├── FunctionSymbol.h │ │ ├── Modifier.h │ │ ├── Scope.h │ │ ├── ScopeType.h │ │ ├── Symbol.h │ │ ├── SymbolCategory.h │ │ ├── SymbolDefinitionListener.h │ │ ├── SymbolLoader.h │ │ ├── SymbolResolutionListener.h │ │ └── SymbolTable.h │ ├── disassembler │ └── BinaryEntityDisassembler.h │ └── virtual-machine │ ├── ExceptionManager.h │ ├── VirtualMachine.h │ ├── VirtualMachineConfiguration.h │ ├── VirtualMachineGarbageCollectorListener.h │ ├── feb │ ├── AuxillaryAttribute.h │ ├── BinaryEntityFormat.h │ ├── ByteCode.h │ ├── Entity.h │ ├── EntityFile.h │ ├── EntityFlag.h │ ├── EntityType.h │ ├── EnumerateEntity.h │ ├── EnumerationEntity.h │ ├── FebVersion.h │ ├── FieldEntity.h │ ├── FunctionEntity.h │ ├── Instruction.h │ ├── Type.h │ ├── attribute │ │ ├── Attribute.h │ │ ├── AttributeTable.h │ │ ├── ConstantValueAttribute.h │ │ ├── DeprecatedAttribute.h │ │ ├── ExceptionHandlerSite.h │ │ ├── ExceptionListAttribute.h │ │ ├── ExceptionTable.h │ │ ├── FunctionParameter.h │ │ ├── FunctionParametersAttribute.h │ │ ├── InstructionAttribute.h │ │ ├── LineNumberTableAttribute.h │ │ ├── LocalVariable.h │ │ ├── LocalVariableTableAttribute.h │ │ ├── ParentFunctionAttribute.h │ │ ├── ParentOtherAttribute.h │ │ ├── PredefinedAttribute.h │ │ ├── SourceFileAttribute.h │ │ └── SyntheticAttribute.h │ └── constant-pool │ │ ├── ConstantPool.h │ │ ├── ConstantPoolClass.h │ │ ├── ConstantPoolDouble.h │ │ ├── ConstantPoolEntry.h │ │ ├── ConstantPoolField.h │ │ ├── ConstantPoolFloat.h │ │ ├── ConstantPoolFunction.h │ │ ├── ConstantPoolInteger.h │ │ ├── ConstantPoolLong.h │ │ ├── ConstantPoolString.h │ │ ├── ConstantPoolTag.h │ │ └── ConstantPoolUtf8.h │ ├── loader │ ├── AttributeParseRules.h │ ├── BinaryEntityLoader.h │ ├── BinaryEntityParser.h │ ├── BinaryEntityVerifier.h │ ├── ClassLoader.h │ ├── EntityLoader.h │ ├── EntityResolver.h │ └── ResolutionManager.h │ ├── memory │ ├── MemoryManager.h │ ├── ObjectType.h │ ├── PendingMessageQueue.h │ ├── PrimaryMemoryManager.h │ ├── allocator │ │ ├── AlignmentConstraint.h │ │ ├── AllocationBuffer.h │ │ ├── AllocationFlag.h │ │ ├── Allocator.h │ │ ├── BestFitAllocator.h │ │ ├── FirstFitAllocator.h │ │ ├── SegregatedFitsAllocator.h │ │ ├── SegregatedFitsAllocatorMode.h │ │ ├── SequentialAllocator.h │ │ └── SizeClass.h │ ├── collector │ │ ├── GarbageCollectionFlag.h │ │ ├── GarbageCollectionListener.h │ │ ├── GarbageCollectionProfile.h │ │ ├── GarbageCollectionReason.h │ │ ├── GarbageCollectionType.h │ │ ├── GarbageCollector.h │ │ └── GarbageCollectorType.h │ ├── heap │ │ ├── Generation.h │ │ ├── Heap.h │ │ ├── ImmortalGeneration.h │ │ ├── NewGeneration.h │ │ ├── Object.h │ │ ├── OldGeneration.h │ │ └── Region.h │ └── module.h │ ├── object │ ├── Class.h │ ├── Field.h │ ├── Function.h │ ├── NativeFunction.h │ ├── Object.h │ └── ObjectArray.h │ └── processor │ ├── Interpreter.h │ ├── InvocationStack.h │ ├── LocalVariableArray.h │ ├── OperandStack.h │ ├── Processor.h │ ├── ProcessorThread.h │ └── StackFrame.h ├── lines.md ├── source ├── Zen.g4 └── com │ └── onecube │ └── zen │ ├── Configuration.c │ ├── DisassemblerTool.c │ ├── InputStream.c │ ├── RuleNode.c │ ├── String.c │ ├── StringBuilder.c │ ├── Zen.c │ ├── Zvm.c │ ├── ZvmSpecificationViewer.c │ ├── assember │ └── lexer │ │ └── AssemblyLexer.c │ ├── compiler │ ├── Compiler.c │ ├── ast │ │ ├── AstAnnotation.c │ │ ├── AstAnnotations.c │ │ ├── AstHelper.c │ │ ├── AstListener.c │ │ ├── AstNode.c │ │ ├── AstPrinter.c │ │ └── AstWalker.c │ ├── generator │ │ ├── BinaryEntityBuilder.c │ │ ├── BinaryEntityGenerator.c │ │ ├── ConstantPoolBuilder.c │ │ └── DataChannel.c │ ├── lexer │ │ ├── Lexer.c │ │ ├── LexerError.c │ │ ├── Token.c │ │ ├── TokenStream.c │ │ └── TokenType.c │ ├── parser │ │ ├── Context.c │ │ ├── Parser.c │ │ └── ParserError.c │ ├── support │ │ ├── Error.c │ │ └── ErrorHandler.c │ └── symbol-table │ │ ├── Modifier.c │ │ ├── SymbolDefinitionListener.c │ │ ├── SymbolLoader.c │ │ ├── SymbolResolutionListener.c │ │ ├── SymbolTable.c │ │ ├── scope │ │ └── Scope.c │ │ └── symbol │ │ ├── ClassSymbol.c │ │ ├── ConstantSymbol.c │ │ ├── EnumerateSymbol.c │ │ ├── EnumerationSymbol.c │ │ ├── FunctionSignature.c │ │ ├── FunctionSymbol.c │ │ ├── LabelSymbol.c │ │ ├── MemberConstantSymbol.c │ │ ├── MemberVariableSymbol.c │ │ ├── Symbol.c │ │ └── VariableSymbol.c │ ├── disassembler │ └── BinaryEntityDisassembler.c │ └── virtual-machine │ ├── ExceptionManager.c │ ├── VirtualMachine.c │ ├── VirtualMachineConfiguration.c │ ├── VirtualMachineContext.c │ ├── VirtualMachineGarbageCollectorListener.c │ ├── feb │ ├── ConstantPool.c │ ├── Entity.c │ ├── FieldEntity.c │ ├── FunctionEntity.c │ ├── Instruction.c │ └── attribute │ │ └── InstructionAttribute.c │ ├── loader │ ├── AttributeParseRules.c │ ├── BinaryEntityParser.c │ ├── BinaryEntityVerifier.c │ ├── ClassLoader.c │ └── EntityLoader.c │ ├── memory │ ├── PrimaryMemoryManager.c │ ├── allocator │ │ ├── BestFitAllocator.c │ │ ├── FirstFitAllocator.c │ │ ├── SegregatedFitsAllocator.c │ │ └── SequentialAllocator.c │ └── collector │ │ └── GarbageCollectionProfile.c │ ├── object │ ├── Class.c │ ├── Field.c │ ├── Function.c │ ├── NativeFunction.c │ ├── Object.c │ └── ObjectArray.c │ ├── processor │ ├── Interpreter.c │ ├── InvocationStack.c │ ├── LocalVariableArray.c │ ├── OperandStack.c │ ├── StackFrame.c │ └── TODO.txt │ └── zend.c ├── style └── zen.svg /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dump 3 | .vscode 4 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(gdb) Attach", 9 | "type": "cppdbg", 10 | "request": "attach", 11 | "program": "/home/project/pulsarvm/build/zvm", 12 | "processId": "${command:pickProcess}", 13 | "MIMode": "gdb", 14 | "setupCommands": [ 15 | { 16 | "description": "Enable pretty-printing for gdb", 17 | "text": "-enable-pretty-printing", 18 | "ignoreFailures": true 19 | } 20 | ] 21 | }, 22 | { 23 | "name": "gcc build and debug active file", 24 | "type": "cppdbg", 25 | "request": "launch", 26 | "program": "${fileDirname}/${fileBasenameNoExtension}", 27 | "args": [], 28 | "stopAtEntry": false, 29 | "cwd": "${workspaceFolder}", 30 | "environment": [], 31 | "externalConsole": false, 32 | "MIMode": "gdb", 33 | "setupCommands": [ 34 | { 35 | "description": "Enable pretty-printing for gdb", 36 | "text": "-enable-pretty-printing", 37 | "ignoreFailures": true 38 | } 39 | ], 40 | "preLaunchTask": "gcc build active file", 41 | "miDebuggerPath": "/usr/bin/gdb" 42 | } 43 | ] 44 | } -------------------------------------------------------------------------------- /apply-license.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for i in `find source | awk /^.*\.c$/` `find include | awk /^.*\.h$/` 3 | do 4 | if ! grep -q Copyright $i 5 | then 6 | cat LICENSE $i > $i.new && mv $i.new $i 7 | fi 8 | done -------------------------------------------------------------------------------- /benchmark/sum/sum.js: -------------------------------------------------------------------------------- 1 | var i = 0; 2 | var sum = 0; 3 | while (i < 10000) { 4 | sum = sum + i; 5 | i++; 6 | } 7 | console.log(sum); -------------------------------------------------------------------------------- /benchmark/sum/sum.zen: -------------------------------------------------------------------------------- 1 | function main(...arguments) 2 | var i = 0 3 | var sum = 0 4 | while i < 10000 5 | sum = sum + i 6 | i = i + 1 7 | print(sum) -------------------------------------------------------------------------------- /doc/Doc.txt: -------------------------------------------------------------------------------- 1 | The standard does impose any restrictions on the implementation design of the 2 | native interface. The reference implementation employs a virtual function table 3 | internally. -------------------------------------------------------------------------------- /doc/annotations.md: -------------------------------------------------------------------------------- 1 | @Between target='value1' greaterThan=8 lesserThan=9 -------------------------------------------------------------------------------- /doc/binary-entity-format.txt: -------------------------------------------------------------------------------- 1 | * Representation of a entity file, more appropriately a binary tape, encoded 2 | * in the Binary Entity Format (FEB). It consists of an array of bytes. 3 | * Muti-byte quantities which occupy 2 bytes, 4 bytes, and 8 bytes are 4 | * constructed by reading two, four, and eight consecutive bytes, respectively. 5 | * These bytes are always stored in big-endian order. 6 | * 7 | * Every entity file contains the definition of a single primary entity: class, 8 | * interface, annotation, or enumeration. 9 | 10 | ``` 11 | struct zen_EntityFile_t { 12 | 13 | /** 14 | * Represents the magic number which identifies the Binary Entity Format (FEB). 15 | * It has the value 0xFEB72000. 16 | */ 17 | uint32_t m_magicNumber; 18 | 19 | /** 20 | * Represents the version of the Binary Entity Format (FEB) with which 21 | * the binary file is encoded. 22 | */ 23 | zen_FebVersion_t m_version; 24 | 25 | 26 | 27 | /** 28 | * A mask of flags which denote various properties of this entity file. 29 | */ 30 | uint16_t m_flags; 31 | 32 | /** 33 | * The constant pool is a table where references to various constants, 34 | * identifiers, and other such entries are stored. 35 | */ 36 | zen_ConstantPool_t* m_constantPool; 37 | 38 | /** 39 | * The primary binary entity of this binary file. 40 | * 41 | * Every binary file contains the definition of a single entity: class, 42 | * interface, annotation, or enumeration. It is known as the primary entity. 43 | */ 44 | zen_Entity_t* m_entity; 45 | } 46 | ``` -------------------------------------------------------------------------------- /doc/introduction.md: -------------------------------------------------------------------------------- 1 | ## Why another programming language? 2 | 3 | At college, I saw my fellow students struggle to learn C. I wanted to help them 4 | and many others around the world like them. So I started working on a language 5 | beginners could learn easily. I called this language Zen. I had a few years of 6 | experience working with C and Java. Naturally, the language was inspired by C, 7 | Java and other languages that I briefly encountered, including Python, Ruby, 8 | and Lua. 9 | 10 | During this period, I worked as a freelancer along with my friends. I would 11 | always turn to Java and the Spring framework to write server-side applications. 12 | There is no denying that Java and Spring are very powerful. However, I soon 13 | realized that they were probably not the best tools for developing applications 14 | quickly. 15 | 16 | I could have learnt other technologies such as JavaScript/NodeJS, Ruby/Rails, 17 | or Python/Django. In my defense I did try to learn them, but I wasted my time 18 | jumping from one technology to another. Because, this may sound silly, I was 19 | obssesed with doing things the Java way. This was another reason why I chose to 20 | develop a brand new language. After all, I would learn so much developing a new 21 | language. 22 | 23 | I saw an oppurtunity here: Zen could be moulded into the technology I desperately 24 | wished for. 25 | 26 | I took the following measures to make the language easy: 27 | * Removal of redundant tokens 28 | * Dynamic typing 29 | * Automatic memory management 30 | * Simplified object-oriented programming 31 | * Partially interpreted -------------------------------------------------------------------------------- /example/BinarySearch.zen: -------------------------------------------------------------------------------- 1 | function search(values, key) 2 | var start = 0 3 | var end = values.size - 1 4 | var result = null 5 | for var i in range(0, end) 6 | var middle = (end - start) / 2 7 | if values[i] == key 8 | result = i 9 | break 10 | else if values[i] > key 11 | end = middle - 1 12 | else 13 | end = middle + 1 14 | return result 15 | 16 | function main(...arguments) 17 | var values = array(53, 118, 519, 1216) 18 | var result = search(values, 27) 19 | if result != null 20 | printf('Found key 27 at index %d.\n', result) 21 | else 22 | print('Could not find key 27.') -------------------------------------------------------------------------------- /example/BubbleSort.zen: -------------------------------------------------------------------------------- 1 | function main(...arguments) 2 | var n = 30 3 | var values = array(n) 4 | for var k in range(0, n) 5 | values[k] = random() 6 | 7 | print('Before sorting...') 8 | print(values) 9 | 10 | for var i in range(0, n) 11 | for var j in range(0, n - i - 1) 12 | if values[j] > values[j + 1] 13 | values.swap(j, j + 1) 14 | 15 | print('After sorting...') 16 | print(values) -------------------------------------------------------------------------------- /example/MaxInteger.zen: -------------------------------------------------------------------------------- 1 | function main(...arguments) 2 | /* 10 32 13 3 | * 334 150 36 4 | * 17 38 90 5 | */ 6 | with var input = Files.open('test') 7 | for line in input.readLines() 8 | var row = parseIntegers(line.split(' ')) 9 | print(Arrays.max(row)) -------------------------------------------------------------------------------- /example/PaymentCalculator.zen: -------------------------------------------------------------------------------- 1 | function main(...arguments) 2 | print('Enter the hours: ') 3 | var hours = scanFloat() 4 | 5 | print('Enter the rate: ') 6 | var rate = scanFloat() 7 | 8 | var result 9 | if hours <= 40 10 | result = hours * rate 11 | else 12 | result = 40 * rate + (hours - 40) * rate * 1.5 13 | 14 | printLine(result) -------------------------------------------------------------------------------- /example/SelectionSort.zen: -------------------------------------------------------------------------------- 1 | function main(...arguments) 2 | var n = 30 3 | var values = array(n) 4 | for var k in range(0, n) 5 | values[k] = random() 6 | 7 | print('Before sorting...') 8 | print(values) 9 | 10 | for var i in range(0, n - 1) 11 | var m = i 12 | for var j in range(i + 1, n) 13 | if values[j] < values[m] 14 | m = j 15 | if m != i 16 | values.swap(m, i) 17 | 18 | print('After sorting...') 19 | print(values) -------------------------------------------------------------------------------- /example/SimpleDownloader.zen: -------------------------------------------------------------------------------- 1 | import zen.net.UrlHelper 2 | import zen.concurrent.WaitGroup 3 | 4 | function download(group, url) 5 | try 6 | var result = UrlHelper.readAll(url) 7 | print(result) 8 | print('[info] Downloaded ' + url) 9 | catch Exception exception 10 | print(exception) 11 | finally 12 | group.signal() 13 | 14 | function main(...arguments) 15 | var group = new WaitGroup() 16 | for var argument in arguments 17 | group.add(1) 18 | spawn download(group, argument) 19 | group.wait() -------------------------------------------------------------------------------- /example/ThrowStatement.zen: -------------------------------------------------------------------------------- 1 | function f1(a, b) 2 | print('Invoked f1!') 3 | throw new Exception() 4 | 5 | function f2() 6 | print('Invoked f2!') 7 | f1(null, null) 8 | 9 | function f3() 10 | print('Invoked f3!') 11 | f2() 12 | 13 | function f4() 14 | print('Invoked f4!') 15 | f3() 16 | 17 | function main(...arguments) 18 | f4() -------------------------------------------------------------------------------- /example/factorial/factorial.zen: -------------------------------------------------------------------------------- 1 | function main(...arguments) 2 | print('Enter an integer: ') 3 | var n = scanInteger() 4 | var result = 1 5 | for var i in range(1, n + 1) 6 | result = result * i 7 | print(result) -------------------------------------------------------------------------------- /example/knn/knn.z: -------------------------------------------------------------------------------- 1 | function classify(input, samples, labels, k) 2 | var distances = [] 3 | for var sample, label : samples, labels 4 | var distance = DistanceMetric.findEuclideanDistance(input, sample) 5 | distances.add({ 'distance' : distance, 'label' : label }) 6 | // Collections.sort(distances, @(value1, value2) -> value1.distance - value2.distance) 7 | Collections.sort(distances, MapEntryComparator.naturalOrder().forKey('distance')) 8 | var neighbours = {} 9 | var max = null 10 | for var record : records 11 | neighbours[record.label] += record.distance 12 | if max == null 13 | max = record 14 | else if max.distance < record.distance 15 | max = record 16 | 17 | print(result.distance) 18 | 19 | -------------------------------------------------------------------------------- /example/linear-search/LinearSearch.zen: -------------------------------------------------------------------------------- 1 | function main(arguments) 2 | var names = [ 3 | 'Samuel Rowe', 4 | 'Joel E. Rego', 5 | 'Bill Gates', 6 | 'Linus Trovalds', 7 | 'Abraham Lincoln', 8 | 'Isaac Newton', 9 | 'Albert Einstein', 10 | 'Richard Feynman', 11 | 'Christopher Nolan', 12 | 'Benedict Cumberbatch' 13 | ] 14 | var key = 'Marshall Mathers' 15 | var result = null 16 | for var i in range(0, names.size) 17 | if key == names[i] 18 | result = i 19 | break 20 | 21 | if result != null 22 | print('Found the key "%s" at index %d.', key, result) 23 | else 24 | print('Could not find the key "%s" in the list.', key) -------------------------------------------------------------------------------- /example/read/Read.z: -------------------------------------------------------------------------------- 1 | import zen.core.System.* 2 | import zen.fs.FileHelper.* 3 | 4 | function main(...arguments) 5 | for var argument : arguments 6 | try 7 | for var line : readFile(argument).asLines() 8 | print(line) 9 | catch Exception exception 10 | logError(exception) -------------------------------------------------------------------------------- /example/student/Student.zen: -------------------------------------------------------------------------------- 1 | import orbit.annotation.* 2 | import orbit.core.* 3 | import orbit.orm.* 4 | 5 | class StudentRepository : CrudRepository 6 | ; 7 | 8 | @Rest path='/student' response='json' 9 | class StudentController 10 | 11 | @Property 12 | @Inject type='StudentRepository' 13 | var repository 14 | 15 | @Request method='GET' path='/insert' 16 | @Parameter name='name' type='string' 17 | @Parameter name='rollNumber' type='string' 18 | function insert(name, rollNumber) 19 | var student = new Student(name, rollNumber) 20 | repository.insertOne(student) 21 | return { 'message' : 'Successfully inserted a new student.' } 22 | 23 | function main() 24 | var server = new SimpleHttpServer() 25 | server.context.registerAll(StudentController, StudentRepository) 26 | server.listen() -------------------------------------------------------------------------------- /example/sum-of-array/SumOfArray.zen: -------------------------------------------------------------------------------- 1 | function main(...arguments) 2 | var numbers = array(10, 20, 30, 40, 50) 3 | var sum = 0 4 | for var i in range(0, numbers.size) 5 | sum += numbers[i] 6 | print(sum) 7 | -------------------------------------------------------------------------------- /include/com/onecube/zen/Configuration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Wedensday, October 18, 2017 18 | 19 | #ifndef ZEN_CONFIGURATION_H 20 | #define ZEN_CONFIGURATION_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | /* Uncomment/comment the following definition to enable/disable 30 | * the logger at compile-time. 31 | */ 32 | #ifndef JTK_LOGGER_DISABLE 33 | // #define JTK_LOGGER_DISABLE 34 | #endif 35 | 36 | #include 37 | 38 | #ifndef NULL 39 | #define NULL 0 40 | #endif 41 | 42 | #define zen_Memory_allocate(type, units) (type*)zen_Memory_allocate0(sizeof (type) * (units)) 43 | #define zen_Memory_deallocate(object) free(object) 44 | #define zen_Assert_assertObject(object, message) assert((object) != NULL) 45 | #define zen_Assert_assertTrue(expression, message) assert(expression) 46 | #define zen_Assert_assertFalse(expression, message) assert(!(expression)) 47 | #define zen_Assert_assertIndex(index, size, message) assert(((index) < (size)) && ((index) >= 0)) 48 | #define zen_Assert_assertRange(startIndex, stopIndex, size, message) puts("TODO: zen_Assert_assertRange"); 49 | #define zen_Assert_assertAddIndex(index, size, message) assert(((index) <= (size)) && ((index) >= 0)) 50 | 51 | void* zen_Memory_allocate0(int32_t size); 52 | 53 | #endif /* ZEN_CONFIGURATION_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/ASTAnnotation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, April 28, 2018 18 | 19 | #ifndef COM_ONECUBE_COM_ONECUBE_COM_ONECUBE_ZEN_COMPILER_COMPILER_COMPILER_AST_AST_ANNOTATION_H 20 | #define COM_ONECUBE_COM_ONECUBE_ZEN_COMPILER_COMPILER_AST_AST_ANNOTATION_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * ASTAnnotation * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @author Samuel Rowe 31 | * @since zen 1.0 32 | */ 33 | struct zen_ASTAnnotation_t { 34 | zen_ASTAnnotationType_t m_type; 35 | void* m_bundle; 36 | }; 37 | 38 | typedef struct zen_ASTAnnotation_t zen_ASTAnnotation_t; 39 | 40 | zen_ASTAnnotation_t* zen_ASTAnnotation_new(zen_ASTAnnotationType_t type, void* bundle); 41 | void zen_ASTAnnotation_delete(zen_ASTAnnotation_t* annotation); 42 | 43 | #endif /* COM_ONECUBE_COM_ONECUBE_ZEN_COMPILER_COMPILER_AST_AST_ANNOTATION_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/ASTAnnotationType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, April 28, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_AST_AST_ANNOTATION_TYPE_H 20 | #define COM_ONECUBE_ZEN_COMPILER_AST_AST_ANNOTATION_TYPE_H 21 | 22 | /******************************************************************************* 23 | * ASTAnnotationType * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * @author Samuel Rowe 28 | * @since zen 1.0 29 | */ 30 | enum zen_ASTAnnotationType_t { 31 | 32 | /** 33 | * A situation where certain instructions are required to be inserted between 34 | * the instructions of multiple productions of a single rule may arise when the 35 | * productions have a common ancestor. In such situations, the byte code generated 36 | * for a production is redirected to a new channel. An asymetrical location for 37 | * pushing and popping of channels is necessary. Here, a new channel is pushed 38 | * by the production rule on request by the ancestor. It is popped off by the 39 | * ancestor. 40 | * 41 | * The communication between the ancestor and the production rule occurs via 42 | * an AST node annotation. The bundle is null. 43 | */ 44 | AST_ANNOTATION_TYPE_ASYMETRICAL_CHANNEL_MANAGEMENT, 45 | 46 | AST_ANNOTATION_TYPE_CUSTOM 47 | }; 48 | 49 | typedef enum zen_ASTAnnotationType_t zen_ASTAnnotationType_t; 50 | 51 | #endif /* COM_ONECUBE_ZEN_COMPILER_AST_AST_ANNOTATION_TYPE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/ASTAnnotations.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, March 10, 2018 18 | 19 | #ifndef COM_ONECUBE_COM_ONECUBE_ZEN_COMPILER_COMPILER_AST_AST_ANNOTATIONS_H 20 | #define COM_ONECUBE_COM_ONECUBE_ZEN_COMPILER_COMPILER_AST_AST_ANNOTATIONS_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * ASTAnnotations * 27 | *******************************************************************************/ 28 | 29 | struct zen_ASTAnnotations_t { 30 | jtk_HashMap_t* m_map; 31 | }; 32 | 33 | typedef struct zen_ASTAnnotations_t zen_ASTAnnotations_t; 34 | 35 | zen_ASTAnnotations_t* zen_ASTAnnotations_new(); 36 | void zen_ASTAnnotations_delete(zen_ASTAnnotations_t* annotations); 37 | void* zen_ASTAnnotations_get(zen_ASTAnnotations_t* annotations, zen_ASTNode_t* node); 38 | void zen_ASTAnnotations_put(zen_ASTAnnotations_t* annotations, zen_ASTNode_t* node, void* value); 39 | void zen_ASTAnnotations_remove(zen_ASTAnnotations_t* annotations, zen_ASTNode_t* node); 40 | 41 | #endif /* COM_ONECUBE_COM_ONECUBE_ZEN_COMPILER_COMPILER_AST_AST_ANNOTATIONS_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/ASTWalker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, November 26, 2017 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_COMPILER_AST_WALKER_H 20 | #define COM_ONECUBE_ZEN_COMPILER_COMPILER_AST_WALKER_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | /******************************************************************************* 27 | * ASTWalker * 28 | *******************************************************************************/ 29 | 30 | /** 31 | * @memberof ASTWalker 32 | */ 33 | void zen_ASTWalker_walk(zen_ASTListener_t* listener, zen_ASTNode_t* node); 34 | 35 | /** 36 | * @memberof ASTWalker 37 | */ 38 | void zen_ASTWalker_enterRule(zen_ASTListener_t* listener, zen_ASTNode_t* node); 39 | 40 | /** 41 | * @memberof ASTWalker 42 | */ 43 | void zen_ASTWalker_exitRule(zen_ASTListener_t* listener, zen_ASTNode_t* node); 44 | 45 | #endif /* COM_ONECUBE_ZEN_COMPILER_COMPILER_AST_WALKER_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/ASTWalkerState.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef COM_ONECUBE_ZEN_COMPILER_AST_AST_WALKER_STATE_H 18 | #define COM_ONECUBE_ZEN_COMPILER_AST_AST_WALKER_STATE_H 19 | 20 | /******************************************************************************* 21 | * ASTWalker * 22 | *******************************************************************************/ 23 | 24 | /** 25 | * @class ASTWalker 26 | * @ingroup zen_compiler_ast 27 | * @author Samuel Rowe 28 | * @since zen 1.0 29 | */ 30 | enum zen_ASTWalkerState_t { 31 | ZEN_AST_WALKER_STATE_INVALID, 32 | 33 | ZEN_AST_WALKER_STATE_SKIP_CHILDREN, 34 | ZEN_AST_WALKER_STATE_VISIT_CHILDREN, 35 | 36 | ZEN_AST_WALKER_STATE_SKIP_EVEN_CHILDREN, 37 | ZEN_AST_WALKER_STATE_VISIT_EVEN_CHILDREN, 38 | 39 | ZEN_AST_WALKER_STATE_SKIP_ODD_CHILDREN, 40 | ZEN_AST_WALKER_STATE_VISIT_ODD_CHILDREN, 41 | 42 | ZEN_AST_WALKER_STATE_SKIP_EXTREME_CHILDREN, 43 | ZEN_AST_WALKER_STATE_VISIT_EXTREME_CHILDREN, 44 | 45 | ZEN_AST_WALKER_STATE_VISIT_FIRST_CHILD, 46 | ZEN_AST_WALKER_STATE_SKIP_FIRST_CHILD, 47 | 48 | ZEN_AST_WALKER_STATE_VISIT_LAST_CHILD, 49 | ZEN_AST_WALKER_STATE_SKIP_LAST_CHILD, 50 | }; 51 | 52 | /** 53 | * @memberof ASTWalker 54 | */ 55 | typedef enum zen_ASTWalkerState_t zen_ASTWalkerState_t; 56 | 57 | #endif /* COM_ONECUBE_ZEN_COMPILER_AST_AST_WALKER_STATE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/ExpressionAnnotation.h: -------------------------------------------------------------------------------- 1 | // Saturday, January 04, 2019 2 | 3 | #ifndef COM_ONECUBE_ZEN_COMPILER_AST_EXPRESSION_ANNOTATION_H 4 | #define COM_ONECUBE_ZEN_COMPILER_AST_EXPRESSION_ANNOTATION_H 5 | 6 | #include 7 | 8 | /******************************************************************************* 9 | * ExpressionAnnotation * 10 | *******************************************************************************/ 11 | 12 | /** 13 | * @ingroup 14 | * @author Samuel Rowe 15 | * @since Zen 1.0 16 | */ 17 | enum zen_ExpressionAnnotation_t { 18 | ZEN_EXPRESSION_ANNOTATION_UNKNOWN, 19 | ZEN_EXPRESSION_ANNOTATION_PLACEHOLDER, 20 | ZEN_EXPRESSION_ANNOTATION_VALUE 21 | }; 22 | 23 | typedef enum zen_ExpressionAnnotation_t zen_ExpressionAnnotation_t; 24 | 25 | #endif /* COM_ONECUBE_ZEN_COMPILER_AST_EXPRESSION_ANNOTATION_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/context/ElseClauseContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Wednesday, July 17, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_ELSE_CLAUSE_CONTEXT_H 20 | #define COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_ELSE_CLAUSE_CONTEXT_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * ElseClauseContext * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class ElseClauseContext 31 | * @ingroup zen_compiler_ast 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_ElseClauseContext_t { 36 | zen_ASTNode_t* m_node; 37 | zen_ASTNode_t* m_statementSuite; 38 | }; 39 | 40 | /** 41 | * @memberof ElseClauseContext 42 | */ 43 | typedef struct zen_ElseClauseContext_t zen_ElseClauseContext_t; 44 | 45 | // Constructor 46 | 47 | /** 48 | * @memberof ElseClauseContext 49 | */ 50 | zen_ElseClauseContext_t* zen_ElseClauseContext_new(zen_ASTNode_t* node); 51 | 52 | // Destructor 53 | 54 | /** 55 | * @memberof ElseClauseContext 56 | */ 57 | void zen_ElseClauseContext_delete(zen_ElseClauseContext_t* context); 58 | 59 | // Children 60 | 61 | /** 62 | * @memberof ElseClauseContext 63 | */ 64 | void zen_ElseClauseContext_getChildren(zen_ElseClauseContext_t* context, jtk_ArrayList_t* children); 65 | 66 | #endif /* COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_ELSE_CLAUSE_CONTEXT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/context/ExpressionContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Wednesday, July 17, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_EXPRESSION_CONTEXT_H 20 | #define COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_EXPRESSION_CONTEXT_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * ExpressionContext * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class ExpressionContext 31 | * @ingroup zen_compiler_ast 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_ExpressionContext_t { 36 | zen_ASTNode_t* m_node; 37 | zen_ASTNode_t* m_assignmentExpression; 38 | }; 39 | 40 | /** 41 | * @memberof ExpressionContext 42 | */ 43 | typedef struct zen_ExpressionContext_t zen_ExpressionContext_t; 44 | 45 | // Constructor 46 | 47 | /** 48 | * @memberof ExpressionContext 49 | */ 50 | zen_ExpressionContext_t* zen_ExpressionContext_new(zen_ASTNode_t* node); 51 | 52 | // Destructor 53 | 54 | /** 55 | * @memberof ExpressionContext 56 | */ 57 | void zen_ExpressionContext_delete(zen_ExpressionContext_t* context); 58 | 59 | // Children 60 | 61 | /** 62 | * @memberof ExpressionContext 63 | */ 64 | void zen_ExpressionContext_getChildren(zen_ExpressionContext_t* context, jtk_ArrayList_t* children); 65 | 66 | #endif /* COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_EXPRESSION_CONTEXT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/context/IfClauseContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Wednesday, July 17, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_IF_CLAUSE_CONTEXT_H 20 | #define COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_IF_CLAUSE_CONTEXT_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * IfClauseContext * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class IfClauseContext 31 | * @ingroup zen_compiler_ast 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_IfClauseContext_t { 36 | zen_ASTNode_t* m_node; 37 | zen_ASTNode_t* m_expression; 38 | zen_ASTNode_t* m_statementSuite; 39 | }; 40 | 41 | /** 42 | * @memberof IfClauseContext 43 | */ 44 | typedef struct zen_IfClauseContext_t zen_IfClauseContext_t; 45 | 46 | // Constructor 47 | 48 | /** 49 | * @memberof IfClauseContext 50 | */ 51 | zen_IfClauseContext_t* zen_IfClauseContext_new(zen_ASTNode_t* node); 52 | 53 | // Destructor 54 | 55 | /** 56 | * @memberof IfClauseContext 57 | */ 58 | void zen_IfClauseContext_delete(zen_IfClauseContext_t* context); 59 | 60 | // Children 61 | 62 | /** 63 | * @memberof IfClauseContext 64 | */ 65 | void zen_IfClauseContext_getChildren(zen_IfClauseContext_t* context, jtk_ArrayList_t* children); 66 | 67 | #endif /* COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_IF_CLAUSE_CONTEXT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/context/ListExpressionContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Tuesday, July 16, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_LIST_EXPRESSION_CONTEXT_H 20 | #define COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_LIST_EXPRESSION_CONTEXT_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * ListExpressionContext * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class ListExpressionContext 31 | * @ingroup zen_compiler_ast 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_ListExpressionContext_t { 36 | zen_ASTNode_t* m_node; 37 | zen_ASTNode_t* m_expressions; 38 | }; 39 | 40 | typedef struct zen_ListExpressionContext_t zen_ListExpressionContext_t; 41 | 42 | zen_ListExpressionContext_t* zen_ListExpressionContext_new(zen_ASTNode_t* node); 43 | void zen_ListExpressionContext_delete(zen_ListExpressionContext_t* context); 44 | void zen_ListExpressionContext_getChildren(zen_ListExpressionContext_t* context, jtk_ArrayList_t* children); 45 | 46 | #endif /* COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_LIST_EXPRESSION_CONTEXT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/context/MapEntryContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Tuesday, July 16, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_MAP_ENTRY_CONTEXT_H 20 | #define COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_MAP_ENTRY_CONTEXT_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * MapEntryContext * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class MapEntryContext 31 | * @ingroup zen_compiler_ast 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_MapEntryContext_t { 36 | zen_ASTNode_t* m_node; 37 | zen_ASTNode_t* m_keyExpression; 38 | zen_ASTNode_t* m_valueExpression; 39 | }; 40 | 41 | /** 42 | * @memberof MapEntryContext 43 | */ 44 | typedef struct zen_MapEntryContext_t zen_MapEntryContext_t; 45 | 46 | // Constructor 47 | 48 | /** 49 | * @memberof MapEntryContext 50 | */ 51 | zen_MapEntryContext_t* zen_MapEntryContext_new(zen_ASTNode_t* node); 52 | 53 | // Destructor 54 | 55 | /** 56 | * @memberof MapEntryContext 57 | */ 58 | void zen_MapEntryContext_delete(zen_MapEntryContext_t* context); 59 | 60 | // Children 61 | 62 | /** 63 | * @memberof MapEntryContext 64 | */ 65 | void zen_MapEntryContext_getChildren(zen_MapEntryContext_t* context, jtk_ArrayList_t* children); 66 | 67 | #endif /* COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_MAP_ENTRY_CONTEXT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/context/MapExpressionContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Tuesday, July 16, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_MAP_EXPRESSION_CONTEXT_H 20 | #define COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_MAP_EXPRESSION_CONTEXT_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * MapExpressionContext * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class MapExpressionContext 31 | * @ingroup zen_compiler_ast 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_MapExpressionContext_t { 36 | zen_ASTNode_t* m_node; 37 | zen_ASTNode_t* m_mapEntries; 38 | }; 39 | 40 | typedef struct zen_MapExpressionContext_t zen_MapExpressionContext_t; 41 | 42 | zen_MapExpressionContext_t* zen_MapExpressionContext_new(zen_ASTNode_t* node); 43 | void zen_MapExpressionContext_delete(zen_MapExpressionContext_t* context); 44 | void zen_MapExpressionContext_getChildren(zen_MapExpressionContext_t* context, jtk_ArrayList_t* children); 45 | 46 | #endif /* COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_MAP_EXPRESSION_CONTEXT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/context/SubscriptContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Tuesday, July 16, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_SUBSCRIPT_CONTEXT_H 20 | #define COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_SUBSCRIPT_CONTEXT_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * SubscriptContext * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class SubscriptContext 31 | * @ingroup zen_compiler_ast 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_SubscriptContext_t { 36 | zen_ASTNode_t* m_node; 37 | zen_ASTNode_t* m_expression; 38 | }; 39 | 40 | /** 41 | * @memberof SubscriptContext 42 | */ 43 | typedef struct zen_SubscriptContext_t zen_SubscriptContext_t; 44 | 45 | // Constructor 46 | 47 | /** 48 | * @memberof SubscriptContext 49 | */ 50 | zen_SubscriptContext_t* zen_SubscriptContext_new(zen_ASTNode_t* node); 51 | 52 | // Destructor 53 | 54 | /** 55 | * @memberof SubscriptContext 56 | */ 57 | void zen_SubscriptContext_delete(zen_SubscriptContext_t* context); 58 | 59 | // Children 60 | 61 | /** 62 | * @memberof SubscriptContext 63 | */ 64 | void zen_SubscriptContext_getChildren(zen_SubscriptContext_t* context, jtk_ArrayList_t* children); 65 | 66 | #endif /* COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_SUBSCRIPT_CONTEXT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/ast/context/TryClauseContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Wednesday, July 17, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_TRY_CLAUSE_CONTEXT_H 20 | #define COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_TRY_CLAUSE_CONTEXT_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * TryClauseContext * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class TryClauseContext 31 | * @ingroup zen_compiler_ast 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_TryClauseContext_t { 36 | zen_ASTNode_t* m_node; 37 | zen_ASTNode_t* m_statementSuite; 38 | }; 39 | 40 | /** 41 | * @memberof TryClauseContext 42 | */ 43 | typedef struct zen_TryClauseContext_t zen_TryClauseContext_t; 44 | 45 | // Constructor 46 | 47 | /** 48 | * @memberof TryClauseContext 49 | */ 50 | zen_TryClauseContext_t* zen_TryClauseContext_new(zen_ASTNode_t* node); 51 | 52 | // Destructor 53 | 54 | /** 55 | * @memberof TryClauseContext 56 | */ 57 | void zen_TryClauseContext_delete(zen_TryClauseContext_t* context); 58 | 59 | // Children 60 | 61 | /** 62 | * @memberof TryClauseContext 63 | */ 64 | void zen_TryClauseContext_getChildren(zen_TryClauseContext_t* context, jtk_ArrayList_t* children); 65 | 66 | #endif /* COM_ONECUBE_ZEN_COMPILER_AST_CONTEXT_TRY_CLAUSE_CONTEXT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/lexer/LexerError.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, November 04, 2017 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_LEXER_LEXER_ERROR_H 20 | #define COM_ONECUBE_ZEN_COMPILER_LEXER_LEXER_ERROR_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * LexerError * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class LexerError 30 | * @ingroup zen_compiler_lexer 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_LexerError_t { 35 | char* m_message; 36 | char* m_path; 37 | int32_t m_line; 38 | int32_t m_column; 39 | }; 40 | 41 | /** 42 | * @memberof LexerError 43 | */ 44 | typedef struct zen_LexerError_t zen_LexerError_t; 45 | 46 | // Constructor 47 | 48 | /** 49 | * @memberof LexerError 50 | */ 51 | zen_LexerError_t* zen_LexerError_new(const char* message, const char* path, 52 | int32_t line, int32_t column); 53 | 54 | // Destructor 55 | 56 | /** 57 | * @memberof LexerError 58 | */ 59 | void zen_LexerError_delete(zen_LexerError_t* error); 60 | 61 | #endif /* COM_ONECUBE_ZEN_COMPILER_LEXER_LEXER_ERROR_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/lexer/TokenChannel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Monday, November 27, 2017 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_LEXER_TOKEN_CHANNEL_H 20 | #define COM_ONECUBE_ZEN_COMPILER_LEXER_TOKEN_CHANNEL_H 21 | 22 | /******************************************************************************* 23 | * TokenChannel * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * @class TokenChannel 28 | * @ingroup zen_compiler_lexer 29 | * @author Samuel Rowe 30 | * @since zen 1.0 31 | */ 32 | enum zen_TokenChannel_t { 33 | ZEN_TOKEN_CHANNEL_DEFAULT, 34 | ZEN_TOKEN_CHANNEL_HIDDEN, 35 | }; 36 | 37 | /** 38 | * @memberof TokenChannel 39 | */ 40 | typedef enum zen_TokenChannel_t zen_TokenChannel_t; 41 | 42 | #endif /* COM_ONECUBE_ZEN_COMPILER_LEXER_TOKEN_CHANNEL_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/parser/ParserError.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, December 03, 2017 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_PARSER_PARSER_ERROR_H 20 | #define COM_ONECUBE_ZEN_COMPILER_PARSER_PARSER_ERROR_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ParserError * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class ParserError 30 | * @ingroup zen_compiler_parser 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_ParserError_t { 35 | char* m_message; 36 | }; 37 | 38 | /** 39 | * @memberof ParserError 40 | */ 41 | typedef struct zen_ParserError_t zen_ParserError_t; 42 | 43 | // Constructor 44 | 45 | /** 46 | * @memberof ParserError 47 | */ 48 | zen_ParserError_t* zen_ParserError_new(); 49 | 50 | // Destructor 51 | 52 | /** 53 | * @memberof ParserError 54 | */ 55 | void zen_ParserError_delete(zen_ParserError_t* error); 56 | 57 | #endif /* COM_ONECUBE_ZEN_COMPILER_PARSER_PARSER_ERROR_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/support/Error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef COM_ONECUBE_ZEN_COMPILER_SUPPORT_ERROR_H 18 | #define COM_ONECUBE_ZEN_COMPILER_SUPPORT_ERROR_H 19 | 20 | #include 21 | #include 22 | 23 | /******************************************************************************* 24 | * Error * 25 | *******************************************************************************/ 26 | 27 | /** 28 | * @class Error 29 | * @ingroup zen_compiler_support 30 | * @author Samuel Rowe 31 | * @since Zen 1.0 32 | */ 33 | struct zen_Error_t { 34 | zen_ErrorCode_t m_code; 35 | zen_Token_t* m_token; 36 | zen_TokenType_t m_expected; 37 | }; 38 | 39 | /** 40 | * @memberof Error 41 | */ 42 | typedef struct zen_Error_t zen_Error_t; 43 | 44 | // Constructor 45 | 46 | zen_Error_t* zen_Error_new(zen_ErrorCode_t errorCode, zen_Token_t* token); 47 | zen_Error_t* zen_Error_newEx(zen_ErrorCode_t errorCode, zen_Token_t* token, zen_TokenType_t expected); 48 | 49 | // Destructor 50 | 51 | void zen_Error_delete(zen_Error_t* error); 52 | 53 | #endif /* COM_ONECUBE_ZEN_COMPILER_SUPPORT_ERROR_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/support/StackTrace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, January 05, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_SUPPORT_STACK_TRACE_H 20 | #define COM_ONECUBE_ZEN_COMPILER_SUPPORT_STACK_TRACE_H 21 | 22 | /******************************************************************************* 23 | * StackTrace * 24 | *******************************************************************************/ 25 | 26 | void zen_StackTrace_enter0(const char* file, const char* name); 27 | void zen_StackTrace_exit0(const char* file, const char* name); 28 | 29 | #ifdef ZEN_STACK_TRACE_ENABLE 30 | #define zen_StackTrace_enter() zen_StackTrace_enter0(__FILE__, __FUNCTION__) 31 | #define zen_StackTrace_exit() zen_StackTrace_exit0(__FILE__, __FUNCTION__) 32 | #else 33 | #define zen_StackTrace_enter() 34 | #define zen_StackTrace_exit() 35 | #endif 36 | 37 | #endif /* COM_ONECUBE_ZEN_COMPILER_SUPPORT_STACK_TRACE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/symbol-table/ClassSymbol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, January 07, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_CLASS_SYMBOL_H 20 | #define COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_CLASS_SYMBOL_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ClassSymbol * 26 | *******************************************************************************/ 27 | 28 | typedef struct zen_Scope_t zen_Scope_t; 29 | 30 | /** 31 | * @class ClassSymbol 32 | * @ingroup zen_compiler_symbolTable 33 | * @author Samuel Rowe 34 | * @since zen 1.0 35 | */ 36 | struct zen_ClassSymbol_t { 37 | /* The superclasses are added in the resolution phase. */ 38 | jtk_ArrayList_t* m_superClasses; /* */ 39 | uint8_t* m_qualifiedName; 40 | int32_t m_qualifiedNameSize; 41 | zen_Scope_t* m_classScope; 42 | 43 | uint8_t* m_descriptor; 44 | int32_t m_descriptorSize; 45 | }; 46 | 47 | /** 48 | * @memberof ClassSymbol 49 | */ 50 | typedef struct zen_ClassSymbol_t zen_ClassSymbol_t; 51 | 52 | void zen_ClassSymbol_initialize(zen_ClassSymbol_t* symbol); 53 | 54 | void zen_ClassSymbol_destroy(zen_ClassSymbol_t* symbol); 55 | 56 | #endif /* COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_CLASS_SYMBOL_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/symbol-table/Modifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, March 04, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_MODIFIER_H 20 | #define COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_MODIFIER_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * Modifier * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class Modifier 30 | * @ingroup zen_compiler_symbolTable 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | enum zen_Modifier_t { 35 | 36 | ZEN_MODIFIER_PUBLIC = 1 << 0, 37 | 38 | ZEN_MODIFIER_PRIVATE = 1 << 1, 39 | 40 | ZEN_MODIFIER_SECRET = 1 << 2, 41 | 42 | ZEN_MODIFIER_SYNTHETIC = 1 << 3, 43 | 44 | ZEN_MODIFIER_ABSTRACT = 1 << 4, 45 | 46 | ZEN_MODIFIER_FINAL = 1 << 5, 47 | 48 | ZEN_MODIFIER_STATIC = 1 << 6, 49 | 50 | ZEN_MODIFIER_NATIVE = 1 << 7, 51 | 52 | ZEN_MODIFIER_ANNOTATION = 1 << 8, 53 | 54 | ZEN_MODIFIER_ENUMERATION = 1 << 9, 55 | 56 | ZEN_MODIFIER_VARIABLE_PARAMETER = 1 << 10 57 | }; 58 | 59 | /** 60 | * @memberof Modifier 61 | */ 62 | typedef enum zen_Modifier_t zen_Modifier_t; 63 | 64 | 65 | 66 | #endif /* COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_MODIFIER_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/symbol-table/ScopeType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, January 07, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_SCOPE_TYPE_H 20 | #define COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_SCOPE_TYPE_H 21 | 22 | /******************************************************************************* 23 | * ScopeType * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * @class ScopeType 28 | * @ingroup zen_compiler_symbolTable 29 | * @author Samuel Rowe 30 | * @since zen 1.0 31 | */ 32 | enum zen_ScopeType_t { 33 | ZEN_SCOPE_COMPILATION_UNIT, 34 | ZEN_SCOPE_ANNOTATION, 35 | ZEN_SCOPE_CLASS, 36 | ZEN_SCOPE_FUNCTION, 37 | ZEN_SCOPE_ENUMERATION, 38 | ZEN_SCOPE_LOCAL 39 | }; 40 | 41 | /** 42 | * @memberof ScopeType 43 | */ 44 | typedef enum zen_ScopeType_t zen_ScopeType_t; 45 | 46 | #endif /* COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_SCOPE_TYPE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/compiler/symbol-table/SymbolCategory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, November 25, 2017 18 | 19 | #ifndef COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_SYMBOL_CATEGORY_H 20 | #define COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_SYMBOL_CATEGORY_H 21 | 22 | /******************************************************************************* 23 | * SymbolCategory * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * @class SymbolCategory 28 | * @ingroup zen_compiler_symbolTable 29 | * @author Samuel Rowe 30 | * @since zen 1.0 31 | */ 32 | enum zen_SymbolCategory_t { 33 | ZEN_SYMBOL_CATEGORY_ANNOTATION, 34 | ZEN_SYMBOL_CATEGORY_CLASS, 35 | ZEN_SYMBOL_CATEGORY_ENUMERATE, 36 | ZEN_SYMBOL_CATEGORY_ENUMERATION, 37 | ZEN_SYMBOL_CATEGORY_FUNCTION, 38 | ZEN_SYMBOL_CATEGORY_CONSTANT, 39 | ZEN_SYMBOL_CATEGORY_VARIABLE, 40 | // ZEN_SYMBOL_CATEGORY_CONSTRUCTOR, 41 | ZEN_SYMBOL_CATEGORY_LABEL, 42 | ZEN_SYMBOL_CATEGORY_EXTERNAL 43 | }; 44 | 45 | /** 46 | * @memberof SymbolCategory 47 | */ 48 | typedef enum zen_SymbolCategory_t zen_SymbolCategory_t; 49 | 50 | #endif /* COM_ONECUBE_ZEN_COMPILER_SYMBOL_TABLE_SYMBOL_CATEGORY_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/ExceptionManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, September 15, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_EXCEPTION_MANAGER_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_EXCEPTION_MANAGER_H 21 | 22 | #include 23 | #include 24 | 25 | /* Forward References */ 26 | typedef struct zen_VirtualMachine_t zen_VirtualMachine_t; 27 | 28 | /******************************************************************************* 29 | * ExceptionManager * 30 | *******************************************************************************/ 31 | 32 | /** 33 | * @class ExceptionManager 34 | * @ingroup zen_virtual_machine 35 | * @author Samuel Rowe 36 | * @since zen 1.0 37 | */ 38 | struct zen_ExceptionManager_t { 39 | zen_VirtualMachine_t* m_virtualMachine; 40 | }; 41 | 42 | /** 43 | * @memberof ExceptionManager 44 | */ 45 | typedef struct zen_ExceptionManager_t zen_ExceptionManager_t; 46 | 47 | /* Constructor */ 48 | 49 | /** 50 | * @memberof ExceptionManager 51 | */ 52 | zen_ExceptionManager_t* zen_ExceptionManager_new(zen_VirtualMachine_t* virtualMachine); 53 | 54 | /* Destructor */ 55 | 56 | /** 57 | * @memberof ExceptionManager 58 | */ 59 | void zen_ExceptionManager_delete(zen_ExceptionManager_t* manager); 60 | 61 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_EXCEPTION_MANAGER_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/VirtualMachineGarbageCollectorListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, September 02, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_VIRTUAL_MACHINE_GARBAGE_COLLECTOR_LISTENER_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_VIRTUAL_MACHINE_GARBAGE_COLLECTOR_LISTENER_H 21 | 22 | /******************************************************************************* 23 | * VirtualMachineGarbageCollectorListener * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * @class VirtualMachineGarbageCollectorListener 28 | * @ingroup zen_vm 29 | * @author Samuel Rowe 30 | * @since zen 1.0 31 | */ 32 | 33 | /** 34 | * @memberof VirtualMachineGarbageCollectorListener 35 | */ 36 | void zen_VirtualMachineGarbageCollectorListener_onAfterInitialization(zen_GarbageCollectorListener_t* listener, zen_GarbageCollector_t* collector); 37 | 38 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_VIRTUAL_MACHINE_GARBAGE_COLLECTOR_LISTENER_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/AuxillaryAttribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, September 22, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_AUXILLARY_ATTRIBUTE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_AUXILLARY_ATTRIBUTE_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * AuxillaryAttribute * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class AuxillaryAttribute 30 | * @ingroup zen_vm_feb 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_AuxillaryAttribute_t { 35 | uint16_t m_operandStackSize; 36 | uint16_t m_localVariableArraySize; 37 | }; 38 | 39 | /** 40 | * @memberof AuxillaryAttribute 41 | */ 42 | typedef struct zen_AuxillaryAttribute_t zen_AuxillaryAttribute_t; 43 | 44 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_AUXILLARY_ATTRIBUTE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/BinaryEntityFormat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Monday, March 19, 2018 18 | 19 | #ifndef ZEN_BINARY_ENTITY_FORMAT_H 20 | #define ZEN_BINARY_ENTITY_FORMAT_H 21 | 22 | #include 23 | 24 | #define ZEN_BINARY_ENTITY_FORMAT_MAGIC_NUMBER 0xFEB72000 25 | #define ZEN_BINARY_ENTITY_FORMAT_MAJOR_VERSION 0 26 | #define ZEN_BINARY_ENTITY_FORMAT_MINOR_VERSION 1 27 | 28 | #endif /* ZEN_BINARY_ENTITY_FORMAT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/EntityType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef ZEN_FEB_ENTITY_TYPE_H 20 | #define ZEN_FEB_ENTITY_TYPE_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * EntityType * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class EntityType 30 | * @ingroup zen_vm_feb 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | enum zen_EntityType_t { 35 | ZEN_ENTITY_TYPE_CLASS = 1, 36 | ZEN_ENTITY_TYPE_INTERFACE = 2, 37 | ZEN_ENTITY_TYPE_ANNOTATION = 3, 38 | ZEN_ENTITY_TYPE_PACKAGE = 4 39 | }; 40 | 41 | /** 42 | * @memberof EntityType 43 | */ 44 | typedef enum zen_EntityType_t zen_EntityType_t; 45 | 46 | #endif /* ZEN_FEB_ENTITY_TYPE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/EnumerateEntity.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ENUMERATE_ENTITY_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ENUMERATE_ENTITY_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * EnumerateEntity * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * A field enumerate. 30 | * 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_EnumerateEntity_t { 35 | 36 | /** 37 | * A valid index into the constant pool table. The entry at this index is 38 | * an UTF-8 entry which represents the name of this field. 39 | */ 40 | uint16_t m_nameIndex; 41 | 42 | /** 43 | * A valid index into the constant pool table. The entry at this index is 44 | * an UTF-8 entry which represents the descriptor of this field. 45 | */ 46 | uint16_t m_descriptorIndex; 47 | }; 48 | 49 | typedef struct zen_EnumerateEntity_t zen_EnumerateEntity_t; 50 | 51 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ENUMERATE_ENTITY_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/EnumerationEntity.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ENUMERATION_ENTITY_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ENUMERATION_ENTITY_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * EnumerationEntity * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * An enumeration entity. 31 | * 32 | * @class EnumerationEntity 33 | * @ingroup zen_vm_feb 34 | * @author Samuel Rowe 35 | * @since zen 1.0 36 | */ 37 | struct zen_EnumerationEntity_t { 38 | 39 | uint16_t m_superClass; 40 | 41 | uint16_t m_enumerateCount; 42 | 43 | zen_Entity_t** m_enumerates; 44 | 45 | zen_Entity_t* m_initializer; 46 | }; 47 | 48 | /** 49 | * @memberof EnumerationEntity 50 | */ 51 | typedef struct zen_EnumerationEntity_t zen_EnumerationEntity_t; 52 | 53 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ENUMERATION_ENTITY_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/FebVersion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Monday, June 11, 2018 18 | 19 | #ifndef ZEN_FEB_FEB_VERSION_H 20 | #define ZEN_FEB_FEB_VERSION_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * FebVersion * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * Represents a version of the Binary Entity Format (FEB). 30 | * 31 | * @author Samuel Rowe 32 | * @since FEB 1.0 33 | */ 34 | struct zen_FebVersion_t { 35 | /** 36 | * The major version of the Binary Entity Format (FEB) in which the entity 37 | * is encoded. Symbolically, 'M' represents the major version and 'm' represents 38 | * the minor version. Thus, 'M.m' represents the FEB version which may be 39 | * subjected to lexicographic comparision. 40 | */ 41 | uint16_t m_majorVersion; 42 | 43 | /** 44 | * The minor version of the Binary Entity Format (FEB) in which the entity 45 | * is encoded. Symbolically, 'M' represents the major version and 'm' represents 46 | * the minor version. Thus, 'M.m' represents the FEB version which may be 47 | * subjected to lexicographic comparision. 48 | */ 49 | uint16_t m_minorVersion; 50 | }; 51 | 52 | typedef struct zen_FebVersion_t zen_FebVersion_t; 53 | 54 | #endif /* ZEN_FEB_FEB_VERSION_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/Instruction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, April 12, 2018 18 | 19 | #ifndef ZEN_FEB_INSTRUCTION_H 20 | #define ZEN_FEB_INSTRUCTION_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * Instruction * 27 | *******************************************************************************/ 28 | 29 | struct zen_Instruction_t { 30 | const uint8_t m_text[30]; 31 | uint32_t m_byteCode; 32 | uint32_t m_argumentCount; 33 | uint32_t m_operandCount; 34 | uint32_t m_resultCount; 35 | }; 36 | 37 | typedef struct zen_Instruction_t zen_Instruction_t; 38 | 39 | bool zen_Instruction_verify(); 40 | zen_Instruction_t* zen_Instruction_getInstance(zen_ByteCode_t byteCode); 41 | const uint8_t* zen_Instruction_getText(zen_Instruction_t* instruction); 42 | uint8_t zen_Instruction_getByteCode(zen_Instruction_t* instruction); 43 | uint8_t zen_Instruction_getArgumentCount(zen_Instruction_t* instruction); 44 | uint8_t zen_Instruction_getOperandCount(zen_Instruction_t* instruction); 45 | uint8_t zen_Instruction_getResultCount(zen_Instruction_t* instruction); 46 | 47 | #endif /* ZEN_FEB_INSTRUCTION_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/Type.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Wednesday, January 23, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_TYPE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_TYPE_H 21 | 22 | /******************************************************************************* 23 | * Type * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * @class Type 28 | * @ingroup zen_vm_memory_allocator 29 | * @author Samuel Rowe 30 | * @since zen 1.0 31 | */ 32 | enum zen_Type_t { 33 | ZEN_TYPE_BOOLEAN = 0, 34 | ZEN_TYPE_CHARACTER = 1, 35 | ZEN_TYPE_INTEGER_8 = 2, 36 | ZEN_TYPE_INTEGER_16 = 3, 37 | ZEN_TYPE_INTEGER_32 = 4, 38 | ZEN_TYPE_INTEGER_64 = 5, 39 | ZEN_TYPE_DECIMAL_32 = 6, 40 | ZEN_TYPE_DECIMAL_64 = 7, 41 | ZEN_TYPE_REFERENCE = 8, 42 | ZEN_TYPE_VOID = 9, 43 | ZEN_TYPE_UNKNOWN = 10 44 | }; 45 | 46 | /** 47 | * @memberof Type 48 | */ 49 | typedef enum zen_Type_t zen_Type_t; 50 | 51 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_TYPE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/AttributeTable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, September 21, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_ATTRIBUTE_TABLE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_ATTRIBUTE_TABLE_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * AttributeTable * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class AttributeTable 31 | * @ingroup zen_vm_feb 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_AttributeTable_t { 36 | /** 37 | * The number of additional attributes of this entity. 38 | */ 39 | uint16_t m_size; 40 | 41 | /** 42 | * The additional attributes of this entity, each represented by the 43 | * {@code zen_Attribute_t} structure. 44 | */ 45 | zen_Attribute_t** m_attributes; 46 | }; 47 | 48 | /** 49 | * @memberof AttributeTable 50 | */ 51 | typedef struct zen_AttributeTable_t zen_AttributeTable_t; 52 | 53 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_ATTRIBUTE_TABLE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/ConstantValueAttribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef ZEN_FEB_CONSTANT_VALUE_ATTRIBUTE_H 20 | #define ZEN_FEB_CONSTANT_VALUE_ATTRIBUTE_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ConstantValueAttribute * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * Represents the value of a constant expression. 30 | * 31 | * A static field is assigned a constant value attribute. When a class is 32 | * loaded for the first time, the virtual machine initializes the field to 33 | * this constant value. 34 | */ 35 | struct zen_ConstantValueAttribute_t { 36 | 37 | /** 38 | * A valid index into the constant pool table. The entry at this index 39 | * is a constant value. The appropriate entry types are: 40 | * ZEN_CONSTANT_POOL_TAG_LONG long 41 | * ZEN_CONSTANT_POOL_TAG_FLOAT float 42 | * ZEN_CONSTANT_POOL_TAG_DOUBLE double 43 | * ZEN_CONSTANT_POOL_TAG_INTEGER int, short, char, byte, boolean 44 | * ZEN_CONSTANT_POOL_TAG_STRING String 45 | */ 46 | uint16_t m_valueIndex; 47 | }; 48 | 49 | typedef struct zen_ConstantValueAttribute_t zen_ConstantValueAttribute_t; 50 | 51 | #endif /* ZEN_FEB_CONSTANT_VALUE_ATTRIBUTE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/DeprecatedAttribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, July 11, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_DEPRECATED_ATTRIBUTE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_DEPRECATED_ATTRIBUTE_H 21 | 22 | /******************************************************************************* 23 | * DeprecatedAttribute * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * The deprecated attribute is a secondary attribute, with fixed length. It 28 | * represents the deprecation of a component. The virtual machine does not 29 | * treat this attribute specially. It is designed to accommodate external tools 30 | * such as compilers and debuggers. 31 | * 32 | * @class DeprecatedAttribute 33 | * @ingroup zen_virtualMachine_feb_attribute 34 | * @author Samuel Rowe 35 | * @since zen 1.0 36 | */ 37 | struct zen_DeprecatedAttribute_t { 38 | }; 39 | 40 | /** 41 | * @memberof DeprecatedAttribute 42 | */ 43 | typedef struct zen_DeprecatedAttribute_t zen_DeprecatedAttribute_t; 44 | 45 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_DEPRECATED_ATTRIBUTE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/ExceptionTable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, September 22, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_EXCEPTION_TABLE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_EXCEPTION_TABLE_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * ExceptionTable * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class ExceptionTable 31 | * @ingroup zen_vm_feb 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_ExceptionTable_t { 36 | uint16_t m_size; 37 | zen_ExceptionHandlerSite_t** m_exceptionHandlerSites; 38 | }; 39 | 40 | /** 41 | * @memberof ExceptionTable 42 | */ 43 | typedef struct zen_ExceptionTable_t zen_ExceptionTable_t; 44 | 45 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_EXCEPTION_TABLE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/FunctionParameter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, July 12, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_FUNCTION_PARAMETER_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_FUNCTION_PARAMETER_H 21 | 22 | /******************************************************************************* 23 | * FunctionParameter * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * @class FunctionParameter 28 | * @ingroup zen_virtualMachine_feb_attribute 29 | * @author Samuel Rowe 30 | * @since zen 1.0 31 | */ 32 | struct zen_FunctionParameter_t { 33 | uint16_t m_nameIndex; 34 | }; 35 | 36 | /** 37 | * @memberof FunctionParameter 38 | */ 39 | typedef struct zen_FunctionParameter_t zen_FunctionParameter_t; 40 | 41 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_FUNCTION_PARAMETER_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/FunctionParametersAttribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, July 12, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_FUNCTION_PARAMETERS_ATTRIBUTE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_FUNCTION_PARAMETERS_ATTRIBUTE_H 21 | 22 | /******************************************************************************* 23 | * FunctionParametersAttribute * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * @class FunctionParametersAttribute 28 | * @ingroup zen_virtualMachine_feb_attribute 29 | * @author Samuel Rowe 30 | * @since zen 1.0 31 | */ 32 | struct zen_FunctionParametersAttribute_t { 33 | uint8_t m_size; 34 | zen_FunctionParameter_t** m_parameters; 35 | }; 36 | 37 | /** 38 | * @memberof FunctionParametersAttribute 39 | */ 40 | typedef struct zen_FunctionParametersAttribute_t zen_FunctionParametersAttribute_t; 41 | 42 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_FUNCTION_PARAMETERS_ATTRIBUTE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/LineNumberTableAttribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, July 11, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_LINE_NUMBER_TABLE_ATTRIBUTE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_LINE_NUMBER_TABLE_ATTRIBUTE_H 21 | 22 | /******************************************************************************* 23 | * LineNumberTableAttribute * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * The line number table attribute is a secondary attribute, with a variable 28 | * length. It is designed to accommodate external tools such as debuggers. 29 | * It can be associated with classes, enumerations, fields, and functions. 30 | * 31 | * @class LineNumberTableAttribute 32 | * @ingroup zen_virtualMachine_feb_attribute 33 | * @author Samuel Rowe 34 | * @since zen 1.0 35 | */ 36 | struct zen_LineNumberTableAttribute_t { 37 | uint16_t m_size; 38 | uint16_t* m_startIndexes; 39 | uint16_t* m_lineNumbers; 40 | }; 41 | 42 | /** 43 | * @memberof LineNumberTableAttribute 44 | */ 45 | typedef struct zen_LineNumberTableAttribute_t zen_LineNumberTableAttribute_t; 46 | 47 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_LINE_NUMBER_TABLE_ATTRIBUTE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/LocalVariableTableAttribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, July 11, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_LOCAL_VARIABLE_TABLE_ATTRIBUTE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_LOCAL_VARIABLE_TABLE_ATTRIBUTE_H 21 | 22 | /******************************************************************************* 23 | * LocalVariableTableAttribute * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * The local variable table attribute is a secondary attribute, with variable 28 | * length. It is designed to accommodate external tools such as debuggers. 29 | * 30 | * @class LocalVariableTableAttribute 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_LocalVariableTableAttribute_t { 35 | uint16_t m_size; 36 | zen_LocalVariable_t** m_localVariables; 37 | }; 38 | 39 | /** 40 | * @memberof LocalVariableTableAttribute 41 | */ 42 | typedef struct zen_LocalVariableTableAttribute_t zen_LocalVariableTableAttribute_t; 43 | 44 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_LOCAL_VARIABLE_TABLE_ATTRIBUTE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/ParentFunctionAttribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, July 11, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_PARENT_FUNCTION_ATTRIBUTE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_PARENT_FUNCTION_ATTRIBUTE_H 21 | 22 | /******************************************************************************* 23 | * ParentFunctionAttribute * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * The parent function attribute is a secondary attribute, with fixed length. 28 | * It represents the function enclosing another function. 29 | * 30 | * @class ParentFunctionAttribute 31 | * @ingroup zen_virtualMachine_feb_attribute 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_ParentFunctionAttribute_t { 36 | 37 | /** 38 | * A valid index into the constant pool. The entry at the specified index 39 | * should be a `ConstantPoolFunction` instance. 40 | */ 41 | uint16_t m_functionIndex; 42 | }; 43 | 44 | typedef struct zen_ParentFunctionAttribute_t zen_ParentFunctionAttribute_t; 45 | 46 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_PARENT_FUNCTION_ATTRIBUTE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/ParentOtherAttribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, July 11, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_PARENT_OTHER_ATTRIBUTE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_PARENT_OTHER_ATTRIBUTE_H 21 | 22 | /******************************************************************************* 23 | * ParentOtherAttribute * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * The parent other attribute is a secondary attribute, with fixed length. 28 | * It represents a component such as static initializer, instance initializer, 29 | * or field initializer within whose context a function was declared. 30 | * 31 | * @class ParentOtherAttribute 32 | * @ingroup zen_virtualMachine_feb_attribute 33 | * @author Samuel Rowe 34 | * @since zen 1.0 35 | */ 36 | struct zen_ParentOtherAttribute_t { 37 | 38 | /** 39 | * A valid index into the constant pool. The entry at the specified index 40 | * should be a `ConstantPoolClass` instance. 41 | */ 42 | uint16_t m_classIndex; 43 | }; 44 | 45 | typedef struct zen_ParentOtherAttribute_t zen_ParentOtherAttribute_t; 46 | 47 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_PARENT_OTHER_ATTRIBUTE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/SourceFileAttribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Tuesday, October 02, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_SOURCE_FILE_ATTRIBUTE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_SOURCE_FILE_ATTRIBUTE_H 21 | 22 | /******************************************************************************* 23 | * SourceFileAttribute * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * The source file attribute is a secondary attribute, with a fixed length. 28 | * It represents the file from which a primary entity was compiled. Therefore, 29 | * this attribute can only be associated with a primary entities such as classes, 30 | * enumerations and annotations. 31 | * 32 | * @class SourceFileAttribute 33 | * @ingroup zen_vm_feb 34 | * @author Samuel Rowe 35 | * @since zen 1.0 36 | */ 37 | struct zen_SourceFileAttribute_t { 38 | 39 | /** 40 | * A valid index into the constant pool. The entry at the specified index 41 | * should be a `ConstantPoolUtf8` instance, which contains the path of 42 | * the source file. Further, the value does not hold any special meaning 43 | * to the virtual machine. 44 | */ 45 | uint16_t m_pathIndex; 46 | }; 47 | 48 | /** 49 | * @memberof SourceFileAttribute 50 | */ 51 | typedef struct zen_SourceFileAttribute_t zen_SourceFileAttribute_t; 52 | 53 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_SOURCE_FILE_ATTRIBUTE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/attribute/SyntheticAttribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, July 11, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_SYNTHETIC_ATTRIBUTE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_SYNTHETIC_ATTRIBUTE_H 21 | 22 | /******************************************************************************* 23 | * SyntheticAttribute * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * The synthetic attribute is a secondary attribute, with a fixed length. 28 | * It can be associated with classes, enumerations, fields, and functions. 29 | * 30 | * @class SyntheticAttribute 31 | * @ingroup zen_virtualMachine_feb_attribute 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_SyntheticAttribute_t { 36 | }; 37 | 38 | /** 39 | * @memberof SyntheticAttribute 40 | */ 41 | typedef struct zen_SyntheticAttribute_t zen_SyntheticAttribute_t; 42 | 43 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_FEB_ATTRIBUTE_SYNTHETIC_ATTRIBUTE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/constant-pool/ConstantPoolClass.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef ZEN_FEB_CONSTANT_POOL_CLASS_CONSTANT_POOL_H 20 | #define ZEN_FEB_CONSTANT_POOL_CLASS_CONSTANT_POOL_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ConstantPoolClass * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * Represents a class reference. 30 | * 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_ConstantPoolClass_t { 35 | 36 | /** 37 | * The type of the constant pool entry. 38 | */ 39 | uint8_t m_tag; 40 | 41 | /** 42 | * A valid index into the constant pool. The entry at this index is an 43 | * UTF-8 entry which represents the encoded name of a class. 44 | * 45 | * NOTE: An array class name should consist of the encoded component class 46 | * name along with its dimensions. Further, the dimensions are limited 47 | * to 255, inclusively. 48 | */ 49 | uint16_t m_nameIndex; 50 | }; 51 | 52 | typedef struct zen_ConstantPoolClass_t zen_ConstantPoolClass_t; 53 | 54 | #endif /* ZEN_FEB_CONSTANT_POOL_CLASS_CONSTANT_POOL_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/constant-pool/ConstantPoolDouble.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef ZEN_FEB_CONSTANT_POOL_DOUBLE_CONSTANT_POOL_H 20 | #define ZEN_FEB_CONSTANT_POOL_DOUBLE_CONSTANT_POOL_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ConstantPoolDouble * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * Represents a double floating-value reference. 30 | * 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_ConstantPoolDouble_t { 35 | 36 | /** 37 | * The type of the constant pool entry. 38 | */ 39 | uint8_t m_tag; 40 | 41 | uint32_t m_highBytes; 42 | uint32_t m_lowBytes; 43 | }; 44 | 45 | typedef struct zen_ConstantPoolDouble_t zen_ConstantPoolDouble_t; 46 | 47 | #endif /* ZEN_FEB_CONSTANT_POOL_DOUBLE_CONSTANT_POOL_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/constant-pool/ConstantPoolEntry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef ZEN_FEB_CONSTANT_POOL_CONSTANT_POOL_ENTRY_H 20 | #define ZEN_FEB_CONSTANT_POOL_CONSTANT_POOL_ENTRY_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ConstantPoolEntry * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * Represents a entry. 30 | * 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_ConstantPoolEntry_t { 35 | 36 | /** 37 | * The type of the constant pool entry. 38 | */ 39 | uint8_t m_tag; 40 | }; 41 | 42 | typedef struct zen_ConstantPoolEntry_t zen_ConstantPoolEntry_t; 43 | 44 | #endif /* ZEN_FEB_CONSTANT_POOL_CONSTANT_POOL_ENTRY_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/constant-pool/ConstantPoolFloat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef ZEN_FEB_CONSTANT_POOL_FLOAT_CONSTANT_POOL_H 20 | #define ZEN_FEB_CONSTANT_POOL_FLOAT_CONSTANT_POOL_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ConstantPoolFloat * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * Represents an floating value reference. 30 | * 31 | * @author Samuel Rowe 32 | * @since STK 1.0 33 | */ 34 | struct zen_ConstantPoolFloat_t { 35 | 36 | /** 37 | * The type of the constant pool entry. 38 | */ 39 | uint8_t m_tag; 40 | 41 | /** 42 | * The value of the float constant. The bytes are stored in the 43 | * big-endian order. 44 | * 45 | * The floating value is encoded in IEEE 754 floating-point single format. 46 | * The bits 47 | */ 48 | uint32_t m_bytes; 49 | }; 50 | 51 | /** 52 | * @memberof ConstantPoolFloat 53 | */ 54 | typedef struct zen_ConstantPoolFloat_t zen_ConstantPoolFloat_t; 55 | 56 | /* Value */ 57 | 58 | /** 59 | * @memberof ConstantPoolFloat 60 | */ 61 | float zen_ConstantPoolFloat_getValue(zen_ConstantPoolFloat_t* constantPoolFloat); 62 | 63 | #endif /* ZEN_FEB_CONSTANT_POOL_FLOAT_CONSTANT_POOL_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/constant-pool/ConstantPoolInteger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef ZEN_FEB_CONSTANT_POOL_INTEGER_CONSTANT_POOL_H 20 | #define ZEN_FEB_CONSTANT_POOL_INTEGER_CONSTANT_POOL_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ConstantPoolInteger * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * Represents an integer reference. 30 | * 31 | * @author Samuel Rowe 32 | * @since STK 1.0 33 | */ 34 | struct zen_ConstantPoolInteger_t { 35 | 36 | /** 37 | * The type of the constant pool entry. 38 | */ 39 | uint8_t m_tag; 40 | 41 | /** 42 | * The value of the integer constant. The bytes are stored in the 43 | * big-endian order. 44 | */ 45 | uint32_t m_bytes; 46 | }; 47 | 48 | /** 49 | * @memberof ConstantPoolInteger 50 | */ 51 | typedef struct zen_ConstantPoolInteger_t zen_ConstantPoolInteger_t; 52 | 53 | /* Value */ 54 | 55 | /** 56 | * @memberof ConstantPoolInteger 57 | */ 58 | int32_t zen_ConstantPoolInteger_getValue(zen_ConstantPoolInteger_t* constantPoolInteger); 59 | 60 | #endif /* ZEN_FEB_CONSTANT_POOL_INTEGER_CONSTANT_POOL_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/constant-pool/ConstantPoolLong.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef ZEN_FEB_CONSTANT_POOL_LONG_CONSTANT_POOL_H 20 | #define ZEN_FEB_CONSTANT_POOL_LONG_CONSTANT_POOL_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ConstantPoolLong * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * Represents a long integer reference. 30 | * 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_ConstantPoolLong_t { 35 | 36 | /** 37 | * The type of the constant pool entry. 38 | */ 39 | uint8_t m_tag; 40 | 41 | /** 42 | * The high bytes of the long integer. 43 | */ 44 | uint32_t m_highBytes; 45 | 46 | /** 47 | * The low bytes of the long integer. 48 | */ 49 | uint32_t m_lowBytes; 50 | }; 51 | 52 | typedef struct zen_ConstantPoolLong_t zen_ConstantPoolLong_t; 53 | 54 | #endif /* ZEN_FEB_CONSTANT_POOL_LONG_CONSTANT_POOL_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/constant-pool/ConstantPoolString.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef ZEN_FEB_CONSTANT_POOL_STRING_CONSTANT_POOL_H 20 | #define ZEN_FEB_CONSTANT_POOL_STRING_CONSTANT_POOL_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ConstantPoolString * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * Represents a string reference. 30 | * 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_ConstantPoolString_t { 35 | 36 | /** 37 | * The type of the constant pool entry. 38 | */ 39 | uint8_t m_tag; 40 | 41 | /** 42 | * A valid index into the constant pool. The entry at this index is an 43 | * UTF-8 element which represents the sequence of Unicode code points 44 | * contained in this string entry. 45 | */ 46 | uint16_t m_stringIndex; 47 | }; 48 | 49 | typedef struct zen_ConstantPoolString_t zen_ConstantPoolString_t; 50 | 51 | #endif /* ZEN_FEB_CONSTANT_POOL_STRING_CONSTANT_POOL_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/constant-pool/ConstantPoolTag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 28, 2018 18 | 19 | #ifndef ZEN_FEB_CONSTANT_POOL_TAG_CONSTANT_POOL_H 20 | #define ZEN_FEB_CONSTANT_POOL_TAG_CONSTANT_POOL_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ConstantPoolTag * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @author Samuel Rowe 30 | * @since zen 1.0 31 | */ 32 | enum zen_ConstantPoolTag_t { 33 | ZEN_CONSTANT_POOL_TAG_INTEGER = 0, 34 | ZEN_CONSTANT_POOL_TAG_LONG = 1, 35 | ZEN_CONSTANT_POOL_TAG_FLOAT = 2, 36 | ZEN_CONSTANT_POOL_TAG_DOUBLE = 3, 37 | ZEN_CONSTANT_POOL_TAG_UTF8 = 4, 38 | ZEN_CONSTANT_POOL_TAG_STRING = 5, 39 | ZEN_CONSTANT_POOL_TAG_FUNCTION = 6, 40 | ZEN_CONSTANT_POOL_TAG_FIELD = 7, 41 | ZEN_CONSTANT_POOL_TAG_CLASS = 8 42 | }; 43 | 44 | typedef enum zen_ConstantPoolTag_t zen_ConstantPoolTag_t; 45 | 46 | #endif /* ZEN_FEB_CONSTANT_POOL_TAG_CONSTANT_POOL_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/feb/constant-pool/ConstantPoolUtf8.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | // Saturday, April 28, 2018 19 | 20 | #ifndef ZEN_FEB_CONSTANT_POOL_UTF8_CONSTANT_POOL_H 21 | #define ZEN_FEB_CONSTANT_POOL_UTF8_CONSTANT_POOL_H 22 | 23 | #include 24 | 25 | /******************************************************************************* 26 | * ConstantPoolUtf8 * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * Represents various strings referenced by the code. 31 | */ 32 | struct zen_ConstantPoolUtf8_t { 33 | 34 | /** 35 | * The type of the constant pool entry. 36 | */ 37 | uint8_t m_tag; 38 | 39 | /** 40 | * The number of bytes the {@code m_bytes} array occupies. 41 | */ 42 | uint16_t m_length; 43 | 44 | /** 45 | * The bytes contained in the string, encoded in UTF-8. 46 | */ 47 | uint8_t* m_bytes; 48 | 49 | int32_t m_hashCode; 50 | }; 51 | 52 | typedef struct zen_ConstantPoolUtf8_t zen_ConstantPoolUtf8_t; 53 | 54 | #endif /* ZEN_FEB_CONSTANT_POOL_UTF8_CONSTANT_POOL_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/loader/BinaryEntityLoader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, September 20, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_BINARY_ENTITY_LOADER_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_BINARY_ENTITY_LOADER_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * BinaryEntityLoader * 26 | *******************************************************************************/ 27 | 28 | struct zen_BinaryEntityLoader_t { 29 | }; 30 | 31 | typedef struct zen_BinaryEntityLoader_t zen_BinaryEntityLoader_t; 32 | 33 | zen_BinaryEntityLoader_t* zen_BinaryEntityLoader_new(); 34 | 35 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_BINARY_ENTITY_LOADER_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/loader/BinaryEntityVerifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Monday, June 11, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_BINARY_ENTITY_VERIFIER_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_BINARY_ENTITY_VERIFIER_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * BinaryEntityVerifier * 26 | *******************************************************************************/ 27 | 28 | struct zen_BinaryEntityVerifier_t { 29 | }; 30 | 31 | typedef struct zen_BinaryEntityVerifier_t zen_BinaryEntityVerifier_t; 32 | 33 | /* Constructor */ 34 | 35 | zen_BinaryEntityVerifier_t* zen_BinaryEntityVerifier_new(); 36 | 37 | /* Destructor */ 38 | 39 | void zen_BinaryEntityVerifier_delete(zen_BinaryEntityVerifier_t* verifier); 40 | 41 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_BINARY_ENTITY_VERIFIER_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/loader/EntityResolver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, September 23, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_ENTITY_RESOLVER_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_ENTITY_RESOLVER_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * EntityResolver * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class EntityResolver 31 | * @ingroup zen_vm_loader 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_EntityResolver_t { 36 | zen_ResolutionManager_t* m_resolutionManager; 37 | }; 38 | 39 | /** 40 | * @memberof EntityResolver 41 | */ 42 | typedef struct zen_EntityResolver_t zen_EntityResolver_t; 43 | 44 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_ENTITY_RESOLVER_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/loader/ResolutionManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, September 23, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_RESOLUTION_MANAGER_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_RESOLUTION_MANAGER_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ResolutionManager * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class ResolutionManager 30 | * @ingroup zen_vm_loader 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_ResolutionManager_t { 35 | }; 36 | 37 | /** 38 | * @memberof ResolutionManager 39 | */ 40 | typedef struct zen_ResolutionManager_t zen_ResolutionManager_t; 41 | 42 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_LOADER_RESOLUTION_MANAGER_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/ObjectType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, January 25, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_OBJECT_TYPE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_OBJECT_TYPE_H 21 | 22 | /******************************************************************************* 23 | * ObjectType * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * @class ObjectType 28 | * @ingroup zen_virtualMachine_memory 29 | * @author Samuel Rowe 30 | * @since zen 1.0 31 | */ 32 | enum zen_ObjectType_t { 33 | ZEN_OBJECT_TYPE_PRIMITIVE_ARRAY = 0, 34 | ZEN_OBJECT_TYPE_REFERENCE_ARRAY = 1, 35 | ZEN_OBJECT_TYPE_AGGREGATE_OBJECT = 2, 36 | }; 37 | 38 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_OBJECT_TYPE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/PendingMessageQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Monday, September 03, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_PENDING_MESSAGE_QUEUE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_PENDING_MESSAGE_QUEUE_H 21 | 22 | /******************************************************************************* 23 | * PendingMessageQueue * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * Insertion of messages into the message queue of the garbage collector 28 | * should be carefully done. 29 | * 30 | * The garbage collector pauses all the threads when collecting. Chances 31 | * are a mutator thread may hold the lock of the message queue. 32 | * This may cause a deadlock. 33 | * 34 | * A solution to this problem is the *pending message queue*. Messages and 35 | * their corresponding handlers are inserted in a special queue. These 36 | * messages are flushed into the target message queue once all the mutator 37 | * threads are resumed. 38 | 39 | * @class PendingMessageQueue 40 | * @ingroup zen_mms 41 | * @author Samuel Rowe 42 | * @since zen 1.0 43 | */ 44 | struct zen_PendingMessageQueue_t { 45 | 46 | zen_SinglyLinkedList_t* m_messages; 47 | }; 48 | 49 | /** 50 | * @memberof PendingMessageQueue 51 | */ 52 | typedef struct zen_PendingMessageQueue_t zen_PendingMessageQueue_t; 53 | 54 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_PENDING_MESSAGE_QUEUE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/allocator/AlignmentConstraint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, January 26, 2019 (Happy Republic Day, India!) 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALIGNMENT_CONSTRAINT_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALIGNMENT_CONSTRAINT_H 21 | 22 | /******************************************************************************* 23 | * AlignmentConstraint * 24 | *******************************************************************************/ 25 | 26 | enum zen_AlignmentConstraint_t { 27 | ZEN_ALIGNMENT_CONSTRAINT_DEFAULT, 28 | ZEN_ALIGNMENT_CONSTRAINT_16_BITS, 29 | ZEN_ALIGNMENT_CONSTRAINT_32_BITS, 30 | ZEN_ALIGNMENT_CONSTRAINT_64_BITS, 31 | ZEN_ALIGNMENT_CONSTRAINT_128_BITS 32 | }; 33 | 34 | typedef enum zen_AlignmentConstraint_t zen_AlignmentConstraint_t; 35 | 36 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALIGNMENT_CONSTRAINT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/allocator/AllocationBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Monday, September 03, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALLOCATION_BUFFER_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALLOCATION_BUFFER_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * AllocationBuffer * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class AllocationBuffer 30 | * @ingroup zen_mms_allocator 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_AllocationBuffer_t { 35 | }; 36 | 37 | /** 38 | * @memberof AllocationBuffer 39 | */ 40 | typedef struct zen_AllocationBuffer_t zen_AllocationBuffer_t; 41 | 42 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALLOCATION_BUFFER_H */ 43 | 44 | zen_Object_t* zen_AllocationBuffer_allocate(zen_AllocationBuffer_t* buffer, 45 | int32_t headerSize, int32_t bodySize) { 46 | jtk_Assert_assertObject(buffer, "The specified allocation buffer is null."); 47 | 48 | int8_t* result = NULL; 49 | int8_t* newFree = allocator->m_free + (headerSize + bodySize); 50 | if (newFree <= buffer->m_limit) { 51 | result = allocator->m_free; 52 | buffer->m_free = newFree; 53 | } 54 | return result; 55 | } -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/allocator/AllocationFlag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Wednesday, January 23, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALLOCATION_FLAG_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALLOCATION_FLAG_H 21 | 22 | /******************************************************************************* 23 | * AllocationFlag * 24 | *******************************************************************************/ 25 | 26 | enum zen_AllocationFlag_t { 27 | ZEN_ALLOCATION_FLAG_MANUAL = (1 << 0), 28 | ZEN_ALLOCATION_FLAG_AUTOMATIC = (1 << 1), 29 | ZEN_ALLOCATION_FLAG_IMMORTAL = (1 << 2) 30 | }; 31 | 32 | typedef enum zen_AllocationFlag_t zen_AllocationFlag_t; 33 | 34 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALLOCATION_FLAG_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/allocator/Allocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, August 30, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALLOCATOR_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALLOCATOR_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * Allocator * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class Allocator 30 | * @ingroup zen_heap 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_Allocator_t { 35 | }; 36 | 37 | /** 38 | * @memberof Allocator 39 | */ 40 | typedef struct zen_Allocator_t zen_Allocator_t; 41 | 42 | /* Allocate */ 43 | 44 | /** 45 | * @memberof Allocator 46 | */ 47 | void* zen_Allocator_allocate(zen_Allocator_t* allocator, uint32_t size); 48 | 49 | /** 50 | * @memberof Allocator 51 | */ 52 | void* zen_Allocator_tryAllocate(zen_Allocator_t* allocator, uint32_t size); 53 | 54 | /* Deallocate */ 55 | 56 | /** 57 | * @memberof Allocator 58 | */ 59 | void zen_Allocator_deallocate(zen_Allocator_t* allocator, void* buffer, uint32_t size); 60 | 61 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_ALLOCATOR_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/allocator/SegregatedFitsAllocatorMode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, March 17, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_SEGREGATED_FITS_ALLOCATOR_MODE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_SEGREGATED_FITS_ALLOCATOR_MODE_H 21 | 22 | /******************************************************************************* 23 | * SegregatedFitsAllocatorMode * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * @class SegregatedFitsAllocatorMode 28 | * @ingroup zen_virtualMachine_memory_allocator 29 | * @author Samuel Rowe 30 | * @since zen 1.0 31 | */ 32 | enum zen_SegregatedFitsAllocatorMode_t { 33 | ZEN_SEGREGATED_FITS_ALLOCATOR_MODE_NEXT_FIT, 34 | ZEN_SEGREGATED_FITS_ALLOCATOR_MODE_BEST_FIT, 35 | ZEN_SEGREGATED_FITS_ALLOCATOR_MODE_FIRST_FIT 36 | }; 37 | 38 | /** 39 | * @memberof SegregatedFitsAllocatorMode 40 | */ 41 | typedef enum zen_SegregatedFitsAllocatorMode_t zen_SegregatedFitsAllocatorMode_t; 42 | 43 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_SEGREGATED_FITS_ALLOCATOR_MODE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/allocator/SizeClass.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, March 17, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_SIZE_CLASS_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_SIZE_CLASS_H 21 | 22 | /******************************************************************************* 23 | * SizeClass * 24 | *******************************************************************************/ 25 | 26 | 27 | 28 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_ALLOCATOR_SIZE_CLASS_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/collector/GarbageCollectionFlag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Wednesday, January 23, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTION_FLAG_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTION_FLAG_H 21 | 22 | /******************************************************************************* 23 | * GarbageCollectionFlag * 24 | *******************************************************************************/ 25 | 26 | #define ZEN_GARBAGE_COLLECTION_FLAG_SQUEEZE (1 << 0) 27 | 28 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTION_FLAG_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/collector/GarbageCollectionReason.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, August 30, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTION_REASON_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTION_REASON_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * GarbageCollectionReason * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class GarbageCollectionReason 30 | * @ingroup zen_vm_memory_collector 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | enum zen_GarbageCollectionReason_t { 35 | ZEN_GARBAGE_COLLECTION_REASON_NATIVE_REQUEST, 36 | ZEN_GARBAGE_COLLECTION_REASON_APPLICATION_REQUEST 37 | }; 38 | 39 | /** 40 | * @memberof GarbageCollectionReason 41 | */ 42 | typedef enum zen_GarbageCollectionReason_t zen_GarbageCollectionReason_t; 43 | 44 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTION_REASON_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/collector/GarbageCollectionType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, August 30, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTION_TYPE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTION_TYPE_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * GarbageCollectionType * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class GarbageCollectionType 30 | * @ingroup zen_vm_memory_collector 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | enum zen_GarbageCollectionType_t { 35 | ZEN_GARBAGE_COLLECTION_TYPE_MINOR, 36 | ZEN_GARBAGE_COLLECTION_TYPE_MAJOR 37 | }; 38 | 39 | /** 40 | * @memberof GarbageCollectionType 41 | */ 42 | typedef enum zen_GarbageCollectionType_t zen_GarbageCollectionType_t; 43 | 44 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTION_TYPE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/collector/GarbageCollector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, August 30, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_COLLECTOR_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_COLLECTOR_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | /******************************************************************************* 28 | * GarbageCollector * 29 | *******************************************************************************/ 30 | 31 | /** 32 | * @class GarbageCollector 33 | * @ingroup zen_vm_memory_collector 34 | * @author Samuel Rowe 35 | * @since zen 1.0 36 | */ 37 | struct zen_GarbageCollector_t { 38 | int64_t m_lastCollectionTime; 39 | int64_t m_totalCollectionTime; 40 | }; 41 | 42 | /** 43 | * @memberof GarbageCollector 44 | */ 45 | typedef struct zen_GarbageCollector_t zen_GarbageCollector_t; 46 | 47 | /* Constructor */ 48 | 49 | /** 50 | * @memberof GarbageCollector 51 | */ 52 | zen_GarbageCollector_t* zen_GarbageCollector_new(); 53 | 54 | /* Destructor */ 55 | 56 | /** 57 | * @memberof GarbageCollector 58 | */ 59 | void zen_GarbageCollector_delete(zen_GarbageCollector_t* planet); 60 | 61 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_COLLECTOR_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/collector/GarbageCollectorType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, March 16, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTOR_TYPE_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTOR_TYPE_H 21 | 22 | /******************************************************************************* 23 | * GarbageCollectorType * 24 | *******************************************************************************/ 25 | 26 | enum zen_GarbageCollectorType_t { 27 | ZEN_GARBAGE_COLLECTOR_TYPE_MARK_SWEEP, 28 | ZEN_GARBAGE_COLLECTOR_TYPE_COPYING 29 | }; 30 | 31 | typedef enum zen_GarbageCollectorType_t zen_GarbageCollectorType_t; 32 | 33 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_COLLECTOR_GARBAGE_COLLECTOR_TYPE_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/heap/Generation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, August 31, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_GENERATION_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_GENERATION_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * Generation * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class Generation 30 | * @ingroup zen_heap 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_Generation_t { 35 | uintptr_t* m_words; 36 | uint32_t m_position; 37 | uint32_t m_capacity; 38 | }; 39 | 40 | /** 41 | * @memberof Generation 42 | */ 43 | typedef struct zen_Generation_t zen_Generation_t; 44 | 45 | /* Constructor */ 46 | 47 | /** 48 | * @memberof Generation 49 | */ 50 | zen_Generation_t* zen_Generation_new(zen_Planet_t* planet, zen_Directory_t* directory); 51 | 52 | /* Destructor */ 53 | 54 | /** 55 | * @memberof Generation 56 | */ 57 | void zen_Generation_delete(zen_Generation_t* generation); 58 | 59 | /* Allocate */ 60 | 61 | /** 62 | * @memberof Generation 63 | */ 64 | void* zen_Generation_allocate(zen_Generation_t* generation, uint32_t size); 65 | 66 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_GENERATION_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/heap/Heap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Thursday, August 30, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_HEAP_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_HEAP_H 21 | 22 | /******************************************************************************* 23 | * Heap * 24 | *******************************************************************************/ 25 | 26 | /** 27 | * @class Heap 28 | * @ingroup zen_heap 29 | * @author Samuel Rowe 30 | * @since zen 1.0 31 | */ 32 | struct zen_Heap_t { 33 | }; 34 | 35 | /** 36 | * @memberof Heap 37 | */ 38 | typedef struct zen_Heap_t zen_Heap_t; 39 | 40 | /* Constructor */ 41 | 42 | /** 43 | * @memberof Heap 44 | */ 45 | zen_Heap_t* zen_Heap_new(); 46 | 47 | /* Destructor */ 48 | 49 | /** 50 | * @memberof Heap 51 | */ 52 | void zen_Heap_delete(zen_Heap_t* heap); 53 | 54 | /* Allocate */ 55 | 56 | /** 57 | * @memberof Heap 58 | */ 59 | void* zen_Heap_allocate(zen_Heap_t* heap, zen_Allocator_t* allocator); 60 | 61 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_HEAP_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/heap/ImmortalGeneration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, September 02, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_IMMORTAL_GENERATION_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_IMMORTAL_GENERATION_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * ImmortalGeneration * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class ImmortalGeneration 30 | * @ingroup zen_heap 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_ImmortalGeneration_t { 35 | }; 36 | 37 | /** 38 | * @memberof ImmortalGeneration 39 | */ 40 | typedef struct zen_ImmortalGeneration_t zen_ImmortalGeneration_t; 41 | 42 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_IMMORTAL_GENERATION_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/heap/NewGeneration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, September 02, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_NEW_GENERATION_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_NEW_GENERATION_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | /******************************************************************************* 27 | * NewGeneration * 28 | *******************************************************************************/ 29 | 30 | /** 31 | * @class NewGeneration 32 | * @ingroup zen_vm_memory_heap 33 | * @author Samuel Rowe 34 | * @since zen 1.0 35 | */ 36 | struct zen_NewGeneration_t { 37 | zen_Region_t* m_leftRegion; 38 | zen_Region_t* m_middleRegion; 39 | zen_Region_t* m_rightRegion; 40 | 41 | zen_SegregatedFitsAllocator_t* m_allocator; 42 | }; 43 | 44 | /** 45 | * @memberof NewGeneration 46 | */ 47 | typedef struct zen_NewGeneration_t zen_NewGeneration_t; 48 | 49 | #endif /* ZEN_MMS_HEAP_NEW_GENERATION_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/heap/Object.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, August 31, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_OBJECT_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_OBJECT_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * Object * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class Object 30 | * @ingroup zen_heap 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_Object_t { 35 | int32_t m_flags; 36 | int32_t m_size; 37 | }; 38 | 39 | /** 40 | * @memberof Object 41 | */ 42 | typedef struct zen_Object_t zen_Object_t; 43 | 44 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_OBJECT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/heap/OldGeneration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, September 02, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_OLD_GENERATION_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_OLD_GENERATION_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * OldGeneration * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class OldGeneration 31 | * @ingroup zen_heap 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_OldGeneration_t { 36 | zen_Region_t* m_whiteRegion; 37 | zen_Region_t* m_blackRegion; 38 | }; 39 | 40 | /** 41 | * @memberof OldGeneration 42 | */ 43 | typedef struct zen_OldGeneration_t zen_OldGeneration_t; 44 | 45 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_OLD_GENERATION_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/heap/Region.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, September 02, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_REGION_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_REGION_H 21 | 22 | #include 23 | 24 | /******************************************************************************* 25 | * Region * 26 | *******************************************************************************/ 27 | 28 | /** 29 | * @class Region 30 | * @ingroup zen_heap 31 | * @author Samuel Rowe 32 | * @since zen 1.0 33 | */ 34 | struct zen_Region_t { 35 | }; 36 | 37 | /** 38 | * @memberof Region 39 | */ 40 | typedef struct zen_Region_t zen_Region_t; 41 | 42 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_MEMORY_HEAP_REGION_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/memory/module.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, September 02, 2018 18 | 19 | /** 20 | * @defgroup zen_mms Memory Management System 21 | * @ingroup zen 22 | */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/object/Field.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, July 14, 2019 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_OBJECT_FIELD_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_OBJECT_FIELD_H 21 | 22 | #include 23 | #include 24 | 25 | // Forward References 26 | 27 | typedef struct zen_Class_t zen_Class_t; 28 | 29 | /******************************************************************************* 30 | * Field * 31 | *******************************************************************************/ 32 | 33 | /** 34 | * @class Field 35 | * @ingroup zen_virtualMachine_object 36 | * @author Samuel Rowe 37 | * @since zen 1.0 38 | */ 39 | struct zen_Field_t { 40 | uint8_t* m_name; 41 | int32_t m_nameSize; 42 | uint8_t* m_descriptor; 43 | int32_t m_descriptorSize; 44 | zen_Class_t* m_class; 45 | int32_t m_offset; 46 | zen_FieldEntity_t* m_entity; 47 | }; 48 | 49 | /** 50 | * @memberof Field 51 | */ 52 | typedef struct zen_Field_t zen_Field_t; 53 | 54 | // Constructor 55 | 56 | zen_Field_t* zen_Field_new(zen_Class_t* class0, 57 | zen_FieldEntity_t* fieldEntity, int32_t offset); 58 | 59 | // Destructor 60 | 61 | void zen_Field_delete(zen_Field_t* field); 62 | 63 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_OBJECT_FIELD_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/object/Object.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, May 18, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_OBJECT_OBJECT_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_OBJECT_OBJECT_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * Object * 27 | *******************************************************************************/ 28 | 29 | struct zen_Object_t { 30 | }; 31 | 32 | typedef struct zen_Object_t zen_Object_t; 33 | 34 | zen_Class_t* zen_Object_getClass(zen_Object_t* object); 35 | 36 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_OBJECT_OBJECT_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/object/ObjectArray.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, May 18, 2018 18 | 19 | #ifndef ZEN_VM_OBJECT_ARRAY_H 20 | #define ZEN_VM_OBJECT_ARRAY_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * ObjectArray * 27 | *******************************************************************************/ 28 | 29 | struct zen_ObjectArray_t { 30 | }; 31 | 32 | typedef struct zen_ObjectArray_t zen_ObjectArray_t; 33 | 34 | /* Value */ 35 | 36 | void zen_ObjectArray_setValue(zen_ObjectArray_t* array, int32_t index, zen_Object_t* value); 37 | zen_Object_t* zen_ObjectArray_getValue(zen_ObjectArray_t* array, int32_t index); 38 | 39 | #endif /* ZEN_VM_OBJECT_ARRAY_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/processor/Processor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, September 16, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_PROCESSOR_PROCESSOR_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_PROCESSOR_PROCESSOR_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * Processor * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class Processor 31 | * @ingroup zen_vm_processor 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_Processor_t { 36 | zen_Interpreter_t* m_interpreter; 37 | }; 38 | 39 | /** 40 | * @memberof Processor 41 | */ 42 | typedef struct zen_Processor_t zen_Processor_t; 43 | 44 | /* Constructor */ 45 | 46 | /** 47 | * @memberof Processor 48 | */ 49 | zen_Processor_t* zen_Processor_new(); 50 | 51 | /* Destructor */ 52 | 53 | /** 54 | * @memberof Processor 55 | */ 56 | void zen_Processor_delete(zen_Processor_t* processor); 57 | 58 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_PROCESSOR_PROCESSOR_H */ -------------------------------------------------------------------------------- /include/com/onecube/zen/virtual-machine/processor/ProcessorThread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, September 16, 2018 18 | 19 | #ifndef COM_ONECUBE_ZEN_VIRTUAL_MACHINE_PROCESSOR_PROCESSOR_THREAD_H 20 | #define COM_ONECUBE_ZEN_VIRTUAL_MACHINE_PROCESSOR_PROCESSOR_THREAD_H 21 | 22 | #include 23 | #include 24 | 25 | /******************************************************************************* 26 | * ProcessorThread * 27 | *******************************************************************************/ 28 | 29 | /** 30 | * @class ProcessorThread 31 | * @ingroup zen_vm_processor 32 | * @author Samuel Rowe 33 | * @since zen 1.0 34 | */ 35 | struct zen_ProcessorThread_t { 36 | zen_InvocationStack_t* m_invocationStack; 37 | }; 38 | 39 | /** 40 | * @memberof ProcessorThread 41 | */ 42 | typedef struct zen_ProcessorThread_t zen_ProcessorThread_t; 43 | 44 | /* Constructor */ 45 | 46 | /** 47 | * @memberof ProcessorThread 48 | */ 49 | zen_ProcessorThread_t* zen_ProcessorThread_new(); 50 | 51 | /* Destructor */ 52 | 53 | /** 54 | * @memberof ProcessorThread 55 | */ 56 | void zen_ProcessorThread_delete(zen_ProcessorThread_t* thread); 57 | 58 | #endif /* COM_ONECUBE_ZEN_VIRTUAL_MACHINE_PROCESSOR_PROCESSOR_THREAD_H */ -------------------------------------------------------------------------------- /source/com/onecube/zen/Configuration.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | static int32_t s_footprint = 0; 20 | 21 | void* zen_Memory_allocate0(int32_t size) { 22 | s_footprint += size; 23 | 24 | void* object = malloc(size); 25 | return object; 26 | } 27 | 28 | int32_t zen_Memory_getFootprint() { 29 | return s_footprint; 30 | } 31 | 32 | void zen_StackTrace_enter0(const char* file, const char* function) { 33 | fprintf(stdout, "[enter] %s(%s)\n", function, file); 34 | } 35 | 36 | void zen_StackTrace_exit0(const char* file, const char* function) { 37 | fprintf(stdout, "[exit] %s(%s)\n", function, file); 38 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/DisassemblerTool.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, April 17, 2019 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | int32_t main(int32_t length, char** arguments) { 24 | zen_Instruction_verify(); 25 | 26 | zen_BinaryEntityDisassembler_t* disassembler = zen_BinaryEntityDisassembler_new(NULL); 27 | zen_BinaryEntityDisassembler_addDirectory(disassembler, ".", 1); 28 | 29 | int32_t descriptorSize = -1; 30 | uint8_t* descriptor = jtk_CString_make(arguments[1], &descriptorSize); 31 | jtk_Arrays_replace_b(descriptor, descriptorSize, '.', '/'); 32 | zen_BinaryEntityDisassembler_disassembleClass(disassembler, descriptor, 33 | descriptorSize); 34 | jtk_CString_delete(descriptor); 35 | 36 | zen_BinaryEntityDisassembler_delete(disassembler); 37 | 38 | return 0; 39 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/InputStream.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, November 04, 2017 18 | 19 | #include 20 | #include 21 | 22 | /******************************************************************************* 23 | * InputStream * 24 | *******************************************************************************/ 25 | 26 | zen_InputStream_t* zen_InputStream_new(const char* path) { 27 | zen_InputStream_t* stream = zen_Memory_allocate(zen_InputStream_t, 1); 28 | stream->m_file = fopen(path, "r"); 29 | stream->m_path = strdup(path); 30 | stream->m_available = 1; 31 | return stream; 32 | } 33 | 34 | void zen_InputStream_delete(zen_InputStream_t* stream) { 35 | jtk_Assert_assertObject(stream, "The specified input stream is null."); 36 | free(stream->m_path); 37 | fclose(stream->m_file); 38 | jtk_Memory_deallocate(stream); 39 | } 40 | 41 | int32_t zen_InputStream_read(zen_InputStream_t* stream) { 42 | jtk_Assert_assertObject(stream, "The specified input stream is null."); 43 | if (stream->m_available != 0) { 44 | char c = fgetc(stream->m_file); 45 | if (c == EOF) { 46 | stream->m_available = 0; 47 | } 48 | return c; 49 | } 50 | return 0; 51 | } 52 | 53 | int32_t zen_InputStream_isAvailable(zen_InputStream_t* stream) { 54 | jtk_Assert_assertObject(stream, "The specified input stream is null."); 55 | return stream->m_available; 56 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/String.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, November 04, 2017 18 | 19 | #include 20 | 21 | uint8_t* jtk_CString_new(const uint8_t* string) { 22 | return jtk_CString_newEx(string, jtk_CString_getSize(string)); 23 | } 24 | 25 | uint8_t* jtk_CString_newEx(const uint8_t* string, int32_t size) { 26 | uint8_t* result = zen_Memory_allocate(uint8_t, size + 1); 27 | int32_t i; 28 | for (i = 0; i < size; i++) { 29 | result[i] = string[i]; 30 | } 31 | result[size] = '\0'; 32 | return result; 33 | } 34 | 35 | void jtk_CString_delete(uint8_t* string) { 36 | jtk_Memory_deallocate(string); 37 | } 38 | 39 | bool jtk_CString_equals(const uint8_t* string1, int32_t size1, const uint8_t* string2, int32_t size2) { 40 | if (string1 == string2) { 41 | return 1; 42 | } 43 | if ((string1 == NULL) ^ (string2 == NULL)) { 44 | return false; 45 | } 46 | if (size1 == size2) { 47 | int32_t i; 48 | for (i = 0; i < size1; i++) { 49 | if (string1[i] != string2[i]) { 50 | return false; 51 | } 52 | } 53 | return true; 54 | } 55 | return false; 56 | } 57 | 58 | int32_t jtk_CString_getSize(const uint8_t* string) { 59 | int32_t i = 0; 60 | while (string[i++] != '\0'); 61 | return i - 1; 62 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/Zen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | int32_t main(int32_t length, char** arguments) { 20 | // jtk_Assert_assertTrue(zen_Instruction_verify(), "The instruction set is invalid."); 21 | 22 | jtk_System_initialize(); 23 | 24 | zen_Compiler_t* compiler = zen_Compiler_new(); 25 | bool result = zen_Compiler_compileEx(compiler, arguments, length); 26 | zen_Compiler_delete(compiler); 27 | 28 | return result? 0 : 1; 29 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/compiler/ast/AstAnnotation.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, April 29, 2018 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * ASTAnnotation * 23 | *******************************************************************************/ 24 | 25 | zen_ASTAnnotation_t* zen_ASTAnnotation_new(zen_ASTAnnotationType_t type, void* bundle) { 26 | zen_ASTAnnotation_t* annotation = zen_Memory_allocate(zen_ASTAnnotation_t, 1); 27 | annotation->m_type = type; 28 | annotation->m_bundle = bundle; 29 | 30 | return annotation; 31 | } 32 | 33 | void zen_ASTAnnotation_delete(zen_ASTAnnotation_t* annotation) { 34 | jtk_Assert_assertObject(annotation, "The specified annotation is null."); 35 | 36 | jtk_Memory_deallocate(annotation); 37 | } 38 | 39 | zen_ASTAnnotationType_t zen_ASTAnnotation_getType(zen_ASTAnnotation_t* annotation) { 40 | jtk_Assert_assertObject(annotation, "The specified annotation is null."); 41 | 42 | return annotation->m_type; 43 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/compiler/lexer/LexerError.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | zen_LexerError_t* zen_LexerError_new(const char* message, const char* path, int32_t line, int32_t column) { 21 | zen_LexerError_t* error = jtk_Memory_allocate(zen_LexerError_t, 1); 22 | error->m_message = (message == NULL)? jtk_CString_new("No error message") : jtk_CString_new(message); 23 | error->m_path = jtk_CString_new(path); 24 | error->m_line = line; 25 | error->m_column = column; 26 | 27 | return error; 28 | } 29 | 30 | void zen_LexerError_delete(zen_LexerError_t* error) { 31 | jtk_Assert_assertObject(error, "The specified lexer error is null."); 32 | jtk_Memory_deallocate(error->m_message); 33 | jtk_Memory_deallocate(error); 34 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/compiler/parser/ParserError.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Sunday, December 03, 2017 18 | 19 | #include 20 | #include 21 | 22 | zen_ParserError_t* zen_ParserError_new() { 23 | zen_ParserError_t* error = zen_Memory_allocate(zen_ParserError_t, 1); 24 | error->m_message = NULL; 25 | return error; 26 | } 27 | 28 | void zen_ParserError_delete(zen_ParserError_t* error) { 29 | jtk_Assert_assertObject(error, "The specified error is null."); 30 | 31 | if (error->m_message != NULL) { 32 | jtk_CString_delete(error->m_message); 33 | } 34 | 35 | jtk_Memory_deallocate(error); 36 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/compiler/support/Error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | /******************************************************************************* 20 | * Error * 21 | *******************************************************************************/ 22 | 23 | // Constructor 24 | 25 | zen_Error_t* zen_Error_new(zen_ErrorCode_t code, zen_Token_t* token) { 26 | return zen_Error_newEx(code, token, ZEN_TOKEN_UNKNOWN); 27 | } 28 | 29 | zen_Error_t* zen_Error_newEx(zen_ErrorCode_t code, zen_Token_t* token, 30 | zen_TokenType_t expected) { 31 | zen_Error_t* error = jtk_Memory_allocate(zen_Error_t, 1); 32 | error->m_code = code; 33 | error->m_token = token; 34 | error->m_expected = expected; 35 | 36 | return error; 37 | } 38 | 39 | // Destructor 40 | 41 | void zen_Error_delete(zen_Error_t* error) { 42 | jtk_Assert_assertObject(error, "The specified error is null."); 43 | 44 | jtk_Memory_deallocate(error); 45 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/compiler/symbol-table/symbol/ConstantSymbol.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Tuesday, February 27, 2018 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * ConstantSymbol * 23 | *******************************************************************************/ 24 | 25 | zen_ConstantSymbol_t* zen_ConstantSymbol_new(zen_ASTNode_t* identifier, 26 | zen_Scope_t* enclosingScope) { 27 | zen_ConstantSymbol_t* constantSymbol = zen_Memory_allocate(zen_ConstantSymbol_t, 1); 28 | 29 | zen_Symbol_t* symbol = zen_Symbol_new(ZEN_SYMBOL_CATEGORY_CONSTANT, identifier, enclosingScope, constantSymbol); 30 | 31 | constantSymbol->m_symbol = symbol; 32 | constantSymbol->m_index = -1; 33 | 34 | return constantSymbol; 35 | } 36 | 37 | void zen_ConstantSymbol_delete(zen_ConstantSymbol_t* symbol) { 38 | jtk_Assert_assertObject(symbol, "The specified symbol is null."); 39 | 40 | zen_Symbol_delete(symbol->m_symbol); 41 | jtk_Memory_deallocate(symbol); 42 | } 43 | 44 | zen_Symbol_t* zen_ConstantSymbol_getSymbol(zen_ConstantSymbol_t* symbol) { 45 | jtk_Assert_assertObject(symbol, "The specified symbol is null."); 46 | 47 | return symbol->m_symbol; 48 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/compiler/symbol-table/symbol/EnumerateSymbol.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, March 09, 2018 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * EnumerateSymbol * 23 | *******************************************************************************/ 24 | 25 | #warning "TODO: Add ordinal to this symbol." 26 | 27 | zen_EnumerateSymbol_t* zen_EnumerateSymbol_new(zen_ASTNode_t* identifier, 28 | zen_Scope_t* enclosingScope) { 29 | zen_EnumerateSymbol_t* enumerateSymbol = zen_Memory_allocate(zen_EnumerateSymbol_t, 1); 30 | 31 | zen_Symbol_t* symbol = zen_Symbol_new(ZEN_SYMBOL_CATEGORY_ENUMERATE, identifier, enclosingScope, enumerateSymbol); 32 | 33 | enumerateSymbol->m_symbol = symbol; 34 | 35 | return enumerateSymbol; 36 | } 37 | 38 | void zen_EnumerateSymbol_delete(zen_EnumerateSymbol_t* symbol) { 39 | jtk_Assert_assertObject(symbol, "The specified symbol is null."); 40 | 41 | zen_Symbol_delete(symbol->m_symbol); 42 | jtk_Memory_deallocate(symbol); 43 | } 44 | 45 | zen_Symbol_t* zen_EnumerateSymbol_getSymbol(zen_EnumerateSymbol_t* symbol) { 46 | jtk_Assert_assertObject(symbol, "The specified symbol is null."); 47 | 48 | return symbol->m_symbol; 49 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/compiler/symbol-table/symbol/LabelSymbol.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Monday, March 05, 2018 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * LabelSymbol * 23 | *******************************************************************************/ 24 | 25 | zen_LabelSymbol_t* zen_LabelSymbol_new(zen_ASTNode_t* identifier, 26 | zen_Scope_t* enclosingScope) { 27 | zen_LabelSymbol_t* labelSymbol = zen_Memory_allocate(zen_LabelSymbol_t, 1); 28 | 29 | zen_Symbol_t* symbol = zen_Symbol_new(ZEN_SYMBOL_CATEGORY_LABEL, identifier, enclosingScope, labelSymbol); 30 | 31 | labelSymbol->m_symbol = symbol; 32 | labelSymbol->m_loopIdentifier = -1; 33 | 34 | return labelSymbol; 35 | } 36 | 37 | void zen_LabelSymbol_delete(zen_LabelSymbol_t* symbol) { 38 | jtk_Assert_assertObject(symbol, "The specified symbol is null."); 39 | 40 | zen_Symbol_delete(symbol->m_symbol); 41 | jtk_Memory_deallocate(symbol); 42 | } 43 | 44 | zen_Symbol_t* zen_LabelSymbol_getSymbol(zen_LabelSymbol_t* symbol) { 45 | jtk_Assert_assertObject(symbol, "The specified symbol is null."); 46 | 47 | return symbol->m_symbol; 48 | } 49 | -------------------------------------------------------------------------------- /source/com/onecube/zen/compiler/symbol-table/symbol/MemberConstantSymbol.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, February 24, 2018 18 | 19 | #include 20 | 21 | zen_MemberConstantSymbol_t* zen_MemberConstantSymbol_new(zen_ASTNode_t* identifier, 22 | jtk_ArrayList_t* modifiers) { 23 | } 24 | void zen_MemberConstantSymbol_delete(zen_MemberConstantSymbol_t* symbol) { 25 | } 26 | zen_Symbol_t* zen_MemberConstantSymbol_getSymbol(zen_MemberConstantSymbol_t* symbol) { 27 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/compiler/symbol-table/symbol/MemberVariableSymbol.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, February 24, 2018 18 | 19 | #include 20 | 21 | zen_MemberVariableSymbol_t* zen_AttributeVariableSymbol_new(zen_ASTNode_t* identifier, 22 | jtk_ArrayList_t* m_modifiers) { 23 | } 24 | void zen_AttributeVariableSymbol_delete(zen_MemberVariableSymbol_t* symbol) { 25 | } 26 | zen_Symbol_t* zen_MemberVariableSymbol_getSymbol(zen_MemberVariableSymbol_t* symbol) { 27 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/compiler/symbol-table/symbol/VariableSymbol.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Tuesday, February 27, 2018 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * VariableSymbol * 23 | *******************************************************************************/ 24 | 25 | zen_VariableSymbol_t* zen_VariableSymbol_new(zen_ASTNode_t* identifier, 26 | zen_Scope_t* enclosingScope) { 27 | zen_VariableSymbol_t* variableSymbol = zen_Memory_allocate(zen_VariableSymbol_t, 1); 28 | 29 | zen_Symbol_t* symbol = zen_Symbol_new(ZEN_SYMBOL_CATEGORY_VARIABLE, identifier, enclosingScope, variableSymbol); 30 | 31 | variableSymbol->m_symbol = symbol; 32 | variableSymbol->m_index = -1; 33 | 34 | return variableSymbol; 35 | } 36 | 37 | void zen_VariableSymbol_delete(zen_VariableSymbol_t* symbol) { 38 | jtk_Assert_assertObject(symbol, "The specified symbol is null."); 39 | 40 | zen_Symbol_delete(symbol->m_symbol); 41 | jtk_Memory_deallocate(symbol); 42 | } 43 | 44 | zen_Symbol_t* zen_VariableSymbol_getSymbol(zen_VariableSymbol_t* symbol) { 45 | jtk_Assert_assertObject(symbol, "The specified symbol is null."); 46 | 47 | return symbol->m_symbol; 48 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/ExceptionManager.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 06, 2019 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * ExceptionManager * 23 | *******************************************************************************/ 24 | 25 | bool zen_ExceptionManager_isClear(zen_ExceptionManager_t* exceptionManager) { 26 | return true; 27 | } 28 | 29 | void zen_ExceptionManager_raiseException(zen_ExceptionManager_t* exceptionManager, 30 | zen_Object_t* exception) { 31 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/VirtualMachineContext.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Friday, June 08, 2018 18 | 19 | #include 20 | #include 21 | 22 | /******************************************************************************* 23 | * VirtualMachineContext * 24 | *******************************************************************************/ 25 | 26 | /* Constructor */ 27 | 28 | zen_VirtualMachineContext_t* zen_VirtualMachineContext_new(zen_VirtualMachine_t* virtualMachine) { 29 | zen_VirtualMachineContext_t* context = zen_Memory_allocate(zen_VirtualMachineContext_t, 1); 30 | context->m_virtualMachine = virtualMachine; 31 | 32 | return context; 33 | } 34 | 35 | /* Destructor */ 36 | 37 | void zen_VirtualMachineContext_delete(zen_VirtualMachineContext_t* context) { 38 | jtk_Assert_assertObject(context, "The specified context is null."); 39 | 40 | jtk_Memory_deallocate(context); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/VirtualMachineGarbageCollectorListener.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | void zen_VirtualMachineGarbageCollectorListener_onAfterInitialization( 19 | zen_GarbageCollectorListener_t* listener, 20 | zen_GarbageCollector_t* collector) { 21 | 22 | zen_Class_t* class0 = zen_Context_findSystemClass(zen_core_OutOfMemoryError); 23 | if (!zen_Context_isClear(context)) { 24 | ... 25 | } 26 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/feb/Entity.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 06, 2019 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * Entity * 23 | *******************************************************************************/ 24 | 25 | void zen_Entity_delete(zen_Entity_t* entity) { 26 | } 27 | 28 | zen_ConstantPool_t* zen_Entity_getConstantPool(zen_Entity_t* entity) { 29 | return NULL; 30 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/feb/FieldEntity.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2019 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Monday, October 07, 2019 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * FieldEntity * 23 | *******************************************************************************/ 24 | 25 | // Constructor 26 | 27 | zen_FieldEntity_t* zen_FieldEntity_new(uint16_t flags, uint16_t nameIndex, 28 | uint16_t descriptorIndex) { 29 | zen_FieldEntity_t* entity = zen_Memory_allocate(zen_FieldEntity_t, 1); 30 | entity->m_flags = flags; 31 | entity->m_nameIndex = nameIndex; 32 | entity->m_descriptorIndex = descriptorIndex; 33 | entity->m_attributeTable.m_size = 0; 34 | entity->m_attributeTable.m_attributes = NULL; 35 | 36 | return entity; 37 | } 38 | 39 | // Destructor 40 | 41 | void zen_FieldEntity_delete(zen_FieldEntity_t* entity) { 42 | jtk_Assert_assertObject(entity, "The specified field entity is null."); 43 | 44 | zen_Memory_deallocate(entity); 45 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/feb/FunctionEntity.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2019 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Monday, October 07, 2019 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * FunctionEntity * 23 | *******************************************************************************/ 24 | 25 | // Constructor 26 | 27 | zen_FunctionEntity_t* zen_FunctionEntity_new(uint16_t flags, uint16_t nameIndex, 28 | uint16_t descriptorIndex, uint16_t tableIndex) { 29 | zen_FunctionEntity_t* functionEntity = zen_Memory_allocate(zen_FunctionEntity_t, 1); 30 | functionEntity->m_flags = flags; 31 | functionEntity->m_nameIndex = nameIndex; 32 | functionEntity->m_descriptorIndex = descriptorIndex; 33 | functionEntity->m_tableIndex = tableIndex; 34 | 35 | return functionEntity; 36 | } 37 | 38 | // Destructor 39 | 40 | void zen_FunctionEntity_delete(zen_FunctionEntity_t* functionEntity) { 41 | jtk_Assert_assertObject(functionEntity, "The specified function entity is null."); 42 | 43 | zen_Memory_deallocate(functionEntity); 44 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/feb/attribute/InstructionAttribute.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Tuesday, October 08, 2019 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * InstructionAttribute * 23 | *******************************************************************************/ 24 | 25 | // Constructor 26 | 27 | zen_InstructionAttribute_t* zen_InstructionAttribute_new(uint16_t nameIndex, 28 | uint32_t length, 29 | uint16_t maxStackSize, 30 | uint16_t localVariableCount, 31 | uint32_t instructionLength, 32 | uint8_t* instructions) { 33 | zen_InstructionAttribute_t* attribute = zen_Memory_allocate(zen_InstructionAttribute_t, 1); 34 | attribute->m_nameIndex = nameIndex; 35 | attribute->m_length = length; 36 | attribute->m_maxStackSize = maxStackSize; 37 | attribute->m_localVariableCount = localVariableCount; 38 | attribute->m_instructionLength = instructionLength; 39 | attribute->m_instructions = instructions; 40 | attribute->m_exceptionTable.m_size = 0; 41 | attribute->m_exceptionTable.m_exceptionHandlerSites = NULL; 42 | 43 | return attribute; 44 | } 45 | 46 | // Destructor 47 | 48 | void zen_InstructionAttribute_delete(zen_InstructionAttribute_t* attribute) { 49 | jtk_Assert_assertObject(attribute, "The specified instruction attribute is null."); 50 | 51 | zen_Memory_deallocate(attribute); 52 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/loader/BinaryEntityVerifier.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Monday, June 11, 2018 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * BinaryEntityVerifier * 23 | *******************************************************************************/ 24 | 25 | void zen_BinaryEntityVerifier_verifyMagicNumber(zen_BinaryEntityVerifier_t* verifier, 26 | uint32_t magicNumber) { 27 | jtk_Assert_assertObject(verifier, "The specified binary entity verifier is null."); 28 | 29 | if (magicNumber != ZEN_BINARY_ENTITY_FORMAT_MAGIC_NUMBER) { 30 | zen_Logger_e("Binary entity file magic number verified: incompatible"); 31 | // throw UnknownEntityMagicNumberException 32 | } 33 | } 34 | 35 | void zen_BinaryEntityVerifier_verifyVersion(zen_BinaryEntityVerifier_t* verifier, 36 | zen_FebVersion_t* fileVersion) { 37 | jtk_Assert_assertObject(verifier, "The specified binary entity verifier is null."); 38 | 39 | zen_FebVersion_t* machineVersion = zen_VirtualMachine_getFebVersion(verifier->m_machine); 40 | if (zen_FebVersionHelper_compare(fileVersion, machineVersion) >= 0) { 41 | zen_Logger_i("Binary entity file version verified: compatibile"); 42 | } 43 | else { 44 | zen_Logger_e("Binary entity file version verified: incompatible"); 45 | // throw UnsupportedEntityVersionException 46 | } 47 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/loader/EntityLoader.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 06, 2019 18 | 19 | 20 | /******************************************************************************* 21 | * EntityLoader * 22 | *******************************************************************************/ 23 | 24 | 25 | // Load Entity 26 | -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/object/NativeFunction.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Monday, July 15, 2019 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * NativeFunction * 23 | *******************************************************************************/ 24 | 25 | // Constructor 26 | 27 | zen_NativeFunction_t* zen_NativeFunction_new( 28 | zen_NativeFunction_InvokeFunction_t invoke) { 29 | zen_NativeFunction_t* nativeFunction = jtk_Memory_allocate(zen_NativeFunction_t, 1); 30 | nativeFunction->m_invoke = invoke; 31 | 32 | return nativeFunction; 33 | } 34 | 35 | // Destructor 36 | 37 | void zen_NativeFunction_delete(zen_NativeFunction_t* function) { 38 | jtk_Assert_assertObject(function, "The specified native function is null."); 39 | 40 | jtk_Memory_deallocate(function); 41 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/object/Object.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, April 06, 2019 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * Object * 23 | *******************************************************************************/ 24 | /* 25 | zen_Class_t* zen_Object_getClass(zen_Object_t* object) { 26 | return NULL; 27 | }*/ -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/object/ObjectArray.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2020 Samuel Rowe 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Saturday, June 09, 2018 18 | 19 | #include 20 | 21 | /******************************************************************************* 22 | * ObjectArray * 23 | *******************************************************************************/ 24 | 25 | zen_ObjectArray_t* zen_ObjectArray_new() { 26 | return NULL; 27 | } 28 | 29 | void zen_ObjectArray_setValue(zen_ObjectArray_t* array, int32_t index, 30 | zen_Object_t* value) { 31 | } -------------------------------------------------------------------------------- /source/com/onecube/zen/virtual-machine/processor/TODO.txt: -------------------------------------------------------------------------------- 1 | increment_i 2 | invoke_special 3 | invoke_virtual 4 | invoke_dynamic 5 | invoke_static 6 | invoke_fragment 7 | load_ab 8 | load_as 9 | load_ai 10 | load_al 11 | load_af 12 | load_ad 13 | load_aa 14 | load_instance_field 15 | load_static_field 16 | load_cpr 17 | load_array_size 18 | return_fragment 19 | rtti 20 | store_ab 21 | store_as 22 | store_ai 23 | store_al 24 | store_af 25 | store_ad 26 | store_aa 27 | store_static_field 28 | store_instance_field 29 | switch_table 30 | switch_search -------------------------------------------------------------------------------- /style: -------------------------------------------------------------------------------- 1 | --break-closing-braces 2 | --break-one-line-headers 3 | --add-braces 4 | --style=java 5 | --indent=spaces=4 6 | --indent-switches 7 | --indent-after-parens 8 | --indent-labels 9 | --indent-preproc-block 10 | --indent-preproc-define 11 | --pad-oper 12 | --pad-comma 13 | --pad-header 14 | --unpad-paren 15 | --align-reference=type 16 | --align-pointer=type 17 | --attach-return-type --------------------------------------------------------------------------------