public EngineFunction ToFunction(string symbol) { EngineFunction func = Functions.FirstOrDefault(x => x.Symbol.Equals(symbol)); if (func != null) { return(func); } foreach (EngineClass engineClass in Classes) { func = engineClass.Methods.FirstOrDefault(x => x.Symbol.Equals(symbol)); if (func != null) { return(func); } } return(null); }
private bool SuperTreeContainsMethod(IEngineObject engineClassSuperType, EngineFunction method) { if (engineClassSuperType == null || !(engineClassSuperType is EngineClass @class)) { return(false); } foreach (EngineFunction other in @class.Methods) { if (!other.Name.Equals(method.Name) || other.Arguments.Count != method.Arguments.Count) { continue; } bool alike = true; for (var index = 0; index < method.Arguments.Count; index++) { EngineFunction.Argument argument = method.Arguments[index]; EngineFunction.Argument otherArgument = other.Arguments[index]; if (argument.Type == otherArgument.Type) { continue; } alike = false; break; } if (alike) { return(true); } } return(SuperTreeContainsMethod(@class.SuperType, method)); }
public void Add(EngineFunction engineFunction) { Methods.Add(engineFunction); }
private void AnnotateFunctionTypes(EngineFunction obj) { obj.ReturnType = ToType(obj.ReturnTypeName); obj.Arguments.ForEach(x => x.Type = ToType(x.TypeName)); }