private string getMangeledName(NameInputTypePair pair) { if (originalNameAndInputTypesToMangledName.ContainsKey(pair)) { return(originalNameAndInputTypesToMangledName[pair]); } return(null); }
private void addFunctionToStaticDictionary(string originalName, List <COOPClass> inputTypes, bool isStatic) { NameInputTypePair nameInputTypePair = new NameInputTypePair(originalName, inputTypes); if (!originalNameAndInputTypesToisStatic.ContainsKey(nameInputTypePair)) { originalNameAndInputTypesToisStatic.Add(new NameInputTypePair(originalName, inputTypes), isStatic); } }
private void addFunctionToMangledNameDictionary(string originalName, List <COOPClass> inputTypes, string mangledName) { NameInputTypePair nameInputTypePair = new NameInputTypePair(originalName, inputTypes); if (!originalNameAndInputTypesToMangledName.ContainsKey(nameInputTypePair)) { originalNameAndInputTypesToMangledName.Add(nameInputTypePair, mangledName); } }
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); }
protected bool Equals(NameInputTypePair other) { return(String.Equals(name, other.name) && Equals(inputs, other.inputs)); }