public void TestFunction(FunctionAstNode expect, FunctionAstNode actual, string traceMessage) { Assert.AreEqual(expect.Prototype, actual.Prototype, $"{traceMessage} -> Function {expect.Prototype.Name}"); TestGeneral(expect.Body, actual.Body, $"{traceMessage} -> Function {expect.Prototype.Name} Body"); }
public void Visit(FunctionAstNode visitable) { _functionReturnType = visitable.Prototype.ReturnType; if (_functionReturnType != "void") { _functionExpectReturn = true; _functionAllPathReturn = false; _functionHasReturn = false; } else { _functionExpectReturn = false; } if (!visitable.IsImported) { foreach (var parameter in visitable.Prototype.Parameters) { if (!_context.HasType(parameter.Type)) { throw new UnknownTypeException(parameter.Type); } _context.FunctionArgQueue.Add( new Tuple <string, string>(parameter.Type, parameter.Name)); } Visit(visitable.Body); if (_functionExpectReturn) { if (!_functionHasReturn) { throw new SemanticException( $"expect return in function {visitable.Prototype.Name}"); } if (!_functionAllPathReturn) { throw new SemanticException( $"Not all path have a return statement in function {visitable.Prototype.Name}"); } } } _context.AddFunction(visitable.Prototype); }
public void Visit(FunctionAstNode visitable) { throw new System.NotImplementedException(); }
public bool Equals(FunctionAstNode other) { return(Equals(Prototype, other.Prototype) && Equals(Body, other.Body)); }