Beispiel #1
0
        public static ExpressionTarget Emit(
            HlCompilation compilation,
            ExpressionTarget target,
            ExpressionTarget outputTarget)
        {
            compilation.EmitterResult.Emit(
                $"LOAD",
                outputTarget.ResultAddress,
                target.ResultAddress
                );

            return(outputTarget.Cast(target.TypeDefinition));
        }
        public override ExpressionTarget ParseExpression(
            HlCompilation compilation,
            HlValueOperand expr,
            ExpressionTarget outputTarget)
        {
            string type;
            string value;

            switch (expr.Value.Type)
            {
            case HlTokenType.OpCharLiteral:
                type  = HLBaseTypeNames.s_UintTypeName;
                value = $"'{expr.Value}'";

                break;

            case HlTokenType.OpDecimalNumber:
                type = HLBaseTypeNames.s_FloatTypeName;

                unsafe
                {
                    float val = float.Parse(expr.Value.ToString());
                    value = (*( uint * )&val).ToString();
                }

                break;

            default:
                type  = HLBaseTypeNames.s_UintTypeName;
                value = expr.Value.ToString();

                break;
            }

            compilation.EmitterResult.Emit($"LOAD", outputTarget.ResultAddress, value);

            return(outputTarget.Cast(compilation.TypeSystem.GetType(compilation.Root, type)));
        }