예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ILUnaryOperation"/> class.
 /// </summary>
 /// <param name="generator">The IL generator.</param>
 /// <param name="node">The node with this unary operation.</param>
 internal ILUnaryOperation(ILCodeGenerator generator, UnaryOperation node)
 {
     this.generator = generator;
     this.node      = node;
     arg            = generator.ExprEvaluator.Create(node.Arg);
     CheckType();
 }
예제 #2
0
 internal ILTypeCast(ILCodeGenerator generator, TypeCast node)
 {
     this.generator = generator;
     this.node      = node;
     arg            = generator.ExprEvaluator.Create(node.InnerExpression);
     type           = new TypeEntity(node.CastingTypeNode);
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ILFunctionRef"/> class.
 /// This is not user defined function, it's .NET framework static method
 /// </summary>
 /// <param name="generator">The IL generator.</param>
 /// <param name="self">The new MethodInfo object of .NET Framework method</param>
 private ILFunctionRef(ILCodeGenerator generator, MethodInfo self)
 {
     system         = true;
     this.self      = self;
     this.generator = generator;
     type           = ILTypeTranslator.Translate(self.ReturnType);
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ILBinaryOperation"/> class.
 /// </summary>
 /// <param name="generator">The IL generator.</param>
 /// <param name="node">The node with this binary operation.</param>
 internal ILBinaryOperation(ILCodeGenerator generator, BinaryOperation node)
 {
     this.generator = generator;
     this.node      = node;
     arg0           = generator.ExprEvaluator.Create(node.Arg0);
     arg1           = generator.ExprEvaluator.Create(node.Arg1);
     CheckType();
 }
예제 #5
0
        bool system; //this is system function

        /// <summary>
        /// Initializes a new instance of the <see cref="T:ILFunctionRef"/> class.
        /// </summary>
        /// <param name="generator">The generator.</param>
        /// <param name="node">The node which declare this function</param>
        /// <param name="self">The new MethodInfo object for this function</param>
        internal ILFunctionRef(ILCodeGenerator generator, FunctionDefinition node, MethodInfo self)
        {
            this.self      = self;
            this.generator = generator;
            this.node      = node;
            type           = new TypeEntity(node.ReturnType);
            generator.GlobalContext.DefineObject(node.Name, this);
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ILGlobal"/> class.
        /// </summary>
        /// <param name="type">The type of the variable.</param>
        /// <param name="name">The name of the variable.</param>
        /// <param name="generator">The IL generator.</param>
        internal ILGlobal(TypeEntity type, string name, ILCodeGenerator generator)
            : base(type, generator)
        {
            this.type = type;
            Type clrType = ILTypeTranslator.Translate(type);

            self = generator.MainClass.DefineField(name, clrType, FieldAttributes.Public | FieldAttributes.Static);
            generator.GlobalContext.DefineObject(name, this);
        }
예제 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ILLocal"/> class.
        /// </summary>
        /// <param name="type">The type of the variable.</param>
        /// <param name="name">The name of the variable.</param>
        /// <param name="generator">The IL generator.</param>
        internal ILLocal(TypeEntity type, string name, ILCodeGenerator generator)
            : base(type, generator)
        {
            this.type = type;
            Type clrType = ILTypeTranslator.Translate(type);

            self = IL.DeclareLocal(clrType);
            generator.CurrentContext.DefineObject(name, this);
        }
예제 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ILArgument"/> class.
        /// </summary>
        /// <param name="type">The type of the argument.</param>
        /// <param name="name">The name of the argument.</param>
        /// <param name="generator">The IL generator.</param>
        /// <param name="method">The parent method.</param>
        /// <param name="index">The index of this argument in arguments array of parent method.</param>
        internal ILArgument(TypeEntity type, string name, ILCodeGenerator generator, MethodBuilder method, int index)
            : base(type, generator)
        {
            this.type   = type;
            this.method = method;
            Type clrType = ILTypeTranslator.Translate(type);

            self = method.DefineParameter(index, ParameterAttributes.None, name);
            generator.CurrentContext.DefineObject(name, this);
        }
예제 #9
0
        /// <summary>
        /// Looks for .NET method
        /// </summary>
        /// <param name="generator">The IL generator.</param>
        /// <param name="callNode">The node which called the .NET static method</param>
        /// <returns>ILFunctionRef for called .NET static method.
        /// <c>null</c> - if there is no static method with this name exist in .NET framework</returns>
        public static ILFunctionRef LookForDotNetMethod(ILCodeGenerator generator, FunctionCall callNode)
        {
            string name  = callNode.Name;
            int    index = name.LastIndexOf('.');

            if (index == -1)
            {
                return(null);
            }
            string typeName   = name.Substring(0, index);
            string methodName = name.Substring(index + 1);

            System.Type type = System.Type.GetType(typeName);
            if (type == null)
            {
                type = System.Type.GetType("System." + typeName);
            }
            if (type == null)
            {
                return(null);
            }


            List <Type>         argTypes = new List <Type>();
            ExpressionGenerator g        = new ExpressionGenerator(generator);

            foreach (Expression arg in callNode)
            {
                argTypes.Add(ILTypeTranslator.Translate(g.Create(arg).Type));
            }

            MethodInfo method = type.GetMethod(methodName, argTypes.ToArray());

            if (method == null || !method.IsStatic)
            {
                return(null);
            }

            return(new ILFunctionRef(generator, method));
        }
예제 #10
0
 public ExpressionGenerator(ILCodeGenerator generator)
 {
     this.generator = generator;
 }
예제 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ILConst"/> class.
 /// </summary>
 /// <param name="generator">The IL generator.</param>
 /// <param name="node">The node with this const.</param>
 internal ILConst(ILCodeGenerator generator, Const node)
 {
     this.generator = generator;
     this.node      = node;
     CheckType();
 }
예제 #12
0
파일: ILStatements.cs 프로젝트: Djuffin/jcc
 public StatementGenerator(ILCodeGenerator generator)
 {
     this.generator = generator;
 }
예제 #13
0
파일: ILCodeObject.cs 프로젝트: Djuffin/jcc
 protected ILCodeObject(TypeEntity type, ILCodeGenerator generator)
     : base(type)
 {
     this.generator = generator;
 }