Exemplo n.º 1
0
 public PreOpDeclaration(String keyword,
     bool delim, CodeBody body, VariableType returnType,
     FunctionParameter operand, List<Specifier> specs,
     SourcePosition start, SourcePosition end)
     : base(ASTNodeType.PrefixOperator, keyword, delim, body, returnType, specs, start, end)
 {
     Operand = operand;
 }
Exemplo n.º 2
0
 public InOpDeclaration(String keyword, int precedence,
 bool delim, CodeBody body, VariableType returnType,
 FunctionParameter leftOp, FunctionParameter rightOp,
 List<Specifier> specs, SourcePosition start, SourcePosition end)
     : base(ASTNodeType.InfixOperator, keyword, delim, body, returnType, specs, start, end)
 {
     LeftOperand = leftOp;
     RightOperand = rightOp;
     Precedence = precedence;
 }
Exemplo n.º 3
0
        public bool VisitNode(FunctionParameter node)
        {
            ASTNode paramType;
            if (!Symbols.TryGetSymbol(node.VarType.Name, out paramType, NodeUtils.GetOuterClassScope(node)))
            {
                return Error("No type named '" + node.VarType.Name + "' exists in this scope!", node.VarType.StartPos, node.VarType.EndPos);
            }
            else if (!typeof(VariableType).IsAssignableFrom(paramType.GetType()))
            {
                return Error("Invalid parameter type, must be a class/struct/enum/primitive.", node.VarType.StartPos, node.VarType.EndPos);
            }
            node.VarType = paramType as VariableType;

            if (Symbols.SymbolExistsInCurrentScope(node.Name))
                return Error("A parameter named '" + node.Name + "' already exists in this function!",
                    node.Variables.First().StartPos, node.Variables.First().EndPos);

            Symbols.AddSymbol(node.Variables.First().Name, node);
            return Success;
        }
Exemplo n.º 4
0
        public bool VisitNode(FunctionParameter node)
        {
            // [specifiers] parametertype parametername[[staticarraysize]]
            if (node.Specifiers.Count > 0)
                Append("{0} ", String.Join(" ", node.Specifiers.Select(x => x.Value)));
            String staticarray = node.Variables[0].Size != -1 ? "[" + node.Variables[0].Size + "]" : "";
            Append("{0} {1}{2}", node.VarType.Name, node.Name, staticarray);

            return true;
        }