Ejemplo n.º 1
0
 public void AddRow(ExpressionList row)
 {
     if (row.Count != fielddefs.Count)
     {
         throw new Exception("The row has the incorrect number of fields, " + row.Count.ToString() + " expected " + fielddefs.Count.ToString());
     }
     rows.Add(row);
 }
Ejemplo n.º 2
0
        public ExpressionList Optimize(OptimizationParams op)
        {
            ExpressionList r = new ExpressionList();

            foreach (Expression x in this)
            {
                r.Add(x.Optimize(op));
            }
            return(r);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Evaluates a list of expressions and returns a list of values
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public List <HeronValue> EvalList(ExpressionList list)
        {
            List <HeronValue> r = new List <HeronValue>();

            foreach (Expression e in list)
            {
                r.Add(Eval(e));
            }
            return(r);
        }
Ejemplo n.º 4
0
        public static ExpressionList CreateCompoundExpr(ParseNode x)
        {
            ExpressionList r = new ExpressionList();

            foreach (ParseNode child in x.Children)
            {
                int        i   = 0;
                Expression tmp = CreateExpr(child, ref i);
                r.Add(tmp);
            }
            return(r);
        }
Ejemplo n.º 5
0
        public static ExpressionList CreateAnnotations(ParseNode x)
        {
            ParseNode      anns = x.GetChild("annotations");
            ExpressionList r    = new ExpressionList();

            if (anns == null)
            {
                return(r);
            }
            foreach (ParseNode y in anns.Children)
            {
                r.Add(CreateExpr(y));
            }
            return(r);
        }
Ejemplo n.º 6
0
        private static void CreateModuleDefn(ModuleDefn m, ParseNode x)
        {
            ParseNode imports = x.GetChild("imports");

            if (imports != null)
            {
                foreach (ParseNode import in imports.Children)
                {
                    string         modAlias   = import.GetChild(0).ToString();
                    string         modDefName = import.GetChild(1).ToString().RemoveInternalWSpace();
                    ExpressionList args       = CreateCompoundExpr(import.GetChild(2));
                    m.AddImport(modAlias, modDefName, args);
                }
            }

            ParseNode inherits = x.GetChild("inherits");

            if (inherits != null)
            {
                if (inherits.GetNumChildren() != 1)
                {
                    throw new Exception("A module can only inherit from exactly one other module");
                }
                m.SetBaseClass(CreateTypeRef(inherits.GetChild(0)));
            }

            ParseNode methods = x.GetChild("methods");

            if (methods != null)
            {
                foreach (ParseNode node in methods.Children)
                {
                    FunctionDefn f = CreateMethod(node, m);
                    m.AddMethod(f);
                }
            }

            ProcessFields(x, m);
        }
Ejemplo n.º 7
0
 public TupleExpr(ExpressionList xs)
 {
     exprs = xs;
 }
Ejemplo n.º 8
0
 public FunCall(Expression f, ExpressionList args)
 {
     funexpr   = f;
     this.args = args;
 }
Ejemplo n.º 9
0
 public NewExpr(TypeRef type, ExpressionList args, string module)
 {
     this.type   = type;
     this.args   = args;
     this.module = module;
 }
Ejemplo n.º 10
0
 public RecordExpr(ExpressionList fields, FormalArgs args)
 {
     this.fields    = fields;
     this.fielddefs = args;
 }
Ejemplo n.º 11
0
 public void AddImport(string sModAlias, string sModName, ExpressionList args)
 {
     imports.Add(new Import(sModAlias, sModName, args));
 }
Ejemplo n.º 12
0
 public Import(string alias, string module, ExpressionList args)
 {
     this.module = module;
     this.alias  = alias;
     this.args   = args;
 }