TriAxis.RunSharp.CodeGen.This C# (CSharp) Method

This() public method

public This ( ) : ContextualOperand
return ContextualOperand
		public ContextualOperand This()
		{
			if (Context.IsStatic)
				throw new InvalidOperationException(Properties.Messages.ErrCodeStaticThis);

		    Type ownerType = Context.OwnerType;
            
		    if (Context.OwnerType.IsValueType)
		    {
		        var m = Context.Member as MethodInfo;
		        if (m != null && m.IsVirtual)
		            ownerType = ownerType.MakeByRefType();
		    }

		    Operand arg = new _Arg(0, ownerType);
            return new ContextualOperand(arg, TypeMapper);
		}

Usage Example

Example #1
0
 public void RevertContextualsIn(FrameScope fs, CodeGen cg)
 {
     foreach (var varname in MangledContextuals.Values)
     {
         if (fs.AssignedContextuals.Contains(varname))
         {
             if (cg.This().Type.Name != "TopLevelFrame")
             {
                 cg.If(cg.This().Field("_assigned_" + fs.ID + "_" + varname) > 0);
                 {
                     cg.Assign(cg.This().Field("TopLevelFrame").Field("_ctxl_" + varname), cg.This().Field("TopLevelFrame").Field("_stack_" + varname).Invoke("Pop"));
                     cg.Assign(cg.This().Field("_assigned_" + fs.ID + "_" + varname), 0);
                 }
                 cg.End();
             }
             else
             {
                 cg.If(cg.This().Field("_assigned_" + fs.ID + "_" + varname) > 0);
                 {
                     cg.Assign(cg.This().Field("_ctxl_" + varname), cg.This().Field("_stack_" + varname).Invoke("Pop"));
                     cg.Assign(cg.This().Field("_assigned_" + fs.ID + "_" + varname), 0);
                 }
                 cg.End();
             }
         }
     }
 }
All Usage Examples Of TriAxis.RunSharp.CodeGen::This