示例#1
0
        public override List <Context> GatherContexts(string context)
        {
            context = context.ToUpper();

            if ("DEF".Equals(context))
            {
                List <Context> list = new List <Context>(generator.Foundation.Dictionary.Count);

                for (int i = 0; i < generator.Foundation.Dictionary.Count; ++i)
                {
                    ContextDef contextDef = new ContextDef(generator, generator.Foundation.Dictionary[i]);
                    list.Add(contextDef);
                }

                return(list);
            }
            else if ("OBJ".Equals(context))
            {
                List <Context> list = new List <Context>(generator.Foundation.Level.Count);

                for (int i = 0; i < generator.Foundation.Level.Count; ++i)
                {
                    ContextObj contextObj = new ContextObj(generator, generator.Foundation.Level[i]);
                    list.Add(contextObj);
                }

                return(list);
            }

            return(base.GatherContexts(context));
        }
示例#2
0
        public override string Do(Statement Statement)
        {
            if (Statement is StmAtr)
            {
                StmAtr stmAtr = Statement as StmAtr;

                if (stmAtr.Owner != null &&
                    !"DEF".Equals(stmAtr.Owner.ToUpper()) &&
                    !"OBJ".Equals(stmAtr.Owner.ToUpper()))
                {
                    throw new ErrorCode(obj.ToStringVerbose(), -1, "Invalid attribute owner: " + stmAtr.Owner);
                }

                string attr = stmAtr.Attribute;

                if (stmAtr.Owner != null && "DEF".Equals(stmAtr.Owner.ToUpper()))
                {
                    StmAtr defAtr = new StmAtr(0, attr);

                    ContextDef defContext = new ContextDef(generator, obj.GetDefinition());
                    Parser     defParser  = new Parser(generator);
                    defParser.SetSingleStatement(defAtr, obj.GetDefinition().ToStringVerbose());
                    defContext.SetParser(defParser);

                    defContext.Parent = this;

                    generator.Stack.Add(defContext);

                    return(null);
                }

                if (string.Compare(attr, "ID", true) == 0)
                {
                    return("" + obj.Id);
                }
                else if (string.Compare(attr, "X", true) == 0)
                {
                    return("" + obj.Position.X);
                }
                else if (string.Compare(attr, "Y", true) == 0)
                {
                    return("" + obj.Position.Y);
                }
                else if (string.Compare(attr, "CODE", true) == 0)
                {
                    ContextObj contextObj = new ContextObj(generator, obj);
                    contextObj.SetParser(generator.GetParsed(obj.GetCode()));
                    contextObj.Parent = this;

                    generator.Stack.Add(contextObj);

                    return(null);
                }
                else
                {
                    throw new ErrorCode(obj.ToStringVerbose(), -1, "Invalid attribute name: " + stmAtr.Attribute);
                }
            }
            else
            {
                return(base.Do(Statement));
            }
        }
示例#3
0
        public override string Do(Statement Statement)
        {
            if (Statement is StmAtr)
            {
                StmAtr stmAtr = Statement as StmAtr;

                if (stmAtr.Owner != null &&
                    !"DEF".Equals(stmAtr.Owner.ToUpper()))
                {
                    throw new ErrorCode(def.ToStringVerbose(), -1, "Invalid attribute owner: " + stmAtr.Owner);
                }

                string attr = stmAtr.Attribute;

                if (string.Compare(attr, "ID", true) == 0)
                {
                    return("" + def.Id);
                }
                else if (string.Compare(attr, "NAME", true) == 0)
                {
                    return(def.Name);
                }
                else if (string.Compare(attr, "IMG_PATH", true) == 0)
                {
                    return(Path.GetDirectoryName(def.ImagePath));
                }
                else if (string.Compare(attr, "IMG_NAME", true) == 0)
                {
                    return(Path.GetFileName(def.ImagePath));
                }
                else if (string.Compare(attr, "OBJ_CNT", true) == 0)
                {
                    return("" + generator.Foundation.GetObjsOf(def).Count);
                }
                else if (string.Compare(attr, "CODE", true) == 0)
                {
                    ContextDef contextDef = new ContextDef(generator, def);
                    contextDef.SetParser(generator.GetParsed(def.GetCode()));
                    contextDef.Parent = this;

                    generator.Stack.Add(contextDef);

                    return(null);
                }
                else if (string.Compare(attr, "AUTO_CODE", true) == 0)
                {
                    ContextDef contextDef = new ContextDef(generator, def);
                    contextDef.SetParser(generator.GetParsed(def.GetCodeObjAuto()));
                    contextDef.Parent = this;

                    generator.Stack.Add(contextDef);

                    return(null);
                }
                else
                {
                    throw new ErrorCode(def.ToStringVerbose(), -1, "Invalid attribute name: " + stmAtr.Attribute);
                }
            }
            else
            {
                return(base.Do(Statement));
            }
        }