Beispiel #1
0
        /// <summary>Prepares to adapt a command entry to CIL.</summary>
        /// <param name="values">The adaptation-relevant values.</param>
        /// <param name="entry">The present entry ID.</param>
        public override void PreAdaptToCIL(CILAdaptationValues values, int entry)
        {
            CommandEntry cent = values.Entry.Entries[entry];
            MapTag       mt   = MapTag.For(cent.Arguments[0].ToString());

            if (mt.Internal.Count == 0)
            {
                throw new ErrorInducedException("Empty map input to require!");
            }
            foreach (KeyValuePair <string, TemplateObject> pair in mt.Internal)
            {
                TagType tagType;
                if (pair.Value is TagTypeTag tag)
                {
                    tagType = tag.Internal;
                }
                else if (!cent.System.TagSystem.Types.RegisteredTypes.TryGetValue(pair.Value.ToString(), out tagType))
                {
                    throw new ErrorInducedException("Invalid local variable type: " + pair.Value.ToString() + "!");
                }
                int loc = values.LocalVariableLocation(pair.Key);
                if (loc >= 0)
                {
                    TagReturnType type = values.LocalVariableType(loc);
                    if (type.Type != tagType)
                    {
                        throw new ErrorInducedException("Required local variable '" + pair.Key + "' already exists, but is of type '"
                                                        + type.Type.TypeName + "', when '" + pair.Value.ToString() + "' was required!");
                    }
                }
                values.AddVariable(pair.Key, tagType);
            }
        }
 /// <summary>Gets the resultant type of this argument bit.</summary>
 /// <param name="values">The relevant variable set.</param>
 /// <returns>The tag type.</returns>
 public override TagReturnType ReturnType(CILAdaptationValues values)
 {
     if (Bits.Length == 1)
     {
         // TODO: Generic handler?
         if (Start is LvarTagBase)
         {
             int var = (int)(((Bits[0].Variable.Bits[0]) as TextArgumentBit).InputValue as IntegerTag).Internal;
             return(values.LocalVariableType(var));
         }
         return(Start.ResultType);
     }
     return(Bits[^ 1].TagHandler.Meta.ReturnTypeResult);
Beispiel #3
0
        /// <summary>Adapts the var tag base for compiling.</summary>
        /// <param name="ccse">The compiled CSE.</param>
        /// <param name="tab">The TagArgumentBit.</param>
        /// <param name="i">The command index.</param>
        /// <param name="values">Related adaptation values.</param>
        public override TagReturnType Adapt(CompiledCommandStackEntry ccse, TagArgumentBit tab, int i, CILAdaptationValues values)
        {
            int index = (int)((tab.Bits[0].Variable.Bits[0] as TextArgumentBit).InputValue as IntegerTag).Internal;

            return(values.LocalVariableType(index));
        }