private ObjectFunctionCallNode createObjectFunctionCall(CallNode parent, ParseNode s, ParseNode f) { if (!s.Equals("<symbol>") || !f.Equals("<function_call>")) { return(null); } COOPClass type = getReturnTypeForFunction(parent.type, s.terminals); ObjectFunctionCallNode output = new ObjectFunctionCallNode( type, s.terminals, parent ); foreach (ParseNode node in Parser.ConvertListNodeToListOfListObjects(f["<list_object>"])) { output.parameters.Add(createCallNodeChain(node)); } return(output); }
public string fixForC(CallNode callNode) { string output = ""; if (callNode is FunctionCallNode) { var fixedNode = (FunctionCallNode)callNode; List <COOPClass> inputs = new List <COOPClass>(); foreach (CallNode parameter in fixedNode.parameters) { inputs.Add(parameter.type); } string parameters = "("; if (callNode is ObjectFunctionCallNode) { ObjectFunctionCallNode node = callNode as ObjectFunctionCallNode; inputs.Insert(0, node.parentObject.type); NameInputTypePair tempPair = new NameInputTypePair(fixedNode.symbol, inputs); while (getMangeledName(tempPair) == null) { inputs[0] = hierarchy.getParent(inputs[0]); if (inputs[0] == null) { return(null); } tempPair = new NameInputTypePair(fixedNode.symbol, inputs); } parameters += fixForC(node.parentObject); if (inputs.Count > 1) { parameters += ","; } } NameInputTypePair pair = new NameInputTypePair(fixedNode.symbol, inputs); for (var i = 0; i < fixedNode.parameters.Count; i++) { parameters += fixForC(fixedNode.parameters[i]); if (i < fixedNode.parameters.Count - 1) { parameters += ","; } } parameters += ")"; string mangled = originalNameAndInputTypesToMangledName[pair]; output = mangled + parameters; } else if (callNode is SymbolNode) { output = callNode.ToString(); } return(output); }