public List <Figure> Execute()
        {
            Dictionary <string, object>   variableScope = new Dictionary <string, object>();
            Dictionary <string, Function> functionScope = new Dictionary <string, Function>();
            Function constructPoint  = new ConstructPointFunction();
            Function constructPlane  = new ConstructPlaneFunction();
            Function constructSphere = new ConstructSphereFunction();
            Function intersection    = new IntersectionFunction();
            Function pointOn         = new PointOnFunction();
            Function binormal        = new BinormalFunction();
            Function constructLine   = new ConstructLineFunction();
            Function center          = new CenterFunction();
            Function nullFunc        = new NullFunction();
            Function space           = new SpaceFunction();

            functionScope.Add("point", constructPoint);
            functionScope.Add("plane", constructPlane);
            functionScope.Add("sphere", constructSphere);
            functionScope.Add("intersection", intersection);
            functionScope.Add("point_on", pointOn);
            functionScope.Add("binormal", binormal);
            functionScope.Add("line", constructLine);
            functionScope.Add("center", center);
            functionScope.Add("null", nullFunc);
            functionScope.Add("space", space);

            string[] files = Directory.GetFiles("Assets/Custom/Scripts/Euclid/Lib", "*.euclid");
            foreach (string f in files)
            {
                RootStatement libRoot = ConstructAbstractSyntaxTree(Tokenize(ReadFromFile(f)));
                libRoot.Run(variableScope, functionScope);
            }

            root.Run(variableScope, functionScope);
            List <Figure> render = new List <Figure>();

            foreach (string variable in variableScope.Keys)
            {
                if (variableScope[variable] is Figure)
                {
                    Figure fig = variableScope[variable] as Figure;
                    if (fig.properties.ContainsKey("render"))
                    {
                        if (Mathf.Approximately((float)fig.properties["render"], 1))
                        {
                            render.Add(fig);
                            Debug.Log(fig);
                            fig.properties["name"] = variable;
                        }
                    }
                }
            }
            return(render);
        }
Exemplo n.º 2
0
 public void Parse(ref string[] program)
 {
     string token = ParseUtils.GetToken(ref program);
     WooScript._Log.AddMsg("Found \"" + token + "\" function (null return)");
     WooScript._Log.Indent();
     _NullFunction = WooScript.GetNullFunction(token);
     string openCurl = ParseUtils.GetToken(ref program);
     if (!openCurl.Equals("(", StringComparison.Ordinal))
         new ParseException("Expected \"(\" not \"" + openCurl + "\"");
     _NullFunction.Parse(ref program);
     string closeCurl = ParseUtils.GetToken(ref program);
     if (!closeCurl.Equals(")", StringComparison.Ordinal))
         new ParseException("Expected \")\" not \"" + closeCurl + "\"");
     WooScript._Log.UnIndent();
 }
Exemplo n.º 3
0
        protected override string RenderNullColumn(NullFunction nullColumn, bool renderAlias)
        {
            StringBuilder sbNullColumn = new StringBuilder();

            sbNullColumn = sbNullColumn.Append($"COALESCE({RenderColumn(nullColumn.Column, false)}, {RenderColumn(nullColumn.DefaultValue, false)}");
            foreach (IColumn defaultValue in nullColumn.AdditionalDefaultValues)
            {
                sbNullColumn
                .Append(", ")
                .Append(RenderColumn(defaultValue, false));
            }
            sbNullColumn.Append(")");

            return(renderAlias && !string.IsNullOrWhiteSpace(nullColumn.Alias)
                ? RenderColumnnameWithAlias(sbNullColumn.ToString(), EscapeName(nullColumn.Alias))
                : sbNullColumn.ToString());
        }
Exemplo n.º 4
0
        public void Parse(ref string[] program)
        {
            string token = ParseUtils.GetToken(ref program);

            WooScript._Log.AddMsg("Found \"" + token + "\" function (null return)");
            WooScript._Log.Indent();
            _NullFunction = WooScript.GetNullFunction(token);
            string openCurl = ParseUtils.GetToken(ref program);

            if (!openCurl.Equals("(", StringComparison.Ordinal))
            {
                new ParseException("Expected \"(\" not \"" + openCurl + "\"");
            }
            _NullFunction.Parse(ref program);
            string closeCurl = ParseUtils.GetToken(ref program);

            if (!closeCurl.Equals(")", StringComparison.Ordinal))
            {
                new ParseException("Expected \")\" not \"" + closeCurl + "\"");
            }
            WooScript._Log.UnIndent();
        }
Exemplo n.º 5
0
		public BTPreconditionNull (string dataToCheck, NullFunction func) : base (dataToCheck) {
			this.func = func;
		}
Exemplo n.º 6
0
 public BTPreconditionNull(string dataToCheck, NullFunction func) : base(dataToCheck)
 {
     this.func = func;
 }
Exemplo n.º 7
0
 public RuntimeEventHandler(String EventName, NullFunction F)
     : base(EventName)
 {
     this.F = F;
 }