internal AssignBinaryExpression(XzaarExpression left, XzaarExpression right) : base(left, right) { }
internal WhileExpression(XzaarExpression test, XzaarExpression body) : base(body, null, null, LoopTypes.While) { Test = test; }
internal ForEachExpression(XzaarExpression variable, XzaarExpression collection, XzaarExpression body) : base(body, null, null, LoopTypes.Foreach) { Variable = variable; Collection = collection; }
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)); }
internal MemberAccessChainExpression(XzaarExpression left, XzaarExpression right) { Left = left; Right = right; }
internal MemberExpression(XzaarExpression expression, XzaarExpression arrayIndex, XzaarType memberType) { MemberType = memberType; _expression = expression; this.ArrayIndex = arrayIndex; }
public static ForExpression For(XzaarExpression initiator, XzaarExpression test, XzaarExpression incrementor, XzaarExpression body) { return(new ForExpression(initiator, test, incrementor, body)); }
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 }
internal MethodBinaryExpression(ExpressionType nodeType, XzaarExpression left, XzaarExpression right, XzaarType type, XzaarMethodBase method) : base(nodeType, left, right, type) { _method = method; }
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 }
public static LabelExpression Label(LabelTarget target, XzaarExpression defaultValue) { return(new LabelExpression(target, defaultValue)); }
internal LabelExpression(LabelTarget label, XzaarExpression defaultValue) { this.target = label; this.defaultValue = defaultValue; }
public static SwitchCaseExpression DefaultCase(XzaarExpression body) { return(new SwitchCaseExpression(null, body)); }
public static Delegate CompileToDotNet(this XzaarExpression expression) { return(DotNetXzaarScriptCompiler.Compile(expression)); }
public static SwitchExpression Switch(XzaarExpression valueExpression, params XzaarExpression[] caseExpressions) { return(new SwitchExpression(valueExpression, caseExpressions)); }
public static XzaarAssembly Compile(this XzaarExpression expression, out IList <string> errors) { return(XSVMCompiler.Compile(expression, out errors)); }
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; }
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)); }
public static void RequiresCanWrite(XzaarExpression expression, string paramName) { }
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 }
internal SwitchCaseExpression(XzaarExpression matchExpression, XzaarExpression body) { this.matchExpression = matchExpression; this.body = body; }
public static WhileExpression While(XzaarExpression test, XzaarExpression body) { return(new WhileExpression(test, body)); }
public static SwitchCaseExpression Case(XzaarExpression test, XzaarExpression body) { return(new SwitchCaseExpression(test, body)); }
public static ForEachExpression ForEach(XzaarExpression variable, XzaarExpression collection, XzaarExpression body) { return(new ForEachExpression(variable, collection, body)); }
public TranspilerResult Transpile(XzaarExpression expression) { // TODO(Zerratar): Implement return(new TranspilerResult()); }