module Rucc::Parser::FuncCall
Private Instance Methods
read_func_args(params)
click to toggle source
@param [Array] params @return [Array]
# File lib/rucc/parser/func_call.rb, line 20 def read_func_args(params) args = [] i = 0 while true break if next_token?(')') arg = Node.conv(read_assignment_expr) if i < params.size paramtype = params[i] i += 1 else paramtype = if Type.is_flotype(arg.ty) Type::DOUBLE elsif Type.is_inttype(arg.ty) Type::INT else arg.ty end end Type.ensure_assignable!(paramtype, arg.ty) if paramtype.kind != arg.ty.kind arg = Node.ast_conv(paramtype, arg) end args.push(arg) tok = get break if Token.is_keyword?(tok, ')') if !Token.is_keyword?(tok, ',') Util.errort(tok, "unexpected token: '#{tok}'") end end args end
read_funcall(fp)
click to toggle source
@param [Node] fp
# File lib/rucc/parser/func_call.rb, line 8 def read_funcall(fp) if (fp.kind == AST::ADDR) && (fp.operand.kind == AST::FUNCDESG) desg = fp.operand args = read_func_args(desg.ty.params) return Node.ast_funcall(desg.ty, desg.fname, args) end args = read_func_args(fp.ty.ptr.params) Node.ast_funcptr_call(fp, args) end