Ejemplo n.º 1
0
        public void SimpleFunctionType_ParseCheck() {
            var returnVal = new LValueRef(LType.F32Type(), "");
            var parameter = new LPointerRef(new LValueRef(LType.F32Type(), ""), "");
            LFunctionType fnType = new LFunctionType(returnVal, parameter);

            Assert.AreEqual("float (float*)", fnType.Parse());
        }
Ejemplo n.º 2
0
        public void VarargFunctionType_ParseCheck() {
            var returnVal = new LValueRef(LType.F32Type(), "");
            var parameter = new LPointerRef(new LValueRef(LType.F32Type(), ""), "");
            LFunctionType fnType = new LFunctionType(returnVal, parameter) {
                HasVararg = true
            };

            Assert.AreEqual("float (float*, ...)", fnType.Parse());
        }
Ejemplo n.º 3
0
        public string ParseInstruction()
        {
            StringBuilder sb = new StringBuilder("\t");

            sb.Append(LRefHelper.GetIdentifierOf(FnType.ReturnType)).Append(" ");
            sb.Append(" = ").Append(LKeywords.Call).Append(" ");
            sb.Append(FnType.Parse()).Append(" ");
            sb.Append(FnIdentifier).Append("(");

            for (int i = 0; i < FnType.Parameters.Length; ++i)
            {
                if (i > 0)
                {
                    sb.Append(", ");
                }
                sb.Append(FnType.Parameters[i].ParseType()).Append(" ");
                sb.Append(LRefHelper.GetValueOrIdentifierOf(FnType.Parameters[i]));
            }
            sb.Append(")");

            return(sb.ToString());
        }