public static ExpressionNode Throw(PluginRoot Plugin, Identifier ExceptionType, CodeString Code, BeginEndMode BEMode = BeginEndMode.Both) { var GlobalContainer = Plugin.Container.GlobalContainer; if ((BEMode & BeginEndMode.Begin) != 0 && !Plugin.Begin()) { return(null); } var IdNode = Plugin.NewNode(new IdExpressionNode(ExceptionType, Code)); if (IdNode == null) { return(null); } var Ch = new ExpressionNode[] { IdNode }; var Node = Plugin.NewNode(new OpExpressionNode(Operator.NewObject, Ch, Code)); if (Node == null) { return(null); } return(Throw(Plugin, Node, Code, (BEMode & BeginEndMode.End) != 0)); }
public static ExpressionNode ThrowSystemException(PluginRoot Plugin, string ExceptionType, CodeString Code, BeginEndMode BEMode = BeginEndMode.Both) { var System = Identifiers.GetByFullNameFast <Namespace>(Plugin.State, "System"); if (System == null) { return(null); } return(Throw(Plugin, System, new CodeString(ExceptionType), Code, BEMode)); }
public static ExpressionNode Throw(PluginRoot Plugin, Identifier ContainerId, CodeString ExceptionType, CodeString Code, BeginEndMode BEMode = BeginEndMode.Both) { var Options = new GetIdOptions() { EnableMessages = true, Func = x => x.RealId is ClassType }; var IdExceptionType = Identifiers.GetFromMembers(ContainerId, ExceptionType, Options); if (IdExceptionType == null) { return(null); } return(Throw(Plugin, IdExceptionType, Code, BEMode)); }
public Variable[] ToVariables(PluginRoot Plugin, BeginEndMode BEMode = BeginEndMode.Both, VarDeclConvMode Mode = VarDeclConvMode.Nothing, bool UsePlugin = false, bool Declare = false, bool EnableUntyped = false) { var Ret = new Variable[Count]; for (var i = 0; i < Count; i++) { if ((BEMode & BeginEndMode.Begin) != 0) { Plugin.Reset(); } Ret[i] = this[i].ToVariable(Plugin, BEMode, Mode, UsePlugin, Declare, EnableUntyped); } return(Ret); }
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 Variable ToVariable(PluginRoot Plugin, BeginEndMode BEMode = BeginEndMode.Both, VarDeclConvMode Mode = VarDeclConvMode.Nothing, bool UsePlugin = false, bool Declare = false, bool EnableUntyped = false) { if (!CheckName(Plugin.State)) { return(null); } Variable Ret; if (UsePlugin) { Ret = Plugin.CreateVariable(Type, Name); if (Ret == null) { return(null); } Ret.InitString = InitString; if (Declare && !Plugin.DeclareIdentifier(Ret)) { return(null); } } else { Ret = ToVariable(Plugin.Container, Declare); if (Ret == null) { return(null); } } if (Mode != VarDeclConvMode.Nothing) { if (!Ret.CalcValue(Plugin, BEMode, Mode == VarDeclConvMode.Assignment, EnableUntyped)) { return(null); } } 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); }
public static ExpressionNode Throw(PluginRoot Plugin, Identifier ContainerId, string ExceptionType, CodeString Code, BeginEndMode BEMode = BeginEndMode.Both) { return(Throw(Plugin, ContainerId, new CodeString(ExceptionType), Code, BEMode)); }
public ExpressionNode GetVal(PluginRoot Plugin, BeginEndMode Mode = BeginEndMode.Both) { return(Expressions.CreateExpression(InitString, Plugin, Mode)); }