public bool VisitNode(OperatorDeclaration node) { ASTNode returnType = null; if (node.ReturnType != null) { if (!Symbols.TryGetSymbol(node.ReturnType.Name, out returnType, NodeUtils.GetOuterClassScope(node))) { return(Error("No type named '" + node.ReturnType.Name + "' exists in this scope!", node.ReturnType.StartPos, node.ReturnType.EndPos)); } else if (!typeof(VariableType).IsAssignableFrom(returnType.GetType())) { return(Error("Invalid return type, must be a class/struct/enum/primitive.", node.ReturnType.StartPos, node.ReturnType.EndPos)); } } Symbols.PushScope(node.OperatorKeyword); if (node.Type == ASTNodeType.InfixOperator) { var op = node as InOpDeclaration; op.LeftOperand.Outer = node; Success = Success && op.LeftOperand.AcceptVisitor(this); op.RightOperand.Outer = node; Success = Success && op.RightOperand.AcceptVisitor(this); } else if (node.Type == ASTNodeType.PrefixOperator) { var op = node as PreOpDeclaration; op.Operand.Outer = node; Success = Success && op.Operand.AcceptVisitor(this); } else if (node.Type == ASTNodeType.PostfixOperator) { var op = node as PostOpDeclaration; op.Operand.Outer = node; Success = Success && op.Operand.AcceptVisitor(this); } Symbols.PopScope(); if (Success == false) { return(Error("Error in operator parameters.", node.StartPos, node.EndPos)); } if (Symbols.OperatorSignatureExists(node)) { return(Error("An operator with identical signature to '" + node.OperatorKeyword + "' already exists!", node.StartPos, node.EndPos)); } Symbols.AddOperator(node); return(Success); }