private expression_node find_operator(SyntaxTree.Operators ot, expression_node expr, location loc)
        {
            string name = name_reflector.get_name(ot);
            //#if (DEBUG)
            if (name == null)
            {
                if (ot == PascalABCCompiler.SyntaxTree.Operators.AddressOf)
                {
                    if (expr.is_addressed == false)
                    {
                        AddError(expr.location, "CAN_NOT_GET_ADDRESS_FROM_EXPRESSION");
                    }
                    expression_node res = new get_addr_node(expr, loc);
                    return res;
                }
                if (ot == PascalABCCompiler.SyntaxTree.Operators.Dereference)
                {
                }
                throw new CompilerInternalError("Invalid operator name");
            }
            //#endif
            SymbolInfo si = expr.type.find(name, context.CurrentScope);
            if (si == null || si.sym_info is wrapped_definition_node)
            {
            	AddError(new OperatorCanNotBeAppliedToThisType(name, expr));
            }

            expressions_list pars = new expressions_list();
            pars.AddElement(expr);

            function_node fn = convertion_data_and_alghoritms.select_function(pars, si, loc);
            expr = pars[0];
            if (fn == null)
            {
            	AddError(new OperatorCanNotBeAppliedToThisType(name, expr));
            }
#if (DEBUG)
            convertion_data_and_alghoritms.check_operator(fn);
#endif
            expression_node exp_node = convertion_data_and_alghoritms.create_simple_function_call(fn, loc, expr);
            return exp_node;
        }
예제 #2
0
 private void VisitGetAddrNode(get_addr_node en)
 {
     VisitExpression(en.addr_of);
 }
 public override void visit(SyntaxTree.get_address _get_address)
 {
     expression_node exp = convert_strong(_get_address.address_of);
     if (!exp.is_addressed)
     {
         AddError(exp.location, "CAN_NOT_GET_ADDRESS_FROM_EXPRESSION");
     }
     expression_node res = new get_addr_node(exp, get_location(_get_address));
     return_value(res);
 }