internal AssignBinaryExpression(XzaarExpression left, XzaarExpression right)
     : base(left, right)
 {
 }
Esempio n. 2
0
 internal WhileExpression(XzaarExpression test, XzaarExpression body) : base(body, null, null, LoopTypes.While)
 {
     Test = test;
 }
Esempio n. 3
0
 internal ForEachExpression(XzaarExpression variable, XzaarExpression collection, XzaarExpression body) : base(body, null, null, LoopTypes.Foreach)
 {
     Variable   = variable;
     Collection = collection;
 }
Esempio n. 4
0
 public static MemberExpression MemberAccess(XzaarExpression expression, XzaarExpression arrayIndex, XzaarType memberType)
 {
     return(new MemberExpression(expression, arrayIndex, memberType));
 }
        public string Visit(XzaarExpression expression)
        {
            dynamic e = expression;

            return(Visit(e));
        }
Esempio n. 6
0
 internal MemberAccessChainExpression(XzaarExpression left, XzaarExpression right)
 {
     Left  = left;
     Right = right;
 }
Esempio n. 7
0
 internal MemberExpression(XzaarExpression expression, XzaarExpression arrayIndex, XzaarType memberType)
 {
     MemberType      = memberType;
     _expression     = expression;
     this.ArrayIndex = arrayIndex;
 }
Esempio n. 8
0
 public static ForExpression For(XzaarExpression initiator, XzaarExpression test, XzaarExpression incrementor, XzaarExpression body)
 {
     return(new ForExpression(initiator, test, incrementor, body));
 }
Esempio n. 9
0
        public object Visit(XzaarExpression expression)
        {
            // TODO(Zerratar): Dependecy Inject a stack guard validation object to do take care of this for us
            if (ctx.StackRecursionCount > 10)
            {
                throw new CompilerException("PANIC!! Stackoverflow! " + expression.GetType() + " [" + expression.NodeType + "] not implemented");
            }

            if (ctx.LastVisited == expression)
            {
                ctx.StackRecursionCount++;
            }
            else
            {
                ctx.StackRecursionCount = 0;
            }

            ctx.LastVisited = expression;

            if (expression.NodeType == ExpressionType.Block)
            {
                var block = expression as BlockExpression;
                if (block != null)
                {
                    foreach (var item in block.Expressions)
                    {
                        Visit(item);
                    }
                }
                return(null);
            }

            // NOTE: Blueh! If only we could have used dynamics here, that would have saved us so many darn lines :P But since we are compiling for 3.5, thats not possible
            //

//#if UNITY
            if (expression is LambdaExpression lambda)
            {
                return(Visit(lambda));
            }
            if (expression is UnaryExpression unaryExpression)
            {
                return(Visit(unaryExpression));
            }
            if (expression is IfElseExpression elseExpression)
            {
                return(Visit(elseExpression));
            }
            if (expression is ConditionalExpression conditionalExpression)
            {
                return(Visit(conditionalExpression));
            }
            if (expression is GotoExpression gotoExpression)
            {
                return(Visit(gotoExpression));
            }
            if (expression is MemberExpression memberExpression)
            {
                return(Visit(memberExpression));
            }
            if (expression is BinaryExpression binaryExpression)
            {
                return(Visit(binaryExpression));
            }
            if (expression is MemberAccessChainExpression chainExpression)
            {
                return(Visit(chainExpression));
            }
            if (expression is ForExpression forExpression)
            {
                return(Visit(forExpression));
            }
            if (expression is ForEachExpression eachExpression)
            {
                return(Visit(eachExpression));
            }
            if (expression is SwitchCaseExpression caseExpression)
            {
                return(Visit(caseExpression));
            }
            if (expression is DoWhileExpression whileExpression)
            {
                return(Visit(whileExpression));
            }
            if (expression is LoopExpression loopExpression)
            {
                return(Visit(loopExpression));
            }
            if (expression is SwitchExpression switchExpression)
            {
                return(Visit(switchExpression));
            }
            if (expression is CreateStructExpression structExpression)
            {
                return(Visit(structExpression));
            }
            if (expression is ConstantExpression constantExpression)
            {
                return(Visit(constantExpression));
            }
            if (expression is FunctionCallExpression callExpression)
            {
                return(Visit(callExpression));
            }
            if (expression is VariableDefinitionExpression definitionExpression)
            {
                return(Visit(definitionExpression));
            }
            if (expression is FieldExpression fieldExpression)
            {
                return(Visit(fieldExpression));
            }
            if (expression is LabelExpression labelExpression)
            {
                return(Visit(labelExpression));
            }
            if (expression is ParameterExpression parameterExpression)
            {
                return(Visit(parameterExpression));
            }
            if (expression is FunctionExpression functionExpression)
            {
                return(Visit(functionExpression));
            }
            if (expression is StructExpression expression1)
            {
                return(Visit(expression1));
            }
            return(Visit(expression));
//#else
//            return Visit((dynamic)expression);
//#endif
        }
Esempio n. 10
0
 internal MethodBinaryExpression(ExpressionType nodeType, XzaarExpression left, XzaarExpression right, XzaarType type, XzaarMethodBase method)
     : base(nodeType, left, right, type)
 {
     _method = method;
 }
Esempio n. 11
0
 internal ForExpression(XzaarExpression initiator, XzaarExpression test, XzaarExpression incrementor, XzaarExpression body) : base(body, null, null, LoopTypes.For)
 {
     Incrementor = incrementor;
     Test        = test;
     Initiator   = initiator;
 }
        // this will help us to define all available functions in the current type we create
        public object Visit(XzaarExpression expression)
        {
            AssertPossibleStackOverflow(expression);

            if (expression.NodeType == ExpressionType.Block)
            {
                var block = expression as BlockExpression;
                if (block != null)
                {
                    foreach (var item in block.Expressions)
                    {
                        Visit(item);
                    }
                }
                return(null);
            }

            // NOTE: Blueh! If only we could have used dynamics here, that would have saved us so many darn lines :P But since we are compiling for 3.5, thats not possible
            //
            if (expression is ErrorExpression errorExpression)
            {
                throw new Exception(errorExpression.ErrorMessage);
            }

//#if UNITY
            if (expression is UnaryExpression)
            {
                return(Visit(expression as UnaryExpression));
            }
            if (expression is IfElseExpression)
            {
                return(Visit(expression as IfElseExpression));
            }
            if (expression is ConditionalExpression)
            {
                return(Visit(expression as ConditionalExpression));
            }
            if (expression is GotoExpression)
            {
                return(Visit(expression as GotoExpression));
            }
            if (expression is MemberExpression)
            {
                return(Visit(expression as MemberExpression));
            }
            if (expression is BinaryExpression)
            {
                return(Visit(expression as BinaryExpression));
            }
            if (expression is MemberAccessChainExpression)
            {
                return(Visit(expression as MemberAccessChainExpression));
            }
            if (expression is ForExpression)
            {
                return(Visit(expression as ForExpression));
            }
            if (expression is ForEachExpression)
            {
                return(Visit(expression as ForEachExpression));
            }
            if (expression is SwitchCaseExpression)
            {
                return(Visit(expression as SwitchCaseExpression));
            }
            if (expression is DoWhileExpression)
            {
                return(Visit(expression as DoWhileExpression));
            }
            if (expression is LoopExpression)
            {
                return(Visit(expression as LoopExpression));
            }
            if (expression is SwitchExpression)
            {
                return(Visit(expression as SwitchExpression));
            }
            if (expression is CreateStructExpression)
            {
                return(Visit(expression as CreateStructExpression));
            }
            if (expression is ConstantExpression)
            {
                return(Visit(expression as ConstantExpression));
            }
            if (expression is FunctionCallExpression)
            {
                return(Visit(expression as FunctionCallExpression));
            }
            if (expression is VariableDefinitionExpression)
            {
                return(Visit(expression as VariableDefinitionExpression));
            }
            if (expression is FieldExpression)
            {
                return(Visit(expression as FieldExpression));
            }
            if (expression is LabelExpression)
            {
                return(Visit(expression as LabelExpression));
            }
            if (expression is ParameterExpression)
            {
                return(Visit(expression as ParameterExpression));
            }
            if (expression is FunctionExpression)
            {
                return(Visit(expression as FunctionExpression));
            }
            if (expression is StructExpression)
            {
                return(Visit(expression as StructExpression));
            }
            return(Visit(expression));
//#else
//            return Visit((dynamic)expression);
//#endif
        }
Esempio n. 13
0
 public static LabelExpression Label(LabelTarget target, XzaarExpression defaultValue)
 {
     return(new LabelExpression(target, defaultValue));
 }
Esempio n. 14
0
 internal LabelExpression(LabelTarget label, XzaarExpression defaultValue)
 {
     this.target       = label;
     this.defaultValue = defaultValue;
 }
Esempio n. 15
0
 public static SwitchCaseExpression DefaultCase(XzaarExpression body)
 {
     return(new SwitchCaseExpression(null, body));
 }
Esempio n. 16
0
 public static Delegate CompileToDotNet(this XzaarExpression expression)
 {
     return(DotNetXzaarScriptCompiler.Compile(expression));
 }
Esempio n. 17
0
 public static SwitchExpression Switch(XzaarExpression valueExpression, params XzaarExpression[] caseExpressions)
 {
     return(new SwitchExpression(valueExpression, caseExpressions));
 }
Esempio n. 18
0
 public static XzaarAssembly Compile(this XzaarExpression expression, out IList <string> errors)
 {
     return(XSVMCompiler.Compile(expression, out errors));
 }
Esempio n. 19
0
 public static MemberAccessChainExpression AccessChain(XzaarExpression left, XzaarExpression right)
 {
     return(new MemberAccessChainExpression(left, right));
 }
 internal VariableDefinitionExpression(XzaarType type, string name, XzaarExpression assignmentExpression)
     : base(name)
 {
     this.type            = type;
     AssignmentExpression = assignmentExpression;
 }
Esempio n. 21
0
 public static MemberExpression MemberAccess(XzaarExpression expression, XzaarType memberType)
 {
     return(new MemberExpression(expression, null, memberType));
 }
 public static VariableDefinitionExpression DefineVariable(XzaarType type, string name, XzaarExpression assignmentExpression)
 {
     return(new VariableDefinitionExpression(type, name, assignmentExpression));
 }
Esempio n. 23
0
 public static void RequiresCanWrite(XzaarExpression expression, string paramName)
 {
 }
Esempio n. 24
0
 internal SwitchExpression(XzaarExpression value, XzaarExpression[] caseExpressions)
 {
     this.value           = value;
     this.caseExpressions = caseExpressions;
 }
        public string Visit(XzaarExpression expression)
        {
//#if UNITY
            if (expression is BinaryExpression binaryExpression)
            {
                return(Visit(binaryExpression));
            }
            if (expression is ConditionalExpression conditionalExpression)
            {
                return(Visit(conditionalExpression));
            }
            if (expression is IfElseExpression elseExpression)
            {
                return(Visit(elseExpression));
            }
            if (expression is LogicalNotExpression notExpression)
            {
                return(Visit(notExpression));
            }

            if (expression is MemberExpression memberExpression)
            {
                return(Visit(memberExpression));
            }
            if (expression is MemberAccessChainExpression chainExpression)
            {
                return(Visit(chainExpression));
            }
            if (expression is GotoExpression gotoExpression)
            {
                return(Visit(gotoExpression));
            }
            if (expression is SwitchExpression switchExpression)
            {
                return(Visit(switchExpression));
            }
            if (expression is SwitchCaseExpression caseExpression)
            {
                return(Visit(caseExpression));
            }
            if (expression is UnaryExpression unaryExpression)
            {
                return(Visit(unaryExpression));
            }
            if (expression is BlockExpression blockExpression)
            {
                return(Visit(blockExpression));
            }

            if (expression is ForExpression forExpression)
            {
                return(Visit(forExpression));
            }
            if (expression is ForEachExpression eachExpression)
            {
                return(Visit(eachExpression));
            }
            if (expression is DoWhileExpression whileExpression)
            {
                return(Visit(whileExpression));
            }
            if (expression is WhileExpression expression1)
            {
                return(Visit(expression1));
            }
            if (expression is LoopExpression loopExpression)
            {
                return(Visit(loopExpression));
            }
            if (expression is DefaultExpression defaultExpression)
            {
                return(Visit(defaultExpression));
            }

            if (expression is LambdaExpression lambda)
            {
                return(Visit(lambda));
            }
            if (expression is FunctionCallExpression callExpression)
            {
                return(Visit(callExpression));
            }
            if (expression is FunctionExpression functionExpression)
            {
                return(Visit(functionExpression));
            }

            if (expression is ConstantExpression constantExpression)
            {
                return(Visit(constantExpression));
            }
            if (expression is NegateExpression negateExpression)
            {
                return(Visit(negateExpression));
            }
            if (expression is VariableDefinitionExpression definitionExpression)
            {
                return(Visit(definitionExpression));
            }
            if (expression is FieldExpression fieldExpression)
            {
                return(Visit(fieldExpression));
            }
            if (expression is LabelExpression labelExpression)
            {
                return(Visit(labelExpression));
            }
            if (expression is ParameterExpression parameterExpression)
            {
                return(Visit(parameterExpression));
            }

            if (expression is StructExpression structExpression1)
            {
                return(Visit(structExpression1));
            }
            if (expression is CreateStructExpression structExpression)
            {
                return(Visit(structExpression));
            }

            if (expression is ErrorExpression error)
            {
            }


            return(Visit(expression));
//#else
//            return Visit((dynamic)expression);
//#endif
        }
Esempio n. 26
0
 internal SwitchCaseExpression(XzaarExpression matchExpression, XzaarExpression body)
 {
     this.matchExpression = matchExpression;
     this.body            = body;
 }
Esempio n. 27
0
 public static WhileExpression While(XzaarExpression test, XzaarExpression body)
 {
     return(new WhileExpression(test, body));
 }
Esempio n. 28
0
 public static SwitchCaseExpression Case(XzaarExpression test, XzaarExpression body)
 {
     return(new SwitchCaseExpression(test, body));
 }
Esempio n. 29
0
 public static ForEachExpression ForEach(XzaarExpression variable, XzaarExpression collection, XzaarExpression body)
 {
     return(new ForEachExpression(variable, collection, body));
 }
Esempio n. 30
0
 public TranspilerResult Transpile(XzaarExpression expression)
 {
     // TODO(Zerratar): Implement
     return(new TranspilerResult());
 }