static bool CallStaticConstructors(IdContainer Container, CodeScopeNode Scope, PluginRoot Plugin, CodeString Code) { for (var i = 0; i < Container.Children.Count; i++) { if (!CallStaticConstructors(Container.Children[i], Scope, Plugin, Code)) { return(false); } } for (var i = 0; i < Container.IdentifierList.Count; i++) { var Ctor = Container.IdentifierList[i] as Constructor; if (Ctor == null || (Ctor.Flags & IdentifierFlags.Static) == 0) { continue; } if (!Plugin.Begin()) { return(false); } var CtorNode = Plugin.NewNode(new IdExpressionNode(Ctor, Code)); if (CtorNode == null) { Plugin.Reset(); return(false); } var NodeCh = new ExpressionNode[] { CtorNode }; var Node = Plugin.NewNode(new OpExpressionNode(Operator.Call, NodeCh, Code)); if (Node == null || Plugin.End(ref Node) == PluginResult.Failed) { Plugin.Reset(); return(false); } Scope.Children.Add(new Command(Scope, Code, CommandType.Expression) { Expressions = new List <ExpressionNode>() { Node }, }); } return(true); }
public ExpressionNode Copy(PluginRoot Plugin, PluginFunc Func = null, BeginEndMode Mode = BeginEndMode.Both, CodeString Code = new CodeString(), bool LeftType = false) { if ((Mode & BeginEndMode.Begin) != 0 && !Plugin.Begin()) { return(null); } if (!Code.IsValid) { Code = this.Code; } var Ret = Copy(Plugin.State, Code, x => { if (Func != null) { var Res = Func(ref x); if (Res == PluginResult.Failed) { return(null); } if (Res == PluginResult.Interrupt || Res == PluginResult.Ready) { return(x); } } return(Plugin.NewNode(x)); }); if ((Mode & BeginEndMode.End) != 0 && Ret != null) { Ret = Plugin.End(Ret); } if (Ret != null && LeftType) { Ret.Type = Type; } return(Ret); }
public ExpressionNode CallNewNode(PluginRoot Plugin, BeginEndMode Mode = BeginEndMode.Both) { if ((Mode & BeginEndMode.Begin) != 0 && !Plugin.Begin()) { return(null); } var RetValue = this; var Res = CallNewNode_NoBeginEnd(ref RetValue, Plugin); if (Res == PluginResult.Failed) { return(null); } if ((Mode & BeginEndMode.End) != 0) { RetValue = Plugin.End(RetValue); } return(RetValue); }
public bool CalcValue(PluginRoot Plugin, BeginEndMode Mode = BeginEndMode.Both, bool CreateAssignNodes = false, bool EnableUntyped = false) { InitValue = null; if (InitString.IsValid) { var NMode = Mode & BeginEndMode.Begin; InitValue = Expressions.CreateExpression(InitString, Plugin, NMode); if (InitValue == null) { return(false); } if (CreateAssignNodes) { var Node = Expressions.CreateReference(Plugin.Container, this, Plugin, InitString); if (Node == null) { return(false); } InitValue = Expressions.SetValue(Node, InitValue, Plugin, InitString, false); if (InitValue == null) { return(false); } } InitValue = Plugin.FinishNode(InitValue); if (InitValue == null) { return(false); } if (!CreateAssignNodes && TypeOfSelf.RealId is AutomaticType) { if (!EnableUntyped && InitValue.Type.RealId is AutomaticType) { Plugin.State.Messages.Add(MessageId.Untyped, Name); return(false); } Children[0] = InitValue.Type; } var TypeMgrnPlugin = Plugin.GetPlugin <TypeMngrPlugin>(); if (!TypeOfSelf.IsEquivalent(InitValue.Type) && !(TypeOfSelf.RealId is AutomaticType)) { InitValue = TypeMgrnPlugin.Convert(InitValue, TypeOfSelf, InitString); if (InitValue == null) { return(false); } } if ((Mode & BeginEndMode.End) != 0) { InitValue = Plugin.End(InitValue); if (InitValue == null) { return(false); } } var ConstVal = InitValue as ConstExpressionNode; if (ConstVal != null) { ConstInitValue = ConstVal.Value; } } else if (TypeOfSelf.RealId is AutomaticType) { if (!EnableUntyped) { Plugin.State.Messages.Add(MessageId.Untyped, Name); return(false); } } return(true); }