public EventActionsLoader(string namespaceName, ScriptEngine engine) : base(engine) { cNamespace.Name = namespaceName; exprInter = engine.GetPlugin <ExpressionInterpreter> (); filters = engine.GetPlugin <FiltersPlugin> (); functionOperators = engine.GetPlugin <EventFunctionOperators> (); }
public ContextFunctionCallInterpreter(MethodInfo method, ScriptEngine engine) { ops = engine.GetPlugin <EventFunctionOperators> (); switches = engine.GetPlugin <ContextSwitchesPlugin> (); argsDef = method.GetParameters(); if (argsDef.Length > 0) { addContextInter = switches.GetInterByType(argsDef [argsDef.Length - 1].ParameterType); } Engine = engine; returnType = method.ReturnType; if (returnType != typeof(void) && returnType != typeof(string) && (returnType.IsClass || (returnType.IsValueType && !returnType.IsEnum && returnType != typeof(bool) && returnType != typeof(float) && returnType != typeof(int))) && !(returnType.IsGenericType && returnType.GetGenericTypeDefinition() == typeof(List <>))) { if (ContextPropertySwitchInterpreter.allPropSwitches.ContainsKey(new ContextPropertySwitchInterpreter.PropKey(returnType, ""))) { ctxInter = ContextPropertySwitchInterpreter.allPropSwitches[new ContextPropertySwitchInterpreter.PropKey(returnType, "")]; } else { ctxInter = new ContextPropertySwitchInterpreter("", returnType, engine); } } funcName = method.Name; }
public LocalisationTagsLoader(string namespaceName, ScriptEngine engine) : base(engine) { loader = UnityEngine.Object.FindObjectOfType <ScriptsLoader>(); cNamespace.Name = namespaceName; exprInter = engine.GetPlugin <ExpressionInterpreter> (); filters = engine.GetPlugin <FiltersPlugin> (); functionOperators = engine.GetPlugin <EventFunctionOperators> (); }
public RelationsMetricsLoader(string namespaceName, string typeName, Type targetFunc, ScriptEngine engine) : base(engine) { cNamespace.Name = namespaceName; exprInter = engine.GetPlugin <ExpressionInterpreter>(); functionOperators = engine.GetPlugin <EventFunctionOperators>(); codeType = new CodeTypeDeclaration(); codeType.Name = typeName; cNamespace.Types.Add(codeType); delegateMethod = targetFunc.GetMethod("Invoke"); }
public override void Interpret(Operator op, FunctionBlock block) { if (exprInterpreter == null) { exprInterpreter = Engine.GetPlugin <ExpressionInterpreter> (); ops = Engine.GetPlugin <EventFunctionOperators> (); } if (op.Args.Count == 1) { //Shouldn't declare variable IfStatement ifStatement = new IfStatement(); ifStatement.CheckExpression = exprInterpreter.InterpretExpression(op.Args [0], block).ExprString; ifStatement.TrueBlock = new FunctionBlock(block, block.Method, block.Type); block.Statements.Add(ifStatement); foreach (var entry in (op.Context as Context).Entries) { var subOp = entry as Operator; if (subOp == null) { continue; } var subInter = ops.GetInterpreter(subOp, ifStatement.TrueBlock); if (subInter == null) { Debug.LogFormat("Can't interpret operator {0} in {1}", subOp.Identifier, block.Method.Name); continue; } subInter.Interpret(subOp, ifStatement.TrueBlock); } } else if (op.Args.Count == 2) { DeclareVariableStatement declareVar = new DeclareVariableStatement(); if (op.Args [1].Operands [0] is IdWrapper) { var id = ((IdWrapper)op.Args [1].Operands [0]).ToString(); declareVar.Name = id; declareVar.Type = typeof(bool); declareVar.InitExpression = "false"; } else { Debug.Log("Wrong definition of an if operator with a variable - variable is not an identifier"); return; } block.Statements.Add(declareVar); //Should declare variable } }
public override void Init() { ops = Engine.GetPlugin <EventFunctionOperators> (); var components = Engine.FindTypesCastableTo <MonoBehaviour> (); MaxProgress = components.Count; foreach (var cmp in components) { CurProgress++; ContextSwitchInterpreter inter = new ContextSwitchInterpreter(cmp, Engine); //if (ScriptEngine.AnalyzeDebug) // Debug.Log ("context " + inter.Engine); ops.AddInterpreter(NameTranslator.ScriptNameFromCSharp(cmp.Name), inter); } CurProgress = MaxProgress; var goInter = new ContextSwitchInterpreter(typeof(GameObject), Engine); }
public override void Interpret(Operator op, FunctionBlock block) { if (exprInterpreter == null) { exprInterpreter = Engine.GetPlugin <ExpressionInterpreter> (); ops = Engine.GetPlugin <EventFunctionOperators> (); } if (op.Args.Count == 1) { ForStatement stmt = new ForStatement(); stmt.RepeatBlock = new FunctionBlock(block, block.Method, block.Type); stmt.InsideExpr = String.Format("int i = 0; i < {0}; i++", exprInterpreter.InterpretExpression(op.Args [0], block).ExprString); block.Statements.Add(stmt); foreach (var entry in (op.Context as Context).Entries) { var subOp = entry as Operator; if (subOp == null) { continue; } var subInter = ops.GetInterpreter(subOp, stmt.RepeatBlock); if (subInter == null) { Debug.LogFormat("Can't interpret operator {0} in {1}", subOp.Identifier, block.Method.Name); continue; } //Debug.Log (subOp.Identifier); subInter.Interpret(subOp, stmt.RepeatBlock); } } else { Debug.Log("Error in repeat definion - more or less than one argument"); } }
public override void Interpret(Operator op, FunctionBlock block) { base.Interpret(op, block); if (interpret) { if (ScriptEngine.AnalyzeDebug) { Debug.LogFormat("Property {0} was interpreted by ContextPropertyInterpreter {1} already", op, propName); } return; } if (!(op.Context is Context)) { if (ScriptEngine.AnalyzeDebug) { Debug.LogFormat("Property context switch {0} has no context", op); } return; } if (ops == null) { ops = Engine.GetPlugin <EventFunctionOperators> (); } var varName = op.Identifier as string; FunctionBlock contextBlock = new FunctionBlock(block, block.Method, block.Type); block.Statements.Add(contextBlock); DeclareVariableStatement declareVar = new DeclareVariableStatement(); declareVar.Type = propType; declareVar.Name = "subContext" + DeclareVariableStatement.VariableId++; declareVar.IsContext = true; DeclareVariableStatement contextVar = block.FindStatement <DeclareVariableStatement> (v => v.Name == varName); if (contextVar == null) { var sCtx = block.FindStatement <ContextStatement> (v => v.InterpretInContext(op, block) != null && v.ContextVar.IsContext); contextVar = sCtx != null ? sCtx.ContextVar : null; } if (contextVar == null) { declareVar.InitExpression = String.Format("root.{0}", propName); } else { declareVar.InitExpression = String.Format("{1}.{0}", propName, contextVar.Name); } contextBlock.Statements.Add(declareVar); contextBlock.Statements.Add(new ContextStatement() { ContextVar = declareVar, InterpretInContext = InterpretInContext }); IfStatement isNotNull = new IfStatement(); isNotNull.CheckExpression = String.Format("{0} != null", declareVar.Name); isNotNull.TrueBlock = new FunctionBlock(contextBlock); contextBlock.Statements.Add(isNotNull); contextBlock = isNotNull.TrueBlock; foreach (var entry in (op.Context as Context).Entries) { //Debug.LogFormat("Interpreting {0} as part of {1} context", (entry as Operator).Identifier, op.Identifier); var subOp = entry as Operator; if (subOp == null) { continue; } FunctionOperatorInterpreter opInter = null; if ((opInter = ops.GetInterpreter(subOp, contextBlock)) == null) { if (!contextSwitches.TryGetValue(subOp.Identifier as string, out opInter)) { if (!functions.TryGetValue(subOp.Identifier as string, out opInter)) { if (!properties.TryGetValue(subOp.Identifier as string, out opInter)) { //Debug.LogFormat ("Can't interpret context operator {1} in {0}", block.Method.Name, subOp.Identifier); continue; } } } } opInter.Interpret(subOp, contextBlock); } }
public override void Interpret(Operator op, FunctionBlock block) { interpret = false; if (exprInter == null) { switches = Engine.GetPlugin <ContextSwitchesPlugin> (); ops = Engine.GetPlugin <EventFunctionOperators> (); exprInter = Engine.GetPlugin <ExpressionInterpreter> (); } var varName = op.Identifier as string; if (ScriptEngine.AnalyzeDebug) { Debug.Log(block); } var sCtx = block.FindStatement <ContextStatement> (v => v.InterpretInContext(op, block) != null && v.ContextVar.IsContext || v.ContextVar.IsArg); var context = sCtx != null ? sCtx.ContextVar : null; if (ScriptEngine.AnalyzeDebug) { Debug.LogFormat("FOUND COUNTEXT {0} for {1}", context, op.Identifier); } if (listT == null) { if (!(op.Context is Expression)) { return; } if (ScriptEngine.AnalyzeDebug) { Debug.Log("PROPERTY " + propName); } if (context == null) { block.Statements.Add(String.Format("root.{0} = ({2})({1});", propName, exprInter.InterpretExpression(op.Context as Expression, block).ExprString, TypeName.NameOf(propType))); } else { block.Statements.Add(String.Format("{2}.{0} = ({3})({1});", propName, exprInter.InterpretExpression(op.Context as Expression, block).ExprString, context.Name, TypeName.NameOf(propType))); } } else { Debug.Log("list of" + listT); ForStatement statement = new ForStatement(); string listVarName = context == null ? "root." + propName : context.Name + "." + propName; string iterName = "i" + DeclareVariableStatement.VariableId++; statement.InsideExpr = String.Format("int {0} = 0; {1} != null && {0} < {1}.Count; {0}++", iterName, listVarName); FunctionBlock repeatBlock = new FunctionBlock(block, block.Method, block.Type); statement.RepeatBlock = repeatBlock; block.Statements.Add(statement); Operator listVarOp = new Operator(); DeclareVariableStatement listVar = new DeclareVariableStatement(); listVar.Name = "iter" + DeclareVariableStatement.VariableId++; listVar.IsContext = true; listVar.IsNew = true; listVar.Type = listT; listVar.InitExpression = String.Format("{0}[{1}]", listVarName, iterName); statement.RepeatBlock.Statements.Add(listVar); var inter = switches.GetInterByType(listT); //Debug.Log(inter); inter.Interpret(op, repeatBlock); } interpret = true; }
public override void Interpret(Operator op, FunctionBlock block) { if (ops == null) { ops = Engine.GetPlugin <EventFunctionOperators> (); } FunctionBlock contextBlock = new FunctionBlock(block, block.Method, block.Type); block.Statements.Add(contextBlock); DeclareVariableStatement addVar = block.FindStatement <DeclareVariableStatement> (v => v.Name == op.Identifier as string); bool setContext = false; if (addVar != null && !addVar.IsContext) { setContext = addVar.IsContext = true; } if (addVar == null) { addVar = block.FindStatement <DeclareVariableStatement> (v => v.IsContext && v.Type == contextType); } //TODO: probably will fail DeclareVariableStatement contextVar = contextType == typeof(GameObject)? addVar : block.FindStatement <DeclareVariableStatement> (v => v.IsContext && v.Type == typeof(GameObject) && v != addVar); DeclareVariableStatement declareVar = null; if (addVar == null) { declareVar = new DeclareVariableStatement(); declareVar.Type = contextType; declareVar.Name = "subContext" + DeclareVariableStatement.VariableId++; declareVar.IsContext = true; if (contextVar == null) { declareVar.InitExpression = String.Format("({0})root.GetComponent(typeof({0}))", contextType); } else { declareVar.InitExpression = String.Format("({0}){1}.GetComponent(typeof({0}))", contextType, contextVar.Name); } contextBlock.Statements.Add(declareVar); } else { declareVar = addVar; } contextBlock.Statements.Add(new ContextStatement() { ContextVar = declareVar, InterpretInContext = InterpretInContext }); IfStatement isNotNull = new IfStatement(); isNotNull.CheckExpression = String.Format("{0} != null", declareVar.Name); isNotNull.TrueBlock = new FunctionBlock(contextBlock); contextBlock.Statements.Add(isNotNull); contextBlock = isNotNull.TrueBlock; contextBlock.Statements.Add(new DeclareVariableStatement() { Name = declareVar.Name, IsArg = true, IsContext = true, Type = declareVar.Type }); foreach (var entry in (op.Context as Context).Entries) { var subOp = entry as Operator; if (subOp == null) { continue; } FunctionOperatorInterpreter opInter = null; if ((opInter = ops.GetInterpreter(subOp, contextBlock)) == null) { if (!contextSwitches.TryGetValue(subOp.Identifier as string, out opInter)) { if (!functions.TryGetValue(subOp.Identifier as string, out opInter)) { if (!properties.TryGetValue(subOp.Identifier as string, out opInter)) { Debug.LogWarningFormat("Can't interpret context operator {1} in {0}", block.Method.Name, subOp.Identifier); continue; } } } } if (ScriptEngine.AnalyzeDebug) { Debug.LogFormat("Interpret {0} via {1}", subOp.Identifier, opInter); } opInter.Interpret(subOp, contextBlock); } if (setContext) { addVar.IsContext = false; } }
public override void Interpret(Operator op, FunctionBlock block) { if (components.Count == 0) { ops = Engine.GetPlugin <EventFunctionOperators> (); var cmpTypes = Engine.FindTypesCastableTo <MonoBehaviour> (); foreach (var type in cmpTypes) { components.Add(NameTranslator.ScriptNameFromCSharp(type.Name), type); } } var varName = ((op.Args [0].Operands [0] as ExprAtom).Content as Scope).Parts [0] as string; block.Statements.Add(new DeclareVariableStatement() { Name = varName, InitExpression = String.Format("new {1}(\"{0}\")", varName, typeof(GameObject)), Type = typeof(GameObject), IsContext = false }); var ctx = op.Context as Context; FunctionBlock subBlock = new FunctionBlock(block, block.Method, block.Type); block.Statements.Add(subBlock); subBlock.Statements.Add(new DeclareVariableStatement() { Name = varName + DeclareVariableStatement.VariableId++, InitExpression = varName, Type = typeof(GameObject), IsContext = true }); foreach (var entry in ctx.Entries) { var subOp = entry as Operator; var subContext = subOp.Context as Context; if (ScriptEngine.AnalyzeDebug) { Debug.Log(subOp.Identifier.GetType()); } if (subOp.Identifier is string) { Type cmpType = null; if (components.TryGetValue(subOp.Identifier as string, out cmpType)) { DeclareVariableStatement addVar = new DeclareVariableStatement(); addVar.Name = "AddContext" + DeclareVariableStatement.VariableId++; addVar.IsNew = true; addVar.InitExpression = String.Format("({1}){0}.AddComponent(typeof({1}))", varName, cmpType); addVar.IsContext = true; addVar.Type = cmpType; subBlock.Statements.Add(addVar); } } if (!IsYes(subOp.Context as Expression)) { var inter = ops.GetInterpreter(subOp, subBlock); if (inter != null) { inter.Interpret(subOp, subBlock); } } } block.Statements.Add(String.Format("UnityEngine.Object.FindObjectOfType<Generators>().Generate({0}, 0.1f);", varName)); }
public override void Interpret(InternalDSL.Operator op, FunctionBlock block) { if (ops == null) { ctxs = Engine.GetPlugin <ContextSwitchesPlugin> (); ops = Engine.GetPlugin <EventFunctionOperators> (); exprInter = Engine.GetPlugin <ExpressionInterpreter> (); } if (op.Args.Count > 0) { var varName = ((op.Args [0].Operands [0] as ExprAtom).Content as Scope).Parts [0] as string; if (op.Context is Expression) { //cache(some_name) = expression // var varDecl = block.FindStatement<DeclareVariableStatement> (v => v.Name == varName); // varDecl.IsArg = true; var exprValue = exprInter.InterpretExpression(op.Context as Expression, block); Debug.Log(exprValue.ExprString); var field = new CodeMemberField(exprValue.Type, varName); field.UserData.Add("type", exprValue.Type); block.Type.Members.Add(field); block.Statements.Add(String.Format("{0} = {1};", varName, exprValue.ExprString)); block.Statements.Add(new DeclareVariableStatement() { Name = varName, IsArg = true, Type = exprValue.Type }); //var varDecl = block.FindStatement<DeclareVariableStatement> (v => v.Name == varName); } else { //cache(some_name, scope) = { ... } var exprValue = exprInter.InterpretExpression(op.Args [1], block); var field = new CodeMemberField(exprValue.Type, varName); field.UserData.Add("type", exprValue.Type); block.Type.Members.Add(field); DeclareVariableStatement cachedVar = new DeclareVariableStatement(); cachedVar.Name = varName; cachedVar.IsContext = true; cachedVar.Type = exprValue.Type; cachedVar.IsArg = true; block.Statements.Add(cachedVar); block.Statements.Add(String.Format("{0} = {1};", varName, exprValue.ExprString)); block.Statements.Add(new DeclareVariableStatement() { Name = varName, IsArg = true, Type = exprValue.Type }); var inter = ctxs.GetInterByType(exprValue.Type); inter.Interpret(op, block); } } else { //cache = some_name var varName = (((op.Context as Expression).Operands [0] as ExprAtom).Content as Scope).Parts [0] as string; var varDecl = block.FindStatement <DeclareVariableStatement> (v => v.Name == varName); //varDecl.IsArg = true; varDecl.IsDeclaration = false; var field = new CodeMemberField(varDecl.Type, varDecl.Name); field.UserData.Add("type", varDecl.Type); block.Type.Members.Add(field); //block.Statements.Add (String.Format ("this.{0} = {0};", varName)); } //new CodeMemberField() //block.Type.Members.Add (); }
public override void Interpret(Operator op, FunctionBlock block) { if (ops == null) { ops = Engine.GetPlugin <EventFunctionOperators> (); switches = Engine.GetPlugin <ContextSwitchesPlugin> (); var cmps = Engine.FindTypesCastableTo <MonoBehaviour> (); foreach (var cmp in cmps) { components.Add(NameTranslator.ScriptNameFromCSharp(cmp.Name), cmp); } } //add = cmp_type - no args, context is Expression //add(var) = cmp_type - 1 arg, context is Expression //add(cmp_type) = { ... } - 1 arg, context is Context //add(var, cmp_type) = { ... } - 2 args, context is Context DeclareVariableStatement cmpVar = null; DeclareVariableStatement contextVar = block.FindStatement <DeclareVariableStatement> (v => (v.IsContext | v.IsArg) && v.Type == typeof(GameObject)); string ctxVar = contextVar == null ? "root" : contextVar.Name; string cmpTypeName = null; try { if (op.Args.Count == 0) { var expr = op.Context as Expression; if (expr != null) { var cmpType = (((op.Context as Expression).Operands[0] as ExprAtom).Content as Scope).Parts[0] as string; block.Statements.Add(string.Format("{0}.AddComponent<{1}>();", ctxVar, components[cmpType])); } } else if (op.Args.Count == 1) { var ctx = op.Context as Context; var expr = op.Context as Expression; if (expr != null) { cmpTypeName = (((op.Context as Expression).Operands[0] as ExprAtom).Content as Scope).Parts[0] as string; var varName = ((op.Args[0].Operands[0] as ExprAtom).Content as Scope).Parts[0] as string; var cmpType = components[cmpTypeName]; cmpVar = new DeclareVariableStatement(); cmpVar.InitExpression = string.Format("{0}.AddComponent<{1}>();", ctxVar, cmpType); cmpVar.Type = cmpType; cmpVar.Name = varName; cmpVar.IsNew = true; cmpVar.IsContext = true; block.Statements.Add(cmpVar); } else if (ctx != null) { cmpTypeName = ((op.Args[0].Operands[0] as ExprAtom).Content as Scope).Parts[0] as string; var cmpType = components[cmpTypeName]; cmpVar = new DeclareVariableStatement(); cmpVar.InitExpression = string.Format("{0}.AddComponent<{1}>();", ctxVar, cmpType); cmpVar.Type = cmpType; cmpVar.IsContext = true; cmpVar.IsNew = true; cmpVar.Name = "ContextVar" + DeclareVariableStatement.VariableId++; block.Statements.Add(cmpVar); switches.GetInterByType(cmpType).Interpret(op, block); } } else if (op.Args.Count == 2) { var ctx = op.Context as Context; if (ctx != null) { cmpTypeName = ((op.Args[1].Operands[0] as ExprAtom).Content as Scope).Parts[0] as string; var varName = ((op.Args[0].Operands[0] as ExprAtom).Content as Scope).Parts[0] as string; var cmpType = components[cmpTypeName]; cmpVar = new DeclareVariableStatement(); cmpVar.InitExpression = string.Format("{0}.AddComponent<{1}>();", ctxVar, cmpType); cmpVar.Type = cmpType; cmpVar.IsContext = true; cmpVar.IsNew = true; cmpVar.Name = varName; block.Statements.Add(cmpVar); switches.GetInterByType(cmpType).Interpret(op, block); } } var entVar = block.FindStatement <DeclareVariableStatement>(v => v.ctxEntity == ctxVar && v.Type == typeof(Entity)); if (entVar == null) { entVar = new DeclareVariableStatement(); entVar.Name = "EntVar" + DeclareVariableStatement.VariableId++; entVar.Type = typeof(Entity); entVar.ctxEntity = ctxVar; entVar.InitExpression = String.Format("(Entity){0}.GetComponent(typeof(Entity));", ctxVar); block.Statements.Add(entVar); var updateSt = new StatementStringContainer(String.Format("if({0} != null) {0}.ComponentAdded();", entVar.Name)); entVar.Cnt = updateSt; block.Statements.Add(updateSt); } else { var updateSt = new StatementStringContainer(entVar.Cnt.Data); entVar.Cnt.Data = ""; entVar.Cnt = updateSt; block.Statements.Add(updateSt); } if (cmpVar != null) { cmpVar.IsContext = false; } } catch (KeyNotFoundException e) { Debug.LogErrorFormat("Can't create {0} in {1}", cmpTypeName, op); } }
public override void Interpret(Operator op, FunctionBlock block) { interpret = false; if (exprInter == null) { switches = Engine.GetPlugin <ContextSwitchesPlugin> (); ops = Engine.GetPlugin <EventFunctionOperators> (); exprInter = Engine.GetPlugin <ExpressionInterpreter> (); } var varName = op.Identifier as string; if (ScriptEngine.AnalyzeDebug) { Debug.Log(block); } var sCtx = block.FindStatement <ContextStatement> (v => v.InterpretInContext(op, block) != null && (v.ContextVar.IsContext || v.ContextVar.IsArg)); var context = sCtx != null ? sCtx.ContextVar : null; if (ScriptEngine.AnalyzeDebug) { Debug.LogFormat("FOUND COUNTEXT {0} for {1}", context, op.Identifier); } if (listT == null) { if (op.Context is Expression) { if (ScriptEngine.AnalyzeDebug) { Debug.Log("PROPERTY " + propName); } if (context == null) { block.Statements.Add(String.Format("root.{0} = ({2})({1});", propName, exprInter.InterpretExpression(op.Context as Expression, block, propType).ExprString, TypeName.NameOf(propType))); } else { block.Statements.Add(String.Format("{2}.{0} = ({3})({1});", propName, exprInter.InterpretExpression(op.Context as Expression, block, propType).ExprString, context.Name, TypeName.NameOf(propType))); } } else if (typeof(Delegate).IsAssignableFrom(propType)) { Debug.Log("LAMBDA!"); //Interpret as lambda LambdaStatement lambda = new LambdaStatement(); lambda.DelegateType = propType; var method = propType.GetMethod("Invoke"); lambda.Params = method.GetParameters(); lambda.Name = "Lambda" + DeclareVariableStatement.VariableId++; block.Statements.Add(lambda); lambda.Block = new FunctionBlock(block); //DeclareVariableStatement lastVar = null; foreach (var param in lambda.Params) { var argVar = new DeclareVariableStatement(); // lastVar = argVar; argVar.Name = param.Name; argVar.IsArg = true; argVar.Type = param.ParameterType; lambda.Block.Statements.Add(argVar); } //if (lastVar != null) // lastVar.IsContext = true; var retType = lambda.DelegateType.GetMethod("Invoke").ReturnType; bool hasReturn = false; if (retType != null && retType != typeof(void)) { hasReturn = true; lambda.Block.Statements.Add(new DeclareVariableStatement() { Name = "return_value", InitExpression = string.Format("default({0})", retType), IsReturn = true, Type = retType }); } foreach (var entry in (op.Context as Context).Entries) { var subOp = entry as Operator; ops.GetInterpreter(subOp, lambda.Block).Interpret(subOp, lambda.Block); } if (hasReturn) { lambda.Block.Statements.Add("return return_value;"); } if (context == null) { block.Statements.Add(String.Format("root.{0} = ({2})({1});", propName, lambda.Name, TypeName.NameOf(propType))); } else { block.Statements.Add(String.Format("{2}.{0} = ({3})({1});", propName, lambda.Name, context.Name, TypeName.NameOf(propType))); } } else { return; } } else { //Debug.Log ("list of" + listT); ForStatement statement = new ForStatement(); string listVarContent = context == null ? "root." + propName : context.Name + "." + propName; string listVarName = "list" + DeclareVariableStatement.VariableId++; DeclareVariableStatement listVar = new DeclareVariableStatement(); listVar.IsTemp = true; listVar.Name = listVarName; listVar.InitExpression = listVarContent; listVar.Type = propType; block.Statements.Add(listVar); string iterName = "i" + DeclareVariableStatement.VariableId++; statement.InsideExpr = String.Format("int {0} = 0; {1} != null && {0} < {1}.Count; {0}++", iterName, listVarName); FunctionBlock repeatBlock = new FunctionBlock(block, block.Method, block.Type); statement.RepeatBlock = repeatBlock; block.Statements.Add(statement); Operator listVarOp = new Operator(); DeclareVariableStatement iterVar = new DeclareVariableStatement(); iterVar.Name = "iter" + DeclareVariableStatement.VariableId++; iterVar.IsContext = true; iterVar.IsNew = true; iterVar.Type = listT; iterVar.IsListIter = true; iterVar.InitExpression = String.Format("{0}[{1}]", listVarName, iterName); statement.RepeatBlock.Statements.Add(iterVar); var inter = switches.GetInterByType(listT); //Debug.Log(inter); inter.Interpret(op, repeatBlock); } interpret = true; }