Beispiel #1
0
 /// <summary>
 /// Adds the given parameter to this set of parameters and specify how the
 /// parameter should be passed to the function.
 /// </summary>
 /// <param name="node">The Parsenode to add</param>
 /// <param name="useByRef">Whether the parameter should be passed by value or reference</param>
 public void Add(ParseNode node, bool useByRef)
 {
     if (node == null) {
         throw new ArgumentNullException("node");
     }
     ParameterParseNode paramNode = new ParameterParseNode(node);
     paramNode.Type = node.Type;
     paramNode.IsByRef = useByRef;
     Nodes.Add(paramNode);
 }
Beispiel #2
0
 /// <summary>
 /// Adds the given parameter to this set of parameters.
 /// </summary>
 /// <param name="node">The Parsenode to add</param>
 /// <param name="symbol">The symbol associated with the parameter</param>
 public void Add(ParseNode node, Symbol symbol)
 {
     if (node == null) {
         throw new ArgumentNullException("node");
     }
     ParameterParseNode paramNode = new ParameterParseNode(node, symbol);
     paramNode.Type = node.Type;
     Nodes.Add(paramNode);
 }
Beispiel #3
0
        /// <summary>
        /// Emit the code to generate a call to the write library function. A
        /// parse node must be specified which evaluates to the value to be
        /// written.
        /// </summary>
        /// <param name="cg">A CodeGenerator object</param>
        /// <param name="node">A parse node for the WRITE identifier</param>
        public override void Generate(CodeGenerator cg, ParseNode node)
        {
            if (cg == null) {
                throw new ArgumentNullException("cg");
            }
            if (node is LoopParseNode) {
                LoopParseNode loopNode = (LoopParseNode)node;
                loopNode.Callback = this;
                loopNode.Generate(cg);
            } else {
                Type writeManagerType = typeof(JComLib.WriteManager);
                List<Type> writeParamTypes = new List<Type>();

                cg.Emitter.LoadLocal(WriteManagerIndex);
                writeParamTypes.Add(writeManagerType);

                if (WriteParamsNode != null) {
                    writeParamTypes.AddRange(WriteParamsNode.Generate(cg));
                }

                if (node != null) {
                    ParameterParseNode exprParam = new ParameterParseNode(node);
                    writeParamTypes.Add(exprParam.Generate(cg));
                }

                cg.Emitter.Call(cg.GetMethodForType(_libraryName, _name, writeParamTypes.ToArray()));
                cg.Emitter.StoreLocal(ReturnIndex);

                if (ErrLabel != null) {
                    cg.Emitter.LoadLocal(ReturnIndex);
                    cg.Emitter.LoadInteger(-1);
                    cg.Emitter.BranchEqual((Label)ErrLabel.Symbol.Info);
                }
            }
        }