Ejemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////////////////////////////////

        public virtual Object Clone()
        {
            DynLanProgram item = (DynLanProgram)this.MemberwiseClone();

#if !NET20
            if (item.Lines != null)
            {
                item.Lines = new DynLanCodeLines(item.Lines.Select(i => i.Clone()));
            }
            if (item.Classes != null)
            {
                item.Classes = new DynLanClasses(item.Classes.Select(i => i.Clone() as DynLanClass));
            }
            if (item.Methods != null)
            {
                item.Methods = new DynLanMethods(item.Methods.Select(i => i.Clone() as DynLanMethod));
            }
#else
            if (item.Lines != null)
            {
                item.Lines = new DynLanCodeLines(Linq2.Select(item.Lines, i => i.Clone()));
            }
            if (item.Classes != null)
            {
                item.Classes = new DynLanClasses(Linq2.Select(item.Classes, i => i.Clone() as DynLanClass));
            }
            if (item.Methods != null)
            {
                item.Methods = new DynLanMethods(Linq2.Select(item.Methods, i => i.Clone() as DynLanMethod));
            }
#endif

            return(item);
        }
Ejemplo n.º 2
0
        //////////////////////////////////////////////

        /*public DynLanState(String DisplayName, Guid ObjectID, DynLanContextType ContextType)
         * {
         *  this.DisplayName = DisplayName ?? "";
         *  this.ObjectID = ObjectID;
         *  this.ID = Guid.NewGuid();
         *  this.ContextType = ContextType;
         *  this.Object = new DynLanObject();
         *  this.Lines = new DynLanCodeLines();
         *  this.CurrentLineIndex = 0;
         * }*/

        public DynLanState(DynLanProgram Program, DynLanContextType ContextType)
        {
            this.Program = Program;
            //this.DisplayName = DisplayName ?? "";
            //this.ObjectID = ObjectID;
            this.ID          = Guid.NewGuid();
            this.ContextType = ContextType;
            this.Object      = new DynLanObject();
            //this.Lines = new DynLanCodeLines();
            this.CurrentLineIndex = 0;
        }
Ejemplo n.º 3
0
        //////////////////////////////////////////////

        public DynContext(DynLanProgram MainProgram)
        {
            this.GlobalState = new DynLanState(
                MainProgram,
                DynLanContextType.GLOBAL);

            this.Stack = new DynLanStates();
            this.Stack.Add(this.GlobalState);
            this.CurrentState = this.GlobalState;

            this.ID = Guid.NewGuid();
        }
Ejemplo n.º 4
0
        //public DynLanState PushContext(String DisplayName, Guid ObjectID, DynLanContextType ContextType)
        public DynLanState PushContext(
            DynLanProgram Program,
            DynLanContextType ContextType,
            IList <Object> Parameters)
        {
            DynLanState  state = new DynLanState(Program, ContextType); // DisplayName, ObjectID, ContextType);
            DynLanObject obj   = state.Object;

            this.Stack.Add(state);
            this.CurrentState = state;

            List <DynLanMethodParam> finalParameters = new List <DynLanMethodParam>();
            Int32 index = -1;

            if (Program is DynLanMethod)
            {
                DynLanMethod method = (DynLanMethod)Program;
                foreach (String parameter in method.Parameters)
                {
                    index++;

                    Object parameterValue = Parameters == null ? null :
                                            index < Parameters.Count ?
                                            Parameters[index] :
                                            new Undefined();

                    if (obj != null)
                    {
                        obj[parameter] = parameterValue;
                        finalParameters.Add(new DynLanMethodParam()
                        {
                            Name  = parameter,
                            Value = parameterValue
                        });
                    }
                }
            }

            if (obj != null)
            {
                foreach (DynLanMethod DynLanMethod in Program.Methods)
                {
                    if (state.Program is DynLanClass)
                    {
                        DynLanMethod newMethod = (DynLanMethod)DynLanMethod.Clone();
                        newMethod.ParentObject = obj;
                        obj[newMethod.Name]    = newMethod;
                    }
                    else
                    {
                        obj[DynLanMethod.Name] = DynLanMethod;
                    }
                }

                foreach (DynLanClass DynLanClass in Program.Classes)
                {
                    obj[DynLanClass.Name] = DynLanClass;
                }
            }

            RaiseProgramStart(
                state,
                finalParameters);

            return(state);
        }