public bool CallInitializer(CodeScopeNode Scope, ref int Index, CodeString Code) { var FS = Scope.FunctionScope; var Structured = FS.Parent as StructuredScope; var Type = Structured.StructuredType; var Class = Type as ClassType; var Plugin = Scope.GetPlugin(); if (!Plugin.Begin()) { return(false); } ExpressionNode SizeN; if (FS.ObjectSize == null) { SizeN = Plugin.NewNode(Constants.GetIntValue(Scope, Class.InstanceSize, Code, true)); if (SizeN == null) { return(false); } } else { SizeN = FS.ObjectSize.Copy(Plugin, Mode: BeginEndMode.None); if (SizeN == null) { return(false); } } return(CallInitializer(Scope, ref Index, Plugin, SizeN, Code)); }
private bool SetTypePointer(CodeScopeNode Scope, ref int Index, SelfVariable Self, CodeString Code) { var Plugin = Scope.GetPlugin(); if (!Plugin.Begin()) { return(false); } var Value = Plugin.NewNode(new DataPointerNode(Code, Self.TypeOfSelf)); if (Value == null) { return(false); } var Assignment = Expressions.SetValue(Self, "_objTypePointer", Value, Plugin, Code, true); if (Assignment == null) { return(false); } var Command = new Command(Scope, Code, CommandType.Expression); Command.Expressions = new List <ExpressionNode>() { Assignment }; Scope.Children.Insert(Index, Command); Index++; return(ProcessContainer(Command)); }
bool LeaveTryBlock(CodeScopeNode Scope, CodeString Code) { var Global = Scope.State.GlobalContainer; var Plugin = Scope.GetPlugin(); if (!Plugin.Begin()) { return(false); } var Func = Identifiers.GetByFullNameFast <Function>(Global, "Internals.LeaveTryBlock"); if (Func == null) { return(false); } var Node = Expressions.Call(Code, Plugin, Func); if (Node == null || Plugin.End(ref Node) == PluginResult.Failed) { return(false); } var Command = new Command(Scope, Code, CommandType.Expression); Command.Expressions = new List <ExpressionNode>() { Node }; Scope.Children.Add(Command); return(ProcessContainer(Command)); }
bool SetFinallyReturn(CodeScopeNode Scope, ExpressionNode Value, CodeString Code) { var FS = Scope.FunctionScope; var FSData = FS.Data.Get <NCFuncScopeData>(); if (!CreateFinallyReturn(FS)) { return(false); } var Plugin = Scope.GetPlugin(); if (!Plugin.Begin()) { return(false); } var Node = Expressions.SetValue(FSData.FinallyReturn, Value, Plugin, Code, true); if (Node == null) { return(false); } var Comm = new Command(Scope, Code, CommandType.Expression); Comm.Expressions = new List <ExpressionNode>() { Node }; Scope.Children.Add(Comm); return(ProcessContainer(Comm)); }
bool CallInitializerWithCmp(CodeScopeNode Scope, ref int Index, PluginRoot Plugin, ExpressionNode Size, CodeString Code) { var CondComm = new Command(Scope, Code, CommandType.If); Scope.Children.Insert(Index, CondComm); Index++; var ThenScope = new CodeScopeNode(CondComm, new CodeString()); CondComm.Children = new List <IdContainer>() { ThenScope }; var CmpPlugin = ThenScope.GetPlugin(); if (!CmpPlugin.Begin()) { return(false); } var FS = Scope.FunctionScope; var Self = CmpPlugin.NewNode(new IdExpressionNode(FS.SelfVariable, Code)); var Null = CmpPlugin.NewNode(Constants.GetNullValue(Scope, Code)); if (Self == null || Null == null) { return(false); } var CmpCh = new ExpressionNode[] { Self, Null }; var CmpNode = CmpPlugin.NewNode(new OpExpressionNode(Operator.RefEquality, CmpCh, Code)); if (CmpNode == null || (CmpNode = CmpPlugin.End(CmpNode)) == null) { return(false); } CondComm.Expressions = new List <ExpressionNode>() { CmpNode }; var NewIndex = ThenScope.Children.Count; if (!CallInitializerWithoutCmp(ThenScope, ref NewIndex, Plugin, Size, Code)) { return(false); } if (!ProcessContainer(ThenScope)) { return(false); } return(ProcessContainer(CondComm)); }
bool EnterTryBlock(CodeScopeNode Scope, int Index, CodeString Code, Identifier CatchVariable, int Label) { var FScope = Scope.FunctionScope; FScope.NeverSkippedLabels.Add(Label); var Global = Scope.State.GlobalContainer; var Plugin = Scope.GetPlugin(); if (!Plugin.Begin()) { return(false); } var CatchVarNode = Plugin.NewNode(new IdExpressionNode(CatchVariable, Code)); if (CatchVarNode == null) { return(false); } var Ch = new ExpressionNode[] { CatchVarNode }; CatchVarNode = Plugin.NewNode(new OpExpressionNode(Operator.Address, Ch, Code)); var JumpTo = Plugin.NewNode(new LabelExpressionNode(Code, "_" + Label.ToString())); var Func = Identifiers.GetByFullNameFast <Function>(Global, "Internals.EnterTryBlock"); if (Func == null || CatchVarNode == null || JumpTo == null) { return(false); } var Node = Expressions.Call(Code, Plugin, Func, CatchVarNode, JumpTo); if (Node == null || Plugin.End(ref Node) == PluginResult.Failed) { return(false); } var Command = new Command(Plugin.Container, Code, CommandType.Expression); Command.Expressions = new List <ExpressionNode>() { Node }; Scope.Children.Insert(0, Command); return(ProcessContainer(Command)); }
private bool SetFunctionTable(CodeScopeNode Scope, ref int Index, SelfVariable Self, CodeString Code) { var Class = Self.TypeOfSelf.UnderlyingClassOrRealId as ClassType; var Plugin = Scope.GetPlugin(); if (!Plugin.Begin()) { return(false); } ExpressionNode Value; if (Class.HasFunctionTable) { Value = Plugin.NewNode(new LabelExpressionNode(Code, Class.FunctionTableLabel)); if (Value == null) { return(false); } } else { Value = Constants.GetNullValue(Scope, Code); if (Value == null) { return(false); } } var Assignment = Expressions.SetValue(Self, "_objFunctionTable", Value, Plugin, Code, true); if (Assignment == null) { return(false); } var Command = new Command(Scope, Code, CommandType.Expression); Command.Expressions = new List <ExpressionNode>() { Assignment }; Scope.Children.Insert(Index, Command); Index++; return(ProcessContainer(Command)); }
bool SetFinallyJump(Command TryComm, CodeScopeNode Scope, string Label, CodeString Code) { var NCData = TryComm.Data.GetOrCreate <NCCommandData>(); if (!CreateFinallyJump(TryComm, Code)) { return(false); } var Plugin = Scope.GetPlugin(); if (!Plugin.Begin()) { return(false); } var Dst = Plugin.NewNode(new IdExpressionNode(NCData.FinallyJump, Code)); var Src = Plugin.NewNode(new LabelExpressionNode(Code, Label)); if (Dst == null || Src == null) { return(false); } var Ch = new ExpressionNode[] { Dst, Src }; var Node = Plugin.NewNode(new OpExpressionNode(Operator.Assignment, Ch, Code)); if (Node == null || Plugin.End(ref Node) == PluginResult.Failed) { return(false); } var Command = new Command(Scope, Code, CommandType.Expression); Command.Expressions = new List <ExpressionNode>() { Node }; Scope.Children.Add(Command); return(ProcessContainer(Command)); }
bool FinallyJump(CodeScopeNode Scope, Identifier JumpTo, CodeString Code) { var Plugin = Scope.GetPlugin(); if (!Plugin.Begin()) { return(false); } var Cmp_IdNode = Plugin.NewNode(new IdExpressionNode(JumpTo, Code)); var Cmp_Null = Plugin.NewNode(Constants.GetNullValue(Scope, Code)); if (Cmp_IdNode == null || Cmp_Null == null) { return(false); } var Cmp_Ch = new ExpressionNode[] { Cmp_IdNode, Cmp_Null }; var Cmp_Node = Plugin.NewNode(new OpExpressionNode(Operator.Inequality, Cmp_Ch, Code)); if (Cmp_Node == null || Plugin.End(ref Cmp_Node) == PluginResult.Failed) { return(false); } var Cmp_If = new Command(Scope, Code, CommandType.If); Cmp_If.Expressions = new List <ExpressionNode>() { Cmp_Node }; Scope.Children.Add(Cmp_If); if (!Plugin.Begin()) { return(false); } var Then_Node = Plugin.NewNode(new IdExpressionNode(JumpTo, Code)); if (Then_Node == null || Plugin.End(ref Then_Node) == PluginResult.Failed) { return(false); } var Then_Jump = CreateJump(Cmp_If, Then_Node, Code); if (Then_Jump == null) { return(false); } Cmp_If.Children.Add(Then_Jump); if (!ProcessContainer(Then_Jump)) { return(false); } if (!ProcessContainer(Cmp_If)) { return(false); } return(true); }