Esempio n. 1
0
        /// <summary>Adapts the tag base to CIL.</summary>
        /// <param name="ilgen">IL Generator.</param>
        /// <param name="tab">The TagArgumentBit.</param>
        /// <param name="values">Related adaptation values.</param>
        /// <returns>Whether any adaptation was done.</returns>
        public override bool AdaptToCIL(ILGeneratorTracker ilgen, TagArgumentBit tab, CILAdaptationValues values)
        {
            int index = (int)((tab.Bits[0].Variable.Bits[0] as TextArgumentBit).InputValue as IntegerTag).Internal;

            ilgen.Emit(OpCodes.Ldarg_0);                                      // Load argument: TagData
            ilgen.Emit(OpCodes.Ldfld, TagData.Field_TagData_Runnable);        // Load TagData.Runnable
            ilgen.Emit(OpCodes.Ldfld, values.LocalVariableData(index).Field); // Load Runnable.Var
            return(true);
        }
Esempio n. 2
0
        public static TagReturnType TypeHelper_Tag_As(TagArgumentBit tab, int bit)
        {
            string type_name = tab.Bits[bit].Variable.ToString().ToLowerFast();

            if (tab.Engine.TagSystem.Types.RegisteredTypes.TryGetValue(type_name, out TagType type))
            {
                return(new TagReturnType(type));
            }
            throw new ErrorInducedException("Invalid tag type '" + type_name + "' in as[] handler!");
        }
Esempio n. 3
0
        public static TagReturnType Compiler_Tag_As(ILGeneratorTracker ilgen, TagArgumentBit tab, int bit, TagReturnType prevType)
        {
            ilgen.Emit(OpCodes.Ldfld, Field_DynamicTag_Internal); // Load field "Internal" on the input DynamicTag instance.
            ilgen.Emit(OpCodes.Ldarg_0);                          // Load argument: TagData.
            string  type_name = tab.Bits[bit].Variable.ToString();
            TagType varType   = tab.Engine.TagSystem.Types.RegisteredTypes[type_name.ToLowerFast()];

            ilgen.Emit(OpCodes.Call, varType.CreatorMethod); // Run the creator method for the type on the input tag.
            return(new TagReturnType(varType, false));
        }
Esempio n. 4
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)
        {
            string       vn    = tab.Bits[0].Variable.ToString().ToLowerFast();
            CommandEntry entry = ccse.Entries[i];

            if (!entry.VarLookup.TryGetValue(vn, out SingleCILVariable locVar))
            {
                throw new ErrorInducedException("Var tag cannot compile: unknown variable name input '" + vn + "' (That variable name cannot be found. Have you declared it in this script section? Consider using the 'require' command.)");
            }
            tab.Start                 = tab.TagSystem.LVar;
            tab.Bits[0].Key           = "\0lvar";
            tab.Bits[0].Handler       = null;
            tab.Bits[0].OriginalInput = "[" + tab.Bits[0].Variable.ToString() + "]";
            tab.Bits[0].Variable      = new Argument()
            {
                WasQuoted = false, Bits = new ArgumentBit[] { new TextArgumentBit(locVar.Index, tab.Engine) }
            };
            return(locVar.Type);
        }
 /// <summary>Adapts the template tab 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 virtual TagReturnType Adapt(CompiledCommandStackEntry ccse, TagArgumentBit tab, int i, CILAdaptationValues values)
 {
     return(default);
 /// <summary>Adapts the tag base to CIL.</summary>
 /// <param name="ilgen">IL Generator.</param>
 /// <param name="tab">The TagArgumentBit.</param>
 /// <param name="values">Related adaptation values.</param>
 /// <returns>Whether any adaptation was done.</returns>
 public virtual bool AdaptToCIL(ILGeneratorTracker ilgen, TagArgumentBit tab, CILAdaptationValues values)
 {
     return(false);
 }
Esempio n. 7
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));
        }