Exemple #1
0
		public Scripting.ScriptNode New()
		{
			Scripting.ScriptNode node = new ScriptNode();
			node.Index = (short)(Definition.NodeSalt - (short)Nodes.Count);
			//node.NextExpression = Definition.DatumFromIndex(SyntaxData.Nodes.Count);

			Nodes.Add(node);
			return node;
		}
Exemple #2
0
		public DecompilerException(string exp_name, int exp_index, ScriptNode node, Exception inner)
			:
			base("{0} {1} {2} {3} {4} {5}", exp_name, node.NodeIndex, exp_index, Program.NewLine, node.HexDump(), inner) { }
Exemple #3
0
 public MandelbrotTopographyFractal(ScriptNode z, ScriptNode f, ScriptNode dr, ScriptNode Palette,
                                    ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
     : base(new ScriptNode[] { z, f, dr, Palette, DimX, DimY },
            new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar,
                                 ArgumentType.Vector, ArgumentType.Scalar, ArgumentType.Scalar }, Start, Length, Expression)
 {
 }
Exemple #4
0
 /// <summary>
 /// Is operator.
 /// </summary>
 /// <param name="Left">Left operand.</param>
 /// <param name="Right">Right operand.</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression containing script.</param>
 public Is(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
     : base(Left, Right, Start, Length, Expression)
 {
 }
Exemple #5
0
        public override IElement Evaluate(IElement[] Arguments, Variables Variables)
        {
            string ColorExpression = null;

            SKColor[]         Palette;
            double[]          Coefficients = null;
            Complex[]         CoefficientsZ = null;
            ILambdaExpression f = null;
            ScriptNode        fDef = null;
            double            rc, ic;
            double            dr;
            Complex           R;
            int     dimx, dimy;
            int     c = Arguments.Length;
            int     i = 0;
            object  Obj;
            Complex z;

            Obj = Arguments[i++].AssociatedObjectValue;
            if (Obj is Complex)
            {
                z  = (Complex)Obj;
                rc = z.Real;
                ic = z.Imaginary;
            }
            else
            {
                rc = Expression.ToDouble(Obj);
                ic = Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }

            if (i >= c)
            {
                throw new ScriptRuntimeException("Insufficient parameters in call to HalleyFractal().", this);
            }

            dr = Expression.ToDouble(Arguments[i++].AssociatedObjectValue);

            if (i < c && (Arguments[i] is DoubleNumber || Arguments[i] is ComplexNumber))
            {
                R = Expression.ToComplex(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                R = Complex.One;

                if (i < c && this.Arguments[i] == null)
                {
                    i++;
                }
            }

            if (i < c)
            {
                if (Arguments[i] is DoubleVector)
                {
                    Coefficients = (double[])Arguments[i++].AssociatedObjectValue;
                }
                else if (Arguments[i] is ComplexVector)
                {
                    CoefficientsZ = (Complex[])Arguments[i++].AssociatedObjectValue;
                }

                /*else if (Parameters[i] is RealPolynomial)
                 *      Coefficients = ((RealPolynomial)Arguments[i++].AssociatedObjectValue).Coefficients;
                 * else if (Parameters[i] is ComplexPolynomial)
                 *      CoefficientsZ = ((ComplexPolynomial)Arguments[i++].AssociatedObjectValue).Coefficients;*/
                else if (Arguments[i] is IVector)
                {
                    IVector Vector = (IVector)Arguments[i++];
                    int     j, d = Vector.Dimension;

                    CoefficientsZ = new Complex[d];
                    for (j = 0; j < d; j++)
                    {
                        CoefficientsZ[j] = Expression.ToComplex(Vector.GetElement(j).AssociatedObjectValue);
                    }
                }
                else if (Arguments[i].AssociatedObjectValue is ILambdaExpression)
                {
                    f = (ILambdaExpression)Arguments[i];
                    if (f.NrArguments != 1)
                    {
                        throw new ScriptRuntimeException("Lambda expression in calls to HalleyFractal() must be of one variable.", this);
                    }

                    fDef = this.Arguments[i++];
                }
                else
                {
                    throw new ScriptRuntimeException("Parameter " + (i + 1).ToString() +
                                                     " in call to HalleyFractal has to be a vector of numbers, containing coefficients " +
                                                     "of the polynomial to use. Now it was of type " + Arguments[i].GetType().FullName,
                                                     this);
                }
            }
            else
            {
                throw new ScriptRuntimeException("Missing coefficients or lambda expression.", this);
            }

            if (i < c && this.Arguments[i] != null && Arguments[i] is ObjectVector)
            {
                ColorExpression = this.Arguments[i].SubExpression;
                Palette         = FractalGraph.ToPalette((ObjectVector)Arguments[i++]);
            }
            else
            {
                Palette         = ColorModels.RandomLinearAnalogousHSL.CreatePalette(128, 4, out int Seed, this, Variables);
                ColorExpression = "RandomLinearAnalogousHSL(128,4," + Seed.ToString() + ")";

                if (i < c && this.Arguments[i] == null)
                {
                    i++;
                }
            }

            if (i < c)
            {
                dimx = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                dimx = 320;
            }

            if (i < c)
            {
                dimy = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                dimy = 200;
            }

            if (i < c)
            {
                throw new ScriptRuntimeException("Parameter mismatch in call to HalleyFractal(z,dr[,R][,Coefficients][,Palette][,dimx[,dimy]]).",
                                                 this);
            }

            if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
            {
                throw new ScriptRuntimeException("Image size must be within 1x1 to 5000x5000", this);
            }

            if (f != null)
            {
                return(CalcHalley(rc, ic, dr, R, f, fDef, Variables, Palette, dimx, dimy,
                                  this, this.FractalZoomScript,
                                  new object[] { Palette, dimx, dimy, R, fDef, ColorExpression }));
            }
            else if (CoefficientsZ != null)
            {
                return(CalcHalley(rc, ic, dr, R, CoefficientsZ, Palette, dimx, dimy,
                                  this, this.FractalZoomScript,
                                  new object[] { Palette, dimx, dimy, R, CoefficientsZ, ColorExpression }));
            }
            else
            {
                return(CalcHalley(rc, ic, dr, R, Coefficients, Palette, dimx, dimy,
                                  this, this.FractalZoomScript,
                                  new object[] { Palette, dimx, dimy, R, Coefficients, ColorExpression }));
            }
        }
Exemple #6
0
        public static FractalGraph CalcHalley(double rCenter, double iCenter, double rDelta, Complex R,
                                              ILambdaExpression f, ScriptNode fDef, Variables Variables, SKColor[] Palette, int Width, int Height,
                                              ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
        {
            byte[]  reds;
            byte[]  greens;
            byte[]  blues;
            double  RRe = R.Real;
            double  RIm = R.Imaginary;
            double  r0, i0, r1, i1;
            double  dr, di;
            double  r, i;
            double  aspect;
            int     x, y;
            int     n, N;
            SKColor cl;

            N      = Palette.Length;
            reds   = new byte[N];
            greens = new byte[N];
            blues  = new byte[N];

            for (x = 0; x < N; x++)
            {
                cl        = Palette[x];
                reds[x]   = cl.Red;
                greens[x] = cl.Green;
                blues[x]  = cl.Blue;
            }

            Variables v = new Variables();

            Variables.CopyTo(v);

            string ParameterName;

            if (!(f is IDifferentiable Differentiable) ||
                !(Differentiable.Differentiate(ParameterName = Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim))
            {
                throw new ScriptRuntimeException("Lambda expression not differentiable.", Node);
            }

            if (!(fPrim is IDifferentiable Differentiable2) ||
                !(Differentiable2.Differentiate(ParameterName, v) is ILambdaExpression fBis))
            {
                throw new ScriptRuntimeException("Lambda expression not twice differentiable.", Node);
            }

            int    size = Width * Height * 4;
            double Conv = 1e-10;
            double Div  = 1e10;

            byte[] rgb = new byte[size];

            Complex[]  Row;
            Complex[]  Row2;
            Complex[]  Row3;
            Complex[]  Row4;
            int[]      Offset;
            IElement[] P = new IElement[1];
            int        j, c, x2;
            IElement   Obj, Obj2, Obj3;
            double     Mod;
            Complex    z, z2, z3;
            Complex    R2 = R * 2;

            rDelta *= 0.5;
            r0      = rCenter - rDelta;
            r1      = rCenter + rDelta;

            aspect = ((double)Width) / Height;

            i0 = iCenter - rDelta / aspect;
            i1 = iCenter + rDelta / aspect;

            dr = (r1 - r0) / Width;
            di = (i1 - i0) / Height;

            for (y = 0, i = i0; y < Height; y++, i += di)
            {
                Row    = new Complex[Width];
                Offset = new int[Width];

                c = Width;
                for (x = 0, x2 = y * Width * 4, r = r0; x < Width; x++, r += dr, x2 += 4)
                {
                    Row[x]    = new Complex(r, i);
                    Offset[x] = x2;
                }

                n = 0;
                while (n < N && c > 0)
                {
                    n++;
                    P[0] = Expression.Encapsulate(Row);
                    Obj  = f.Evaluate(P, v);
                    Obj2 = fPrim.Evaluate(P, v);
                    Obj3 = fBis.Evaluate(P, v);
                    Row2 = Obj.AssociatedObjectValue as Complex[];
                    Row3 = Obj2.AssociatedObjectValue as Complex[];
                    Row4 = Obj3.AssociatedObjectValue as Complex[];

                    if (Row2 == null || Row3 == null || Row4 == null)
                    {
                        throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " +
                                                         "and return complex vectors of equal length. Type returned: " +
                                                         Obj.GetType().FullName + ", " + Obj2.GetType().FullName + " and " + Obj3.GetType().FullName,
                                                         Node);
                    }
                    else if (Row2.Length != c || Row3.Length != c)
                    {
                        throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " +
                                                         "and return complex vectors of equal length. Length returned: " +
                                                         Row2.Length.ToString() + ", " + Row3.Length.ToString() + " and " + Row4.Length.ToString() +
                                                         ". Expected: " + c.ToString(), Node);
                    }

                    for (x = x2 = 0; x < c; x++)
                    {
                        j  = Offset[x];
                        z  = Row2[x];
                        z2 = Row3[x];
                        z3 = Row4[x];

                        z       = R2 * z * z2 / (2 * z2 * z2 - z * z3);
                        Row[x] -= z;

                        Mod = z.Magnitude;

                        if (Mod > Conv && Mod < Div)
                        {
                            if (x != x2)
                            {
                                Offset[x2] = j;
                            }

                            x2++;
                        }
                        else
                        {
                            if (n >= N)
                            {
                                rgb[j++] = 0;
                                rgb[j++] = 0;
                                rgb[j++] = 0;
                            }
                            else
                            {
                                rgb[j++] = blues[n];
                                rgb[j++] = greens[n];
                                rgb[j++] = reds[n];
                            }

                            rgb[j++] = 255;
                        }
                    }

                    if (x2 < x)
                    {
                        Array.Resize <Complex>(ref Row, x2);
                        Array.Resize <int>(ref Offset, x2);
                        c = x2;
                    }
                }
            }

            using (SKData Data = SKData.Create(new MemoryStream(rgb)))
            {
                SKImage Bitmap = SKImage.FromPixelData(new SKImageInfo(Width, Height, SKColorType.Bgra8888), Data, Width * 4);
                return(new FractalGraph(Bitmap, r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State));
            }
        }
Exemple #7
0
 /// <summary>
 /// DO-WHILE operator.
 /// </summary>
 /// <param name="Statement">Statement.</param>
 /// <param name="Condition">Condition.</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression containing script.</param>
 public DoWhile(ScriptNode Statement, ScriptNode Condition, int Start, int Length, Expression Expression)
     : base(Statement, Condition, Start, Length, Expression)
 {
 }
 private JuliaRoot2Variation(Complex z, ScriptNode Parameter, int Start, int Length, Expression Expression)
     : base(z, Parameter, Start, Length, Expression)
 {
 }
Exemple #9
0
 /// <summary>
 /// Encode(Object,AcceptedTypes)
 /// </summary>
 /// <param name="Object">Object to encode</param>
 /// <param name="AcceptedTypes">Accepted content types.</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression containing script.</param>
 public Encode(ScriptNode Object, ScriptNode AcceptedTypes, int Start, int Length, Expression Expression)
     : base(new ScriptNode[] { Object, AcceptedTypes }, new ArgumentType[] { ArgumentType.Normal, ArgumentType.Vector },
            Start, Length, Expression)
 {
 }
Exemple #10
0
 /// <summary>
 /// Encode(Object)
 /// </summary>
 /// <param name="Object">Object to encode</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression containing script.</param>
 public Encode(ScriptNode Object, int Start, int Length, Expression Expression)
     : base(new ScriptNode[] { Object }, new ArgumentType[] { ArgumentType.Normal }, Start, Length, Expression)
 {
 }
 public abstract void ProcessNode(ScriptNode node);
Exemple #12
0
        public object Invoke(TemplateContext context, ScriptNode callerContext, ScriptArray arguments, ScriptBlockStatement blockStatement)
        {
            if (arguments.Count == 0)
            {
                throw new ScriptRuntimeException(callerContext.Span, "Expecting at least the name of the template to include for the <include> function");
            }

            var templateName = context.ToString(callerContext.Span, arguments[0]);

            // If template name is empty, throw an exception
            if (string.IsNullOrEmpty(templateName))
            {
                // In a liquid template context, we let an include to continue without failing
                if (context is LiquidTemplateContext)
                {
                    return(null);
                }
                throw new ScriptRuntimeException(callerContext.Span, $"Include template name cannot be null or empty");
            }

            var templateLoader = context.TemplateLoader;

            if (templateLoader == null)
            {
                throw new ScriptRuntimeException(callerContext.Span, $"Unable to include <{templateName}>. No TemplateLoader registered in TemplateContext.TemplateLoader");
            }

            var templatePath = templateLoader.GetPath(context, callerContext.Span, templateName);

            // If template name is empty, throw an exception
            if (templatePath == null)
            {
                throw new ScriptRuntimeException(callerContext.Span, $"Include template path cannot be null");
            }

            // Compute a new parameters for the include
            var newParameters = new ScriptArray(arguments.Count - 1);

            for (int i = 1; i < arguments.Count; i++)
            {
                newParameters[i] = arguments[i];
            }

            context.SetValue(ScriptVariable.Arguments, newParameters, true);

            Template template;

            if (!context.CachedTemplates.TryGetValue(templatePath, out template))
            {
                var templateText = templateLoader.Load(context, callerContext.Span, templatePath);

                if (templateText == null)
                {
                    throw new ScriptRuntimeException(callerContext.Span, $"The result of including `{templateName}->{templatePath}` cannot be null");
                }

                // Clone parser options
                var parserOptions = context.TemplateLoaderParserOptions;
                var lexerOptions  = context.TemplateLoaderLexerOptions;
                template = Template.Parse(templateText, templatePath, parserOptions, lexerOptions);

                // If the template has any errors, throw an exception
                if (template.HasErrors)
                {
                    throw new ScriptParserRuntimeException(callerContext.Span, $"Error while parsing template `{templateName}` from `{templatePath}`", template.Messages);
                }

                context.CachedTemplates.Add(templatePath, template);
            }

            // Make sure that we cannot recursively include a template

            context.PushOutput();
            object result = null;

            try
            {
                context.EnterRecursive(callerContext);
                result = template.Render(context);
                context.ExitRecursive(callerContext);
            }
            finally
            {
                context.PopOutput();
            }

            return(result);
        }
Exemple #13
0
 /// <summary>
 /// Named member Assignment operator.
 /// </summary>
 /// <param name="NamedMember">Named member</param>
 /// <param name="Operand">Operand.</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression containing script.</param>
 public NamedMemberAssignment(NamedMember NamedMember, ScriptNode Operand, int Start, int Length, Expression Expression)
     : base(NamedMember.Operand, Operand, Start, Length, Expression)
 {
     this.name = NamedMember.Name;
 }
Exemple #14
0
 /// <summary>
 /// Interval operator
 /// </summary>
 /// <param name="From">From</param>
 /// <param name="To">To</param>
 /// <param name="StepSize">Step size.</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression containing script.</param>
 public Interval(ScriptNode From, ScriptNode To, ScriptNode StepSize, int Start, int Length, Expression Expression)
     : base(From, To, StepSize, Start, Length, Expression)
 {
 }
 private JuliaRoot2Variation(double Re, double Im, ScriptNode Parameter1, ScriptNode Parameter2,
                             int Start, int Length, Expression Expression)
     : base(Re, Im, Parameter1, Parameter2, Start, Length, Expression)
 {
 }
Exemple #16
0
        public string Generate(ScriptNode syntaxTree, string className)
        {
            DataContext data = new DataContext();

            WriteLine(data, "using System;");
            WriteLine(data, "using System.Collections.Generic;");
            WriteLine(data);

            WriteLine(data, "namespace {0}", GeneratedCodeNamespace);
            WriteLine(data, "{{");

            data.CodeBlock.Padding++;
            WriteLine(data, "public class {0} : Script", className);
            WriteLine(data, "{{");

            data.CodeBlock.Padding++;
            WriteLine(data, "public override dynamic Execute(ScriptExecutionContext context)");
            WriteLine(data, "{{");

            data.CodeBlock.Padding++;
            WriteLine(data, "try");
            WriteLine(data, "{{");

            data.CodeBlock.Padding++;
            foreach (var statement in syntaxTree.Statements)
            {
                GenerateStatement(statement, data);
            }

            if (!(syntaxTree.Statements.Last() is ReturnNode))
                WriteLine(data, "return null;");

            data.CodeBlock.Padding--;
            WriteLine(data, "}}");
            WriteLine(data, "catch (Exception ex)");
            WriteLine(data, "{{");

            data.CodeBlock.Padding++;
            WriteLine(data, "throw new ScriptExecutionException(ex.Message, context.GetStackFrames(), ex);");

            data.CodeBlock.Padding--;
            WriteLine(data, "}}");

            data.CodeBlock.Padding--;
            WriteLine(data, "}}");

            for (int i = 1; i <= data.FunctionCount; i++)
            {
                WriteLine(data);
                data.CodeBlock.Code.Append("\t\t");
                data.CodeBlock.Code.Append(data.CodeBlocksMap["Function" + i].ToString());
            }

            data.CodeBlock.Padding--;
            WriteLine(data, "}}");

            data.CodeBlock.Padding--;
            WriteLine(data, "}}");

            return data.CodeBlock.ToString();
        }
Exemple #17
0
        private void traverseNode( ScriptNode node, ref StreamWriter writer, bool isLast )
        {
            writer.WriteLine( "{" );
            writer.Write( "\"type\":" );
            switch( node.Type ) {
                case 0:
                    writer.WriteLine( "\"root\"," );
                    break;
                case Token.T_FUNCTION:
                    writer.WriteLine( "\"function\"," );
                    break;
                case Token.T_PROPERTY:
                    writer.WriteLine( "\"property\"," );
                    break;
                case Token.T_CLASS:
                    writer.WriteLine( "\"class\"," );
                    break;
                case Token.T_VAR:
                    writer.WriteLine( "\"var\"," );
                    break;
                case Token.T_CONST:
                    writer.WriteLine( "\"const\"," );
                    break;
                default:
                    writer.WriteLine( "\"unknown\"," );
                    break;
            }
            if( node.Type == Token.T_FUNCTION && node .Args != null && node.Args.Count > 0 ) {
                writer.WriteLine( "\"arguments\":[" );
                for( int i = 0; i < node.Args.Count; i++ ) {
                    string arg = node.Args[i];
                    if( ( i + 1 ) != node.Args.Count ) {
                        writer.WriteLine( "\"" + arg + "\"," );
                    } else {
                        writer.WriteLine( "\"" + arg + "\"" );
                    }
                }
                if( node.Comment != null || node.Child != null ) {
                    writer.WriteLine( "]," );
                } else {
                    writer.WriteLine( "]" );
                }
            }
            if( node.Comment != null || node.Child != null ) {
                writer.WriteLine( "\"name\":\"" + node.Name + "\"," );
            } else {
                writer.WriteLine( "\"name\":\"" + node.Name + "\"" );
            }
            if( node.Comment != null ) {
                writer.WriteLine( "\"comment\":{" );
                string comment = escapeJsonString( node.Comment );
                List<CommentNode> cnl = parseComment( node.Comment );
                if( cnl.Count > 0 ) {
                    writer.WriteLine( "\"raw\":\"" + comment + "\"," );
                } else {
                    writer.WriteLine( "\"raw\":\"" + comment + "\"" );
                }
                List<Param> parameters = new List<Param>();
                for( int i = 0; i < cnl.Count; i++ ) {
                    CommentNode cn = cnl[i];
                    string body = Regex.Replace( cn.Body, "[ \t]*\\\\n$", "" );	// 末尾の空白と改行は削除する
                    body = escapeJsonString( body );
                    switch( cn.Type ) {
                        case CommentType.SUMMARY:
                            writer.Write( "\"summary\":" );
                            break;
                        case CommentType.PARAM:
                            //writer.Write( "\"param\":{\"name\":\"" + cn.Name + "\",\"desc\":\"" + body + "\"}" );
                            parameters.Add( new Param( cn.Name, body ) );
                            break;
                        case CommentType.RETURN:
                            writer.Write( "\"return\":" );
                            break;
                        case CommentType.THROW:
                            writer.Write( "\"throw\":" );
                            break;
                        case CommentType.AUTHOR:
                            writer.Write( "\"author\":" );
                            break;
                        case CommentType.VERSION:
                            writer.Write( "\"version\":" );
                            break;
                        case CommentType.SEE:
                            writer.Write( "\"see\":" );
                            break;
                        case CommentType.DESCRIPTION:
                            writer.Write( "\"description\":" );
                            break;
                        default:
                            writer.Write( "\"unknown\":" );
                            break;
                    }
                    if( cn.Type != CommentType.PARAM ) {
                        writer.Write( "\"" + body + "\"" );
                    }
                    if( ( i + 1 ) != cnl.Count || parameters.Count > 0 ) {
                        writer.Write( "," );
                    }
                    writer.WriteLine( "" );
                }
                if( parameters.Count > 0 ) {
                    writer.WriteLine( "\"param\":[" );
                    for( int i = 0; i < parameters.Count; i++ ) {
                        Param p = parameters[i];
                        writer.Write( "{\"name\":\"" + p.Name + "\",\"desc\":\"" + p.Desc + "\"}" );
                        if( ( i + 1 ) != parameters.Count ) {
                            writer.WriteLine( "," );
                        } else {
                            writer.WriteLine( "" );
                        }
                    }
                    writer.WriteLine( "]" );
                }

                if( node.Child != null ) {
                    writer.WriteLine( "}," );
                } else {
                    writer.WriteLine( "}" );
                }
            }
            if( node.Child != null ) {
                writer.Write( "\"members\":[" );
                int count = node.Child.Count;
                int index = 0;
                foreach( ScriptNode n in node.Child ) {
                    traverseNode( n, ref writer, ( index + 1 ) == count );
                    index++;
                }
                writer.Write( "]" );
            }
            if( isLast ) {
                writer.WriteLine( "}" );
            } else {
                writer.WriteLine( "}," );
            }
        }
Exemple #18
0
 public InlineableNodeViewModel(ScriptViewModel script, ScriptNode node) : base(script, node)
 {
     MenuItems.Add(new MenuItemViewModel {
         Header = "Inline", Command = InlineThis
     });
 }
Exemple #19
0
 /// <summary>
 /// Generates a <see cref="Graphs3D.PhongIntensity"/> object.
 /// </summary>
 /// <param name="Diffuse">Diffuse light.</param>
 /// <param name="Specular">Specular light.</param>
 /// <param name="Position">Light source position.</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression.</param>
 public PhongShader(ScriptNode Diffuse, ScriptNode Specular, ScriptNode Position,
                    int Start, int Length, Expression Expression)
     : base(new ScriptNode[] { Diffuse, Specular, Position },
            new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Normal }, Start, Length, Expression)
 {
 }
Exemple #20
0
 public IfDefViewModel(ScriptViewModel script, ScriptNode node) : base(script, node)
 {
 }
Exemple #21
0
        public static FractalGraph CalcHalley(double rCenter, double iCenter, double rDelta, Complex R,
                                              Complex[] Coefficients, SKColor[] Palette, int Width, int Height, ScriptNode Node,
                                              FractalZoomScript FractalZoomScript, object State)
        {
            byte[]  reds;
            byte[]  greens;
            byte[]  blues;
            double  RRe = R.Real;
            double  RIm = R.Imaginary;
            double  r0, i0, r1, i1;
            double  dr, di;
            double  r, i;
            double  zr, zi, zr2, zi2, zr3, zi3, zr4, zi4, zr5, zi5, zr6, zi6;
            double  aspect;
            double  Temp;
            int     x, y;
            int     n, N;
            int     index;
            int     Degree = Coefficients.Length - 1;
            SKColor cl;

            N      = Palette.Length;
            reds   = new byte[N];
            greens = new byte[N];
            blues  = new byte[N];

            for (x = 0; x < N; x++)
            {
                cl        = Palette[x];
                reds[x]   = cl.Red;
                greens[x] = cl.Green;
                blues[x]  = cl.Blue;
            }

            if (Degree < 3)
            {
                Array.Resize <Complex>(ref Coefficients, 4);
                while (Degree < 3)
                {
                    Coefficients[++Degree] = Complex.Zero;
                }
            }

            Complex[] Prim = new Complex[Degree];
            for (x = 1; x <= Degree; x++)
            {
                Prim[x - 1] = x * Coefficients[x];
            }

            Complex[] Bis = new Complex[Degree - 1];
            for (x = 1; x < Degree; x++)
            {
                Bis[x - 1] = x * Prim[x];
            }

            Array.Reverse(Bis);
            Array.Reverse(Prim);
            Coefficients = (Complex[])Coefficients.Clone();
            Array.Reverse(Coefficients);

            int j, c = Prim.Length;
            int c2 = c - 1;

            double[] ReC    = new double[c + 1];
            double[] ImC    = new double[c + 1];
            double[] RePrim = new double[c];
            double[] ImPrim = new double[c];
            double[] ReBis  = new double[c2];
            double[] ImBis  = new double[c2];
            Complex  z;

            for (j = 0; j < c; j++)
            {
                z      = Coefficients[j];
                ReC[j] = z.Real;
                ImC[j] = z.Imaginary;

                z         = Prim[j];
                RePrim[j] = z.Real;
                ImPrim[j] = z.Imaginary;

                if (j < c2)
                {
                    z        = Bis[j];
                    ReBis[j] = z.Real;
                    ImBis[j] = z.Imaginary;
                }
            }

            z      = Coefficients[j];
            ReC[j] = z.Real;
            ImC[j] = z.Imaginary;

            int    size = Width * Height * 4;
            double Conv = 1e-10;
            double Div  = 1e10;

            byte[] rgb = new byte[size];

            rDelta *= 0.5;
            r0      = rCenter - rDelta;
            r1      = rCenter + rDelta;

            aspect = ((double)Width) / Height;

            i0 = iCenter - rDelta / aspect;
            i1 = iCenter + rDelta / aspect;

            dr = (r1 - r0) / Width;
            di = (i1 - i0) / Height;

            for (y = 0, i = i0, index = 0; y < Height; y++, i += di)
            {
                for (x = 0, r = r0; x < Width; x++, r += dr)
                {
                    zr = r;
                    zi = i;

                    n = 0;
                    do
                    {
                        // f:
                        zr2 = zi2 = 0;
                        for (j = 0; j <= c; j++)
                        {
                            Temp = zr2 * zr - zi2 * zi + ReC[j];
                            zi2  = zr2 * zi + zi2 * zr + ImC[j];
                            zr2  = Temp;
                        }

                        // f':
                        zr3 = zi3 = 0;
                        for (j = 0; j < c; j++)
                        {
                            Temp = zr3 * zr - zi3 * zi + RePrim[j];
                            zi3  = zr3 * zi + zi3 * zr + ImPrim[j];
                            zr3  = Temp;
                        }

                        // f":
                        zr4 = zi4 = 0;
                        for (j = 0; j < c2; j++)
                        {
                            Temp = zr4 * zr - zi4 * zi + ReBis[j];
                            zi4  = zr4 * zi + zi4 * zr + ImBis[j];
                            zr4  = Temp;
                        }

                        // 2*f*f'

                        zr5 = 2 * (zr2 * zr3 - zi2 * zi3);
                        zi5 = 2 * (zr2 * zi3 + zi2 * zr3);

                        // 2f'^2-f*f"

                        zr6 = 2 * (zr3 * zr3 - zi3 * zi3) - (zr2 * zr4 - zi2 * zi4);
                        zi6 = 4 * zr3 * zi3 - (zr2 * zi4 + zr4 * zi2);

                        // R*2*f*f'/2f'^2-f*f"

                        Temp = 1.0 / (zr6 * zr6 + zi6 * zi6);
                        zr4  = (zr5 * zr6 + zi5 * zi6) * Temp;
                        zi4  = (zi5 * zr6 - zr5 * zi6) * Temp;

                        // R*2*f*f'/(2f'^2-f*f")
                        Temp = zr4 * RRe - zi4 * RIm;
                        zi4  = zr4 * RIm + zi4 * RRe;
                        zr4  = Temp;

                        zr -= zr4;
                        zi -= zi4;

                        Temp = Math.Sqrt(zr4 * zr4 + zi4 * zi4);
                    }while ((Temp > Conv) && (Temp < Div) && (n++ < N));

                    if (Temp < Conv && n < N)
                    {
                        rgb[index++] = blues[n];
                        rgb[index++] = greens[n];
                        rgb[index++] = reds[n];
                    }
                    else
                    {
                        rgb[index++] = 0;
                        rgb[index++] = 0;
                        rgb[index++] = 0;
                    }

                    rgb[index++] = 255;
                }
            }

            using (SKData Data = SKData.Create(new MemoryStream(rgb)))
            {
                SKImage Bitmap = SKImage.FromPixelData(new SKImageInfo(Width, Height, SKColorType.Bgra8888), Data, Width * 4);
                return(new FractalGraph(Bitmap, r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State));
            }
        }
Exemple #22
0
 public void Advance([CanBeNull] ScriptNode node)
 {
     _runner.Advance(node);
 }
Exemple #23
0
 public HalleyFractal(ScriptNode z, ScriptNode dr, int Start, int Length, Expression Expression)
     : base(new ScriptNode[] { z, dr },
            new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar }, Start, Length, Expression)
 {
 }
Exemple #24
0
 /// <summary>
 /// Transpose operator.
 /// </summary>
 /// <param name="Operand">Operand.</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression containing script.</param>
 public Transpose(ScriptNode Operand, int Start, int Length, Expression Expression)
     : base(Operand, Start, Length, Expression)
 {
 }
Exemple #25
0
 /// <summary>
 /// MarkdownEncode(x)
 /// </summary>
 /// <param name="Argument">Argument.</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression containing script.</param>
 public MarkdownEncode(ScriptNode Argument, int Start, int Length, Expression Expression)
     : base(Argument, Start, Length, Expression)
 {
 }
Exemple #26
0
 /// <summary>
 /// Residue from self operator.
 /// </summary>
 /// <param name="VariableName">Variable name..</param>
 /// <param name="Operand">Operand.</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression containing script.</param>
 public ResidueFromSelf(string VariableName, ScriptNode Operand, int Start, int Length, Expression Expression)
     : base(VariableName, Operand, Start, Length, Expression)
 {
 }
Exemple #27
0
        public static FractalGraph CalcMandelbrot(double rCenter, double iCenter, double rDelta,
                                                  SKColor[] Palette, int Width, int Height, ScriptNode Node,
                                                  FractalZoomScript FractalZoomScript, object State)
        {
            double r0, i0, r1, i1;
            double dr, di;
            double r, i;
            double zr, zi, zrt, zr2, zi2;
            double aspect;
            int    x, y;
            int    n, N;

            N = Palette.Length;

            int Size = Width * Height;

            int[] ColorIndex = new int[Size];
            int   Index      = 0;

            rDelta *= 0.5;
            r0      = rCenter - rDelta;
            r1      = rCenter + rDelta;

            aspect = ((double)Width) / Height;

            i0 = iCenter - rDelta / aspect;
            i1 = iCenter + rDelta / aspect;

            dr = (r1 - r0) / Width;
            di = (i1 - i0) / Height;

            for (y = 0, i = i0; y < Height; y++, i += di)
            {
                for (x = 0, r = r0; x < Width; x++, r += dr)
                {
                    zr = r;
                    zi = i;

                    n   = 0;
                    zr2 = zr * zr;
                    zi2 = zi * zi;

                    while (zr2 + zi2 < 9 && n < N)
                    {
                        n++;
                        zrt = zr2 - zi2 + r;
                        zi  = 2 * zr * zi + i;
                        zr  = zrt;

                        zr2 = zr * zr;
                        zi2 = zi * zi;
                    }

                    if (n >= N)
                    {
                        ColorIndex[Index++] = N;
                    }
                    else
                    {
                        ColorIndex[Index++] = n;
                    }
                }
            }

            ColorIndex = FractalGraph.FindBoundaries(ColorIndex, Width, Height);

            return(new FractalGraph(FractalGraph.ToBitmap(ColorIndex, Width, Height, Palette),
                                    r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State));
        }
Exemple #28
0
 public NewtonTopographyFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode c, ScriptNode Palette,
                                int Start, int Length, Expression Expression)
     : base(new ScriptNode[] { z, dr, R, c, Palette },
            new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar,
                                 ArgumentType.Normal, ArgumentType.Vector },
            Start, Length, Expression)
 {
 }
Exemple #29
0
        public static FractalGraph CalcMandelbrot(double rCenter, double iCenter, double rDelta,
                                                  ILambdaExpression f, Variables Variables, SKColor[] Palette, int Width, int Height,
                                                  ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
        {
            double r0, i0, r1, i1;
            double dr, di;
            double r, i, Mod;
            double aspect;
            int    x, x2, y;
            int    n, N;

            N = Palette.Length;

            int Size = Width * Height;

            int[] ColorIndex = new int[Size];

            Complex z;

            IElement[] P = new IElement[2];
            int        j, c;
            IElement   Obj;

            rDelta *= 0.5;
            r0      = rCenter - rDelta;
            r1      = rCenter + rDelta;

            aspect = ((double)Width) / Height;

            i0 = iCenter - rDelta / aspect;
            i1 = iCenter + rDelta / aspect;

            dr = (r1 - r0) / Width;
            di = (i1 - i0) / Height;

            for (y = 0, i = i0; y < Height; y++, i += di)
            {
                Complex[] Row    = new Complex[Width];
                Complex[] Row0   = new Complex[Width];
                int[]     Offset = new int[Width];

                c = Width;
                for (x = 0, x2 = y * Width, r = r0; x < Width; x++, r += dr, x2++)
                {
                    Row[x]    = Row0[x] = new Complex(r, i);
                    Offset[x] = x2;
                }

                Variables v = new Variables();
                Variables.CopyTo(v);

                n = 0;
                while (n < N && c > 0)
                {
                    n++;
                    P[0] = Expression.Encapsulate(Row);
                    P[1] = Expression.Encapsulate(Row0);
                    Obj  = f.Evaluate(P, v);
                    Row  = Obj.AssociatedObjectValue as Complex[];

                    if (Row is null)
                    {
                        throw new ScriptRuntimeException("Lambda expression must be able to accept complex vectors, " +
                                                         "and return complex vectors of equal length. Type returned: " +
                                                         Obj.GetType().FullName, Node);
                    }
                    else if (Row.Length != c)
                    {
                        throw new ScriptRuntimeException("Lambda expression must be able to accept complex vectors, " +
                                                         "and return complex vectors of equal length. Length returned: " +
                                                         Row.Length.ToString() + ". Expected: " + c.ToString(), Node);
                    }

                    for (x = x2 = 0; x < c; x++)
                    {
                        z = Row[x];
                        j = Offset[x];

                        Mod = z.Magnitude;

                        if (Mod < 3)
                        {
                            if (x != x2)
                            {
                                Row[x2]    = z;
                                Row0[x2]   = Row0[x];
                                Offset[x2] = j;
                            }

                            x2++;
                        }
                        else
                        {
                            if (n >= N)
                            {
                                ColorIndex[j++] = N;
                            }
                            else
                            {
                                ColorIndex[j++] = n;
                            }
                        }
                    }

                    if (x2 < x)
                    {
                        Array.Resize <Complex>(ref Row, x2);
                        Array.Resize <Complex>(ref Row0, x2);
                        Array.Resize <int>(ref Offset, x2);
                        c = x2;
                    }
                }

                if (c > 0)
                {
                    for (x = 0; x < c; x++)
                    {
                        j             = Offset[x];
                        ColorIndex[j] = N;
                    }
                }
            }

            ColorIndex = FractalGraph.FindBoundaries(ColorIndex, Width, Height);

            return(new FractalGraph(FractalGraph.ToBitmap(ColorIndex, Width, Height, Palette),
                                    r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State));
        }
Exemple #30
0
 /// <summary>
 /// Exp(x)
 /// </summary>
 /// <param name="Argument">Argument.</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression containing script.</param>
 public Exp(ScriptNode Argument, int Start, int Length, Expression Expression)
     : base(Argument, Start, Length, Expression)
 {
 }
Exemple #31
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            if (DepthFirst)
            {
                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                foreach (Assignment SetOperation in this.setOperations)
                {
                    if (!(SetOperation?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                    {
                        return(false);
                    }
                }

                if (!(this.where?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            if (!(this.source is null) && !Callback(ref this.source, State))
            {
                return(false);
            }

            int i, c = this.setOperations.Length;

            for (i = 0; i < c; i++)
            {
                ScriptNode SetOperation = this.setOperations[i];

                if (!(SetOperation is null))
                {
                    if (!Callback(ref SetOperation, State))
                    {
                        return(false);
                    }

                    if (SetOperation is Assignment Assignment)
                    {
                        this.setOperations[i] = Assignment;
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            if (!(this.where is null) && !Callback(ref this.where, State))
            {
                return(false);
            }

            if (!DepthFirst)
            {
                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                foreach (Assignment SetOperation in this.setOperations)
                {
                    if (!(SetOperation?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                    {
                        return(false);
                    }
                }

                if (!(this.where?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #32
0
        /// <summary>
        /// Calls the callback method for all child nodes.
        /// </summary>
        /// <param name="Callback">Callback method to call.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="DepthFirst">If calls are made depth first (true) or on each node and then its leaves (false).</param>
        /// <returns>If the process was completed.</returns>
        public override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
        {
            if (DepthFirst)
            {
                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.select?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            ScriptNode Node = this.source;

            if (!(Node is null) && !Callback(ref Node, State))
            {
                return(false);
            }

            if (Node is SourceDefinition Source2)
            {
                this.source = Source2;
            }
            else
            {
                return(false);
            }

            Node = this.select;
            if (!(Node is null) && !Callback(ref Node, State))
            {
                return(false);
            }

            if (Node is Select Select1)
            {
                this.select = Select1;
            }
            else
            {
                return(false);
            }

            if (!DepthFirst)
            {
                if (!(this.source?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }

                if (!(this.select?.ForAllChildNodes(Callback, State, DepthFirst) ?? true))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #33
0
        private ScriptNode createNodes( string script )
        {
            if( parse( script ) == false) {
                System.Console.WriteLine( "Parse Error. Line: " + error_line_ );
                return null;
            }
            string comment = null;
            string name = null;
            int type = 0;
            bool prevComment = false;
            int nest = 0;
            ScriptNode topNode = new ScriptNode( 0, null, null );
            ScriptNode currentNode = topNode;
            Stack<ScriptNode> node = new Stack<ScriptNode>();
            node.Push( topNode );
            Stack<int> classNest = new Stack<int>();
            classNest.Push( -2 );
            int i = 0;
            string headerComment = null;
            if( tokens_.Count > 0 && tokens_[0].Token == Token.T_COMMENT ) {
                // header comment
                i++;
                headerComment = (string)tokens_[0].Value;
                if( tokens_.Count > 1 ) {
                    int token = tokens_[1].Token;
                    if( token == Token.T_FUNCTION ||
                        token == Token.T_PROPERTY ||
                        token == Token.T_CLASS ||
                        token == Token.T_VAR ||
                        token == Token.T_CONST ) {
                        // ヘッダーコメントではなく、次のメンバのコメントとなる
                        headerComment = null;
                        i--;
                    }
                }
            }
            if( headerComment != null ) {
                topNode.Comment = headerComment;
            }
            for( ; i < tokens_.Count; i++ ) {
                TokenInfo token = tokens_[i];
                switch( token.Token ) {
                    case Token.T_COMMENT:
                        comment = (string)token.Value;
                        prevComment = true;
                        break;
                    case Token.T_SYMBOL:
                        name = (string)token.Value;
                        if( type != 0 ) {
                            if( prevComment != true ) {
                                comment = null;
                            }
                            ScriptNode n = new ScriptNode( type, name, comment );
                            currentNode.Child.Add( n );
                            if( type == Token.T_CLASS ) {
                                node.Push( n );
                                currentNode = n;
                            }
                            if( type == Token.T_FUNCTION ) {
                                // 関数なので引数をチェックする
                                i++;
                                if( i < tokens_.Count ) {
                                    token = tokens_[i];
                                    if( token.Token != Token.T_LPARENTHESIS ) {
                                        i--;
                                        continue;
                                    }
                                }
                                // Token.T_LPARENTHESIS (
                                // Token.T_RPARENTHESIS )
                                // Token.T_COMMA ,
                                // Token.T_COLON :
                                // Token.T_SYMBOL
                                // Token.T_LBRACE {
                                // Token.T_INT int
                                // Token.T_REAL real
                                // Token.T_STRING string
                                // Token.T_OCTET octet
                                // Token.T_OMIT ...
                                // * や初期値などは調べてない
                                bool nextSymbol = true;
                                for( ; i < tokens_.Count; i++ ) {
                                    token = tokens_[i];
                                    if( token.Token == Token.T_RPARENTHESIS ) {	// )
                                        break;
                                    }
                                    if( nextSymbol && token.Token == Token.T_SYMBOL ) {
                                        n.Args.Add( (string)token.Value );
                                        nextSymbol = false;
                                    } else if( token.Token == Token.T_OMIT ) {
                                        n.Args.Add( "..." );
                                        nextSymbol = false;
                                    } else if( token.Token == Token.T_COMMA ) {
                                        nextSymbol = true;
                                    }
                                }

                            }
                        }
                        break;
                    case Token.T_FUNCTION:
                        type = Token.T_FUNCTION;
                        break;
                    case Token.T_PROPERTY:
                        type = Token.T_PROPERTY;
                        break;
                    case Token.T_CLASS:
                        type = Token.T_CLASS;
                        classNest.Push( nest );
                        break;
                    case Token.T_VAR:
                        type = Token.T_VAR;
                        break;
                    case Token.T_CONST:
                        type = Token.T_CONST;
                        break;
                    case Token.T_LBRACE:
                        nest++;
                        prevComment = false; type = 0;
                        break;
                    case Token.T_RBRACE:
                        nest--;
                        if( nest == classNest.Peek() ) {
                            // 現在のクラスノードが終了した
                            node.Pop();
                            classNest.Pop();
                            if( node.Count > 0 ) {
                                currentNode = node.Peek();
                            }
                        }
                        prevComment = false; type = 0;
                        break;
                    default:
                        prevComment = false; type = 0;
                        break;
                }
            }
            return topNode;
        }
Exemple #34
0
 /// <summary>
 /// Vector Index Assignment operator.
 /// </summary>
 /// <param name="VectorIndex">Vector Index</param>
 /// <param name="Operand">Operand.</param>
 /// <param name="Start">Start position in script expression.</param>
 /// <param name="Length">Length of expression covered by node.</param>
 /// <param name="Expression">Expression containing script.</param>
 public VectorIndexAssignment(VectorIndex VectorIndex, ScriptNode Operand, int Start, int Length, Expression Expression)
     : base(VectorIndex.LeftOperand, VectorIndex.RightOperand, Operand, Start, Length, Expression)
 {
 }
        public ScriptNode CompileScriptNode(string nodeName, string text, StringTable stringTable, Type self)
        {
            if (String.IsNullOrEmpty(text))
                throw new GossipScriptException("Script cannot be null or empty");

            var scriptletInfo = ScriptNodeParser.ParseScriptNode(text);

            var rv = new ScriptNode(nodeName);

            if (scriptletInfo.OnUpdateScript != null)
            {
                var tokens = Lexer.Tokenize(scriptletInfo.OnUpdateScript.EventScript).ToList();
                PopulateStringTable(tokens, stringTable);
                rv.OnUpdateEvent = new ScriptEvent(CompileEvent(tokens, self, stringTable), 0);
            }

            if (scriptletInfo.OnExitScript != null)
            {
                List<Token> tokens = Lexer.Tokenize(scriptletInfo.OnExitScript.EventScript).ToList();
                PopulateStringTable(tokens, stringTable);
                rv.OnEndEvent = new ScriptEvent(CompileEvent(tokens, self, stringTable), 0);
            }

            if (scriptletInfo.OnEnterScript != null)
            {
                List<Token> tokens = Lexer.Tokenize(scriptletInfo.OnEnterScript.EventScript).ToList();
                PopulateStringTable(tokens, stringTable);
                rv.OnStartEvent = new ScriptEvent(CompileEvent(tokens, self, stringTable), 0);
            }

            if (scriptletInfo.OnInterruptScript != null)
            {
                List<Token> tokens = Lexer.Tokenize(scriptletInfo.OnInterruptScript.EventScript).ToList();
                PopulateStringTable(tokens, stringTable);
                rv.OnInterruptEvent = new ScriptEvent(CompileEvent(tokens, self, stringTable), 0);
            }

            // Custom events
            foreach (ScriptNodeEventInfo customEvent in scriptletInfo.CustomEventScripts)
            {
                List<Token> tokens = Lexer.Tokenize(customEvent.EventScript).ToList();
                PopulateStringTable(tokens, stringTable);

                EventBinding binding = m_Engine.HostBridge.EventBindingTable.GetBindingByName(customEvent.Token.Value);
                var scriptletEvent =
                    new ScriptEvent(CompileEvent(tokens, self, stringTable, binding.EventParameterType), binding.Id);

                rv.OnCustomEvents.Add(scriptletEvent);
            }

            return rv;
        }
 public JuliaRoot2Variation(ScriptNode Parameter1, int Start, int Length, Expression Expression)
     : base(Parameter1, null, Start, Length, Expression)
 {
 }