diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..479e2ea
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+bin
+obj
+*.sln.fire.cache
+*.sln.fire.user
+
diff --git a/Base.swift b/Base.swift
new file mode 100644
index 0000000..5e9e9cb
--- /dev/null
+++ b/Base.swift
@@ -0,0 +1,6 @@
+import Sugar
+import Sugar.Collections
+
+public class CGEntity {
+}
+
diff --git a/CodeGen4.elements b/CodeGen4.elements
new file mode 100644
index 0000000..72de8b8
--- /dev/null
+++ b/CodeGen4.elements
@@ -0,0 +1,53 @@
+
+
+
+ CodeGen4
+ EA4135EC-C7A2-454F-A53C-A9B6FE92DA94
+ StaticLibrary
+ CodeGen4
+ False
+ False
+ False
+ False
+ False
+ Release
+ OS X
+ True
+
+
+ false
+ .\bin\Debug
+ DEBUG;TRACE;
+ True
+ True
+ False
+ False
+ True
+
+
+ true
+ .\bin\Release
+ False
+ False
+ False
+ False
+ True
+
+
+
+
+
+
+ ..\..\Xcode\DerivedData\Fire-gudanmcdbkoejsaanfhrydpjbude\Build\Products\Debug\libSugar.fx
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CodeGen4.sln b/CodeGen4.sln
new file mode 100644
index 0000000..872545f
--- /dev/null
+++ b/CodeGen4.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# RemObjects Fire
+Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "CodeGen4", "CodeGen4.elements", "{EA4135EC-C7A2-454F-A53C-A9B6FE92DA94}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|AnyCPU = Debug|AnyCPU
+ Release|AnyCPU = Release|AnyCPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {EA4135EC-C7A2-454F-A53C-A9B6FE92DA94}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU
+ {EA4135EC-C7A2-454F-A53C-A9B6FE92DA94}.Debug|AnyCPU.Build.0 = Debug|AnyCPU
+ {EA4135EC-C7A2-454F-A53C-A9B6FE92DA94}.Release|AnyCPU.ActiveCfg = Release|AnyCPU
+ {EA4135EC-C7A2-454F-A53C-A9B6FE92DA94}.Release|AnyCPU.Build.0 = Release|AnyCPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
\ No newline at end of file
diff --git a/Expressions.swift b/Expressions.swift
new file mode 100644
index 0000000..d4a5c27
--- /dev/null
+++ b/Expressions.swift
@@ -0,0 +1,216 @@
+import Sugar
+import Sugar.Collections
+
+/* Expressions */
+
+public class CGExpression: CGStatement {
+}
+
+public class CGAssigedExpression: CGExpression {
+ var Value: CGExpression
+
+ init(_ value: CGExpression) {
+ Value = value
+ }
+}
+
+public class CGSizeOfExpression: CGExpression {
+ public var Expression: CGExpression
+
+ init(_ expression: CGExpression) {
+ Expression = expression
+ }
+}
+
+public class CGTypeOfExpression: CGExpression {
+ public var Expression: CGExpression
+
+ init(_ expression: CGExpression) {
+ Expression = expression
+ }
+}
+
+public class CGDefaultExpression: CGExpression {
+ public var `Type`: CGTypeReference
+
+ init(_ type: CGTypeReference) {
+ `Type` = type
+ }
+}
+
+public class CGSelectorExpression: CGExpression { /* Cocoa only */
+ var SelectorName: String
+
+ init(_ selectorNameame: String) {
+ SelectorName = selectorNameame;
+ }
+}
+
+public class CGTypeCastExpression: CGExpression {
+ public var Expression: CGExpression?
+ public var TargetType: CGTypeReference?
+ public var ThrowsException = false
+ public var GuaranteedSafe = false // in Silver, this uses "as"
+
+ init(_ expression: CGExpression, _ targetType: CGTypeReference) {
+ Expression = expression
+ TargetType = targetType
+ }
+}
+
+public class CGAwaitExpression: CGExpression {
+ //incomplete
+}
+
+public class CGAnonymousMethodExpression: CGExpression {
+ public var lambda = true
+ //incomplete
+}
+
+public class CGAnonymousClassOrStructExpression: CGExpression {
+ public var TypeDefinition: CGClassOrStructTypeDefinition
+
+ init(_ typeDefinition: CGClassOrStructTypeDefinition) {
+ TypeDefinition = typeDefinition
+ }
+}
+
+public class CGInheritedxpression: CGExpression {
+ public var Expression: CGExpression
+
+ init(_ expression: CGExpression) {
+ Expression = expression
+ }
+}
+
+/*
+public class CGIfThenElseExpression: CGExpression { //* Oxygene only */
+ //incomplete
+}
+
+public class CGCaseExpression: CGExpression { //* Oxygene only */
+ //incomplete
+}
+
+public class CGForToLoopExpression: CGExpression { //* Oxygene only */
+ //incomplete
+}
+
+public class CGForEachLoopExpression: CGExpression { //* Oxygene only */
+ //incomplete
+}
+*/
+
+public class CGBinaryOperatorExpression: CGExpression {
+ var LefthandValue: CGExpression
+ var RighthandValue: CGExpression
+ var Operator: CGOperatorKind? // for standard operators
+ var OperatorString: String? // for custom operators
+
+ init(_ lefthandValue: CGExpression, _ righthandValue: CGExpression, _ `operator`: CGOperatorKind) {
+ LefthandValue = lefthandValue
+ RighthandValue = righthandValue
+ Operator = `operator`;
+ }
+ init(_ lefthandValue: CGExpression, _ righthandValue: CGExpression, _ operatorString: String) {
+ LefthandValue = lefthandValue
+ RighthandValue = righthandValue
+ OperatorString = operatorString;
+ }
+}
+
+public enum CGOperatorKind {
+ case Addition
+ case Subtraction
+ case Multiplication
+ case Division
+ case LegacyPascalDivision // "div"
+ case Modulus
+ case Equals
+ case NotEquals
+ case LessThan
+ case LessThanOrEquals
+ case GreaterThan
+ case GreatThanOrEqual
+ case LogicalAnd
+ case LogicalOr
+ case LogicalXor
+ case Shl
+ case Shr
+ case BitwiseAnd
+ case BitwiseOr
+ case Bitwiseor
+ case Implies /* Oxygene only */
+ case Is
+ case IsNot
+ case In /* Oxygene only */
+ case NotIn
+ /*case Assign
+ case AssignAddition
+ case AssignSubtraction
+ case AssignMultiplication
+ case AssignDivision
+ case AssignModulus
+ case AssignBitwiseAnd
+ case AssignBitwiseOr
+ case AssignBitwiseXor
+ case AssignShl
+ case AssignShr*/
+}
+
+
+/* Literal Expressions */
+
+public class CGNamedIdenfifierExpression: CGExpression {
+ var Name: String
+
+ init(_ name: String) {
+ Name = name;
+ }
+}
+
+public class CGSelfExpression: CGExpression { // "self" or "this"
+}
+
+public class CGNilExpression: CGExpression { // "nil" or "null"
+}
+
+public class CGPropertyValueExpression: CGExpression { /* "value" or "newValue" in C#/Swift */
+}
+
+public class CGLiteralExpression: CGExpression {
+}
+
+public class CGStringLiteralExpression: CGLiteralExpression {
+ var value: String = ""
+}
+
+public class CGCharacterLiteralExpression: CGLiteralExpression {
+ var value: Char = "\0"
+}
+
+public class CGIntegerLiteralExpression: CGLiteralExpression {
+ var Value: Int64 = 0
+}
+
+public class CGFloatLiteralExpression: CGLiteralExpression {
+ var Value: Double = 0
+}
+
+public class CGFBooleanLiteralExpression: CGLiteralExpression {
+ var Value: Boolean = false
+}
+
+public enum CGArrayLiteralExpressionKind {
+ case Static
+ case Dynamic
+ case HighLevel /* Swift only */
+}
+
+public class CGArrayLiteralExpression: CGLiteralExpression {
+ public var ArrayKind: CGArrayLiteralExpressionKind = .Dynamic
+ //incomplete
+}
+
+public class CGDictionaryLiteralExpression: CGLiteralExpression { /* Swift only */
+}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..44f8be0
--- /dev/null
+++ b/README.md
@@ -0,0 +1,18 @@
+# CodeGen4
+
+An open source cross-platform, language agnostic code generation engine that will drive the future code generation in
+RemObjects products such as RemObjects SDK, Data Abstract and Elements
+
+## Platform support:
+
+* .NET, Java and Cocoa, va the Elements compiler
+
+## Language Support
+
+* Oxygene, Hydrogene, Silver
+* Objective-C
+* Java
+* Visual C#, Visual Basic
+* Delphi, C++ Builder
+
+Implemented with [RemObjects Silver](http://elementscompiler.com/silver).
\ No newline at end of file
diff --git a/Statements.swift b/Statements.swift
new file mode 100644
index 0000000..6395de1
--- /dev/null
+++ b/Statements.swift
@@ -0,0 +1,158 @@
+import Sugar
+import Sugar.Collections
+
+
+/* Statements */
+
+public class CGStatement: CGEntity {
+}
+
+public class CGBlockStatement : CGStatement { // Abstract base for anhy block statement
+ public var Statements = List()
+}
+
+public class CGNestingStatement : CGStatement { // Abstract base for any statement that contains a single other statement
+ public var NestedStatement: CGStatement?
+
+ init(_ nestedStatement: CGStatement) {
+ NestedStatement = nestedStatement
+ }
+}
+
+public class CGBeginEndStatement : CGBlockStatement { //"begin/end" or "{/}"
+}
+
+public class CGIfElseStatement: CGStatement {
+ public var Condition: CGExpression
+ public var IfStatement: CGStatement
+ public var ElseStatement: CGStatement?
+
+ init(_ condition: CGExpression, _ ifStatement: CGStatement, _ elseStatement: CGStatement?) {
+ Condition = condition
+ IfStatement = ifStatement
+ ElseStatement = elseStatement
+ }
+
+}
+
+public class CGForToLoopStatement: CGNestingStatement {
+ //incomplete
+}
+
+public class CGForEachLoopStatement: CGNestingStatement {
+ //incomplete
+}
+
+public class CGWhileDoStatement: CGNestingStatement {
+ //incomplete
+}
+
+public class CGDoWhileStatement: CGBlockStatement { // also "repeat/until"
+ //incomplete
+}
+
+public class CGInfiniteLoopStatement: CGNestingStatement {
+ //incomplete
+}
+
+public class CGSwitchStatement: CGStatement {
+ //incomplete
+}
+
+public class CGLockingStatement: CGNestingStatement {
+ var Expression: CGExpression
+
+ init(_ expression: CGExpression, _ nestedStatement: CGStatement) {
+ init(nestedStatement)
+ Expression = expression
+ }
+}
+
+public class CGUsingStatement: CGNestingStatement {
+ var Expression: CGExpression
+
+ init(_ expression: CGExpression, _ nestedStatement: CGStatement) {
+ init(nestedStatement)
+ Expression = expression
+ }
+}
+
+public class CGAutoReleasePoolStatement: CGNestingStatement {}
+
+public class CGTryFinalyCatchStatement: CGBlockStatement {
+ public var FinallyStatements = List()
+ public var CatchBlockStatements = List()
+}
+
+public class CGCatchBlockStatement: CGBlockStatement {
+ public var Name: String
+ public var `Type`: CGTypeReference
+ public var Filter: CGExpression?
+
+ init(_ name: String, _ type: CGTypeReference) {
+ Name = name
+ `Type` = type
+ }
+}
+
+/* Simple Statements */
+
+public class CGReturnStatement: CGStatement {
+ var Value: CGExpression?
+
+ init(_ value: CGExpression?) {
+ Value = value
+ }
+}
+
+public class CGThrowStatement: CGStatement {
+ var Exception: CGExpression?
+
+ init(_ exception: CGExpression?) {
+ Exception = exception
+ }
+}
+
+public class CGBreakStatement: CGStatement {}
+public class CGContinueStatement: CGStatement {}
+
+public class CGEmptyStatement: CGStatement {}
+
+/* Operator statements */
+
+public class CGVariableDeclarationStatement: CGStatement {
+ public var Name: String
+ public var `Type`: CGTypeReference?
+ public var Initializer: CGExpression?
+ public var Constant = false
+
+ init(_ name: String, _ type: CGTypeReference?, initializer: CGExpression?) {
+ Name = name
+ `Type` = type
+ Initializer = initializer
+ }
+}
+
+public class CGAssignmentStatement: CGStatement {
+ var Target: CGExpression
+ var Value: CGExpression
+
+ init(_ target: CGExpression, _ value: CGExpression) {
+ Target = target
+ Value = value
+ }
+}
+
+public class CGConstructorCallStatement: CGStatement {
+ public var `Type`: CGTypeReference
+
+ init(_ type: CGTypeReference) {
+ `Type` = type
+ }
+ //incomplete
+}
+
+public class CGMethodOrFunctionCallStatement: CGStatement {
+ //incomplete
+}
+
diff --git a/TypeDefinitions.swift b/TypeDefinitions.swift
new file mode 100644
index 0000000..485d6b4
--- /dev/null
+++ b/TypeDefinitions.swift
@@ -0,0 +1,142 @@
+import Sugar
+import Sugar.Collections
+
+/* Types */
+
+public enum TypeVisibilityKind {
+ case Private
+ case Assmebly
+ case Public
+}
+
+public class CGTypeDefinition: CGEntity {
+ public var GenericParameters = List()
+ public var Name: String
+
+ init(_ name: String) {
+ Name = name;
+ }
+}
+
+public class CGTypeAliasDefinition : CGTypeDefinition {
+ public var ActualType: CGTypeReference
+
+ init (_ actualType: CGTypeReference) {
+ ActualType = actualType
+ }
+}
+
+public class CGBlockTypeDefinition : CGTypeDefinition {
+ public var Parameters = List()
+ public var ReturnValue: CGParameterDefinition?
+}
+
+public class CGEnumTypeDefinition : CGTypeDefinition {
+ public var Values = Dictionary()
+}
+
+public class CGClassOrStructTypeDefinition : CGTypeDefinition {
+ public var Static = false
+ public var Visbility: TypeVisibilityKind = .Private
+}
+
+public class CGClassTypeDefinition : CGClassOrStructTypeDefinition {
+}
+
+public class CGStrucTypeDefinition : CGClassOrStructTypeDefinition {
+}
+
+/* Type members */
+
+public enum MemberVisibilityKind {
+ case Private
+ case Unit
+ case UnitOrProtected
+ case UnitAndProtected
+ case Assmebly
+ case AssmeblyOrProtected
+ case AssmeblyAndProtected
+ case Protcteed
+ case Public
+}
+
+public enum MemberVirtualityKind {
+ case None
+ case Virtual
+ case Abstract
+ case Override
+ case Final
+ case Reintroduce
+}
+
+public class CGMemberDefinition: CGEntity {
+ public var Name: String
+ public var Visbility: MemberVisibilityKind = .Private
+ public var Static = false
+ public var Virtuality: MemberVirtualityKind = .None
+ public var Locked = false /* Oxygene only */
+ public var LockedOn: CGExpression? /* Oxygene only */
+
+ init(_ name: String) {
+ Name = name;
+ }
+}
+
+public class CGMethodDefinition: CGMemberDefinition {
+ public var Parameters = List()
+ public var ReturnValue: CGParameterDefinition?
+}
+
+public class CGOperatorDefinition: CGMemberDefinition {
+ public var Parameters = List()
+ public var ReturnValue: CGParameterDefinition?
+}
+
+public class CGConstructorDefinition: CGMethodDefinition {
+}
+
+public class CGFieldDefinition: CGMemberDefinition {
+ public var `Type`: CGTypeReference?
+ public var Initializer: CGExpression?
+}
+
+public class CGPropertyDefinition: CGMemberDefinition {
+}
+
+public class CGEventDefinition: CGMemberDefinition {
+}
+
+/* Parameters */
+
+public enum ParameterModifierKind {
+ case In
+ case Out
+ case Var
+ case Const
+ case Array
+ case Reintroduce
+}
+
+public class CGParameterDefinition: CGMemberDefinition {
+ public var Modifier: ParameterModifierKind = .In
+ public var `Type`: CGTypeReference
+ public var DefaultValue: CGExpression?
+
+ init (_ name: String, _ type: CGTypeReference) {
+ super.init(name)
+ `Type` = type
+ }
+}
+
+public class CGGenericParameterDefinition: CGEntity {
+ public var Constraints = List()
+ var Name: String
+
+ init(_ name: String) {
+ Name = name;
+ }
+}
+
+public class CGGenericConstraintDefintion: CGEntity {
+}
+
diff --git a/TypeReferences.swift b/TypeReferences.swift
new file mode 100644
index 0000000..34f9b37
--- /dev/null
+++ b/TypeReferences.swift
@@ -0,0 +1,65 @@
+import Sugar
+import Sugar.Collections
+
+/* Type References */
+
+public class CGTypeReference : CGExpression {
+}
+
+public enum CGTypeNullabilityKind {
+ case Unknown
+ case Default
+ case Nullable
+ case NotNullable
+}
+
+public class CGNamedTypeReference : CGTypeReference {
+ public var Name: String
+ public var Nullability: CGTypeNullabilityKind = .Default
+ public var DefaultNullabiltyName: CGTypeNullabilityKind = .Unknown
+
+ init (_ name: String) {
+ Name = name
+ }
+}
+
+/* Arrays */
+
+public class CGArrayTypeReference : CGTypeReference {
+ public var `Type`: CGTypeReference
+ public var Bounds = List()
+
+ init(_ type: CGTypeReference, _ bounds: List? = default) {
+ `Type` = type;
+ if let bounds = bounds {
+ Bounds = bounds
+ } else {
+ Bounds = List()
+ }
+
+ }
+}
+
+public class CGArrayTypeReferenceBounds {
+ public var Start: Int32 = 0
+ public var End: Int32?
+
+ init() {
+ }
+ init(_ start: Int32, end: Int32) {
+ Start = start
+ End = end
+ }
+}
+
+/* Dictionaries (Swoft nly for now */
+
+public class CGDictionaryTypeReference : CGTypeReference {
+ public var KeyType: CGTypeReference
+ public var ValueType: CGTypeReference
+
+ init(_ keyType: CGTypeReference, _ valueType: CGTypeReference) {
+ KeyType = keyType;
+ ValueType = valueType;
+ }
+}