Example #1
0
        private static void Ptr(Compiler cmp, Argument[] args)
        {
            int         value = 0;
            Function    fct   = cmp.Functions.Last();
            PtrVariable v     = new PtrVariable
            {
                Name = args[1],
            };

            if (args.Length == 3)
            {
                Variable assign = fct.GetVariable(args[2]);

                fct.Instructions.Insert(0, new NewSetInstruction
                {
                    Destination = v,
                    Source      = assign
                });
            }

            fct.AddVariable(v);
        }
Example #2
0
        /// <summary>
        /// Returns the variable pointed by the pointer variable, or a
        /// temporary variable for that address.
        /// </summary>
        /// <returns>A temporary or a true variable</returns>
        /// <param name="ptrVble">A PtrVariable object.</param>
        public Variable GetPointedValueAsVariable(PtrVariable ptrVble)
        {
            Variable toret = this.LookForAddress( ptrVble.IntValue );

            if ( toret == null
              || toret.GetTargetType() != ptrVble.AssociatedType )
            {
                toret = new TempVariable( ptrVble.AssociatedType );
                toret.Address = ptrVble.IntValue.Value;
                toret.LiteralValue = new IntLiteral( this.machine, ptrVble.Access );
            }

            return toret;
        }