コード例 #1
0
ファイル: NCProcessor.cs プロジェクト: bencz/Zinnia-lang
        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));
        }
コード例 #2
0
ファイル: NCProcessor.cs プロジェクト: bencz/Zinnia-lang
        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));
        }
コード例 #3
0
ファイル: NCProcessor.cs プロジェクト: bencz/Zinnia-lang
        private bool AllocateObject(CodeScopeNode Scope, ref int Index, SelfVariable Self, ExpressionNode Size, PluginRoot Plugin, CodeString Code)
        {
            var TypeMngrPlugin = Plugin.GetPlugin <TypeMngrPlugin>();

            TypeMngrPlugin.Flags |= TypeMngrPluginFlags.NoWarningOnCastingToSameType;
            TypeMngrPlugin.Flags |= TypeMngrPluginFlags.EnableReadonlyWriting;

            var Func = Identifiers.GetByFullNameFast <Function>(Scope.State, "Internals.ObjectHelper.Allocate");

            if (Func == null)
            {
                return(false);
            }

            var FuncNode = Plugin.NewNode(new IdExpressionNode(Func, Code));

            if (Func == null)
            {
                return(false);
            }

            var FuncType  = Func.Children[0] as TypeOfFunction;
            var SizeParam = FuncType.Children[1] as FunctionParameter;

            if (Size.Type == null || !Size.Type.IsEquivalent(SizeParam.TypeOfSelf))
            {
                Size = Expressions.Convert(Size, SizeParam.TypeOfSelf, Plugin, Code);
                if (Size == null)
                {
                    return(false);
                }
            }

            var CallCh = new ExpressionNode[] { FuncNode, Size };
            var Call   = Plugin.NewNode(new OpExpressionNode(Operator.Call, CallCh, Code));

            if (Call == null)
            {
                return(false);
            }

            var Node = Expressions.Reinterpret(Call, Self.TypeOfSelf, Plugin, Code);

            if (Node == null)
            {
                return(false);
            }

            var FS         = Scope.FunctionScope;
            var Assignment = Expressions.SetValue(FS.SelfVariable, Node, 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));
        }