コード例 #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);
 }
コード例 #2
0
        public ExpressionList Optimize(OptimizationParams op)
        {
            ExpressionList r = new ExpressionList();

            foreach (Expression x in this)
            {
                r.Add(x.Optimize(op));
            }
            return(r);
        }
コード例 #3
0
ファイル: HeronVM.cs プロジェクト: catb0t/heron-language
        /// <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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #7
0
 public TupleExpr(ExpressionList xs)
 {
     exprs = xs;
 }
コード例 #8
0
 public FunCall(Expression f, ExpressionList args)
 {
     funexpr   = f;
     this.args = args;
 }
コード例 #9
0
 public NewExpr(TypeRef type, ExpressionList args, string module)
 {
     this.type   = type;
     this.args   = args;
     this.module = module;
 }
コード例 #10
0
 public RecordExpr(ExpressionList fields, FormalArgs args)
 {
     this.fields    = fields;
     this.fielddefs = args;
 }
コード例 #11
0
 public void AddImport(string sModAlias, string sModName, ExpressionList args)
 {
     imports.Add(new Import(sModAlias, sModName, args));
 }
コード例 #12
0
 public Import(string alias, string module, ExpressionList args)
 {
     this.module = module;
     this.alias  = alias;
     this.args   = args;
 }