Ejemplo n.º 1
0
 public ArrayInitNode(ExpressionNode[] Nodes, ArrayIndices[] Indices,
                      CodeString Code, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.Children = Nodes;
     this.Indices  = Indices;
 }
Ejemplo n.º 2
0
 public ObjectInitNode(IdentifierReference[] Members, ExpressionNode[] Nodes,
                       CodeString Code, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.Members  = Members;
     this.Children = Nodes;
 }
Ejemplo n.º 3
0
        ///////////////////////////////////////////////////////////////////////

        //
        // NOTE: For use by InteractiveOps.Commands._break() and
        //       Engine.CheckBreakpoints() only.
        //
        internal InteractiveLoopData(
            ReturnCode code,
            BreakpointType breakpointType,
            string breakpointName,
            IToken token,
            ITraceInfo traceInfo,
            EngineFlags engineFlags,
            SubstitutionFlags substitutionFlags,
            EventFlags eventFlags,
            ExpressionFlags expressionFlags,
            HeaderFlags headerFlags,
            IClientData clientData,
            ArgumentList arguments
            )
            : this()
        {
            this.code              = code;
            this.breakpointType    = breakpointType;
            this.breakpointName    = breakpointName;
            this.token             = token;
            this.traceInfo         = traceInfo;
            this.engineFlags       = engineFlags;
            this.substitutionFlags = substitutionFlags;
            this.eventFlags        = eventFlags;
            this.expressionFlags   = expressionFlags;
            this.headerFlags       = headerFlags;
            this.clientData        = clientData;
            this.arguments         = arguments;
        }
Ejemplo n.º 4
0
        internal AsynchronousContext(
            int threadId,
            EngineMode engineMode,
            Interpreter interpreter,
            string text,
            EngineFlags engineFlags,
            SubstitutionFlags substitutionFlags,
            EventFlags eventFlags,
            ExpressionFlags expressionFlags,
            AsynchronousCallback callback,
            IClientData clientData
            )
        {
            this.threadId = threadId;

            this.engineMode        = engineMode;
            this.interpreter       = interpreter;
            this.text              = text;
            this.engineFlags       = engineFlags;
            this.substitutionFlags = substitutionFlags;
            this.eventFlags        = eventFlags;
            this.expressionFlags   = expressionFlags;
            this.callback          = callback;
            this.clientData        = clientData;
        }
Ejemplo n.º 5
0
        ///////////////////////////////////////////////////////////////////////

        public static IScript Create(
            string name,
            string group,
            string description,
            string type,
            string text,
            string fileName,
            int startLine,
            int endLine,
            bool viaSource,
            DateTime timeStamp,
            EngineMode engineMode,
            ScriptFlags scriptFlags,
            EngineFlags engineFlags,
            SubstitutionFlags substitutionFlags,
            EventFlags eventFlags,
            ExpressionFlags expressionFlags,
            IClientData clientData
            )
        {
            return(PrivateCreate(
                       Guid.Empty, name, group, description, type, text, fileName,
                       startLine, endLine, viaSource,
#if XML
                       XmlBlockType.None, timeStamp, null, null,
#endif
                       engineMode, scriptFlags, engineFlags, substitutionFlags,
                       eventFlags, expressionFlags, clientData));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Build list of expression separated by comma
        /// </summary>
        /// <param name="lexemes">List of lexemes</param>
        /// <param name="pos">Position of current parsed lexeme</param>
        /// <param name="flags">Control flags. ExpressionFlags.None to ignore all flags</param>
        /// <param name="elements">Builded expressions</param>
        /// <returns>Position of a next lexeme</returns>
        private int ExtractSeparatedExpressions(List <Lexeme> lexemes, int pos, ExpressionFlags flags,
                                                out List <ValueElement> elements)
        {
            elements = new List <ValueElement>();
            ValueElement val;
            int          currentLevel = 1;

            ++pos; //skip '('

            for (int i = pos; currentLevel != 0 && i < lexemes.Count;)
            {
                switch (lexemes[i].Source)
                {
                case ";":
                    Compilation.WriteError("Unexpected symbol ';'. Did you forget ')' ?", lexemes[i].Line);
                    break;

                case "(":
                    ++currentLevel;
                    ++i;
                    continue;

                case ")":
                    --currentLevel;
                    if (currentLevel == 0)
                    {
                        pos = i = ParseExpression(lexemes, pos, i, flags & (~ExpressionFlags.OperationRequired)
                                                  | ExpressionFlags.AllowDefaultValue, out val) +
                                  1;
                        elements.Add(val);
                    }
                    else
                    {
                        ++i;
                    }
                    continue;

                case ",":
                    if (currentLevel == 1)
                    {
                        pos = i = ParseExpression(lexemes, pos, i, flags & (~ExpressionFlags.OperationRequired)
                                                  | ExpressionFlags.AllowDefaultValue, out val) +
                                  1;
                        elements.Add(val);
                    }
                    else
                    {
                        ++i;
                    }
                    break;

                default:
                    ++i;
                    break;
                }
            }
            return(pos);
        }
Ejemplo n.º 7
0
        protected IMatched <SkipTake> getSkipTake(ParseState state, ExpressionFlags flags)
        {
            var skipTake = new SkipTake();

            var noSkipMatch = state.Scan("^ /(|s|) /','", Color.Whitespace, Color.Structure);

            if (noSkipMatch.If(out _, out var _exception))
            {
            }
Ejemplo n.º 8
0
        ///////////////////////////////////////////////////////////////////////

        /* INTERNAL STATIC OK */
        internal static IScript CreateForPolicy(
            string name,
            string type,
            string text,
            EngineFlags engineFlags,
            SubstitutionFlags substitutionFlags,
            EventFlags eventFlags,
            ExpressionFlags expressionFlags
            )
        {
            return(Create(
                       name, null, null, type, text, TimeOps.GetUtcNow(),
                       EngineMode.EvaluateScript, ScriptFlags.None,
                       engineFlags, substitutionFlags, eventFlags,
                       expressionFlags, null));
        }
Ejemplo n.º 9
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        #region Protected Constructors
        //
        // NOTE: Sets up default values for the properties we use.  The MSBuild
        //       documentation is not entirely clear about whether or not having
        //       constructors is allowed; however, it does not appear to forbid
        //       them.
        //
        protected Script()
        {
            //
            // NOTE: Get the effective interpreter creation flags from the
            //       environment, etc.
            //
            createFlags = Interpreter.GetStartupCreateFlags(null,
                                                            DefaultCreateFlags, OptionOriginFlags.Standard, true, true);

            //
            // NOTE: By default, we do not want any special evaluation flags.
            //
            engineFlags = EngineFlags.None;

            //
            // NOTE: By default, we want all the substitution flags.
            //
            substitutionFlags = SubstitutionFlags.Default;

            //
            // NOTE: By default, we want to handle events targeted at the
            //       engine.
            //
            eventFlags = EventFlags.Default;

            //
            // NOTE: By default, we want all the expression flags.
            //
            expressionFlags = ExpressionFlags.Default;

            //
            // NOTE: By default, we do not want to allow "exceptional" (non-Ok)
            //       success return codes.
            //
            exceptions = false;

            //
            // NOTE: By default, we want to show the exception stack trace.
            //
            showStackTrace = true;
        }
Ejemplo n.º 10
0
        ///////////////////////////////////////////////////////////////////////

        private static IScript PrivateCreate(
            Guid id,
            string name,
            string group,
            string description,
            string type,
            string text,
            string fileName,
            int startLine,
            int endLine,
            bool viaSource,
#if XML
            XmlBlockType blockType,
            DateTime timeStamp,
            string publicKeyToken,
            byte[] signature,
#endif
            EngineMode engineMode,
            ScriptFlags scriptFlags,
            EngineFlags engineFlags,
            SubstitutionFlags substitutionFlags,
            EventFlags eventFlags,
            ExpressionFlags expressionFlags,
            IClientData clientData
            )
        {
            return(new Script(
                       id, name, group, description, type, text, fileName,
                       startLine, endLine, viaSource,
#if XML
                       blockType, timeStamp, publicKeyToken, signature,
#endif
#if CAS_POLICY
                       DefaultEvidence,
                       DefaultHashValue,
                       DefaultHashAlgorithm,
#endif
                       engineMode, scriptFlags, engineFlags, substitutionFlags,
                       eventFlags, expressionFlags, clientData));
        }
Ejemplo n.º 11
0
            ///////////////////////////////////////////////////////////////////

            private static ExpressionFlags GetExpressionFlags(
                NameValueCollection appSettings,
                ExpressionFlags @default
                )
            {
                try
                {
                    string value = Utility.GetEnvironmentVariable(
                        ExpressionFlags, true, true);

                    if (String.IsNullOrEmpty(value) && (appSettings != null))
                    {
                        value = appSettings[ExpressionFlags];
                    }

                    //
                    // NOTE: Were we able to get the value from somewhere?
                    //
                    if (!String.IsNullOrEmpty(value))
                    {
                        Result error = null;

                        object enumValue = Utility.TryParseFlagsEnum(
                            null, typeof(ExpressionFlags), @default.ToString(),
                            value, null, true, true, true, ref error);

                        if (enumValue is ExpressionFlags)
                        {
                            return((ExpressionFlags)enumValue);
                        }
                    }
                }
                catch
                {
                    // do nothing.
                }

                return(@default);
            }
Ejemplo n.º 12
0
        ///////////////////////////////////////////////////////////////////////

        public static IScript Create(
            string name,
            string group,
            string description,
            string type,
            string text,
            DateTime timeStamp,
            EngineMode engineMode,
            ScriptFlags scriptFlags,
            EngineFlags engineFlags,
            SubstitutionFlags substitutionFlags,
            EventFlags eventFlags,
            ExpressionFlags expressionFlags,
            IClientData clientData
            )
        {
            return(Create(
                       name, group, description, type, text, null, Parser.UnknownLine,
                       Parser.UnknownLine, false, timeStamp, engineMode, scriptFlags,
                       engineFlags, substitutionFlags, eventFlags, expressionFlags,
                       clientData));
        }
Ejemplo n.º 13
0
 private InteractiveLoopData(
     bool debug,
     IEnumerable <string> args,
     ReturnCode code,
     BreakpointType breakpointType,
     string breakpointName,
     IToken token,
     ITraceInfo traceInfo,
     EngineFlags engineFlags,
     SubstitutionFlags substitutionFlags,
     EventFlags eventFlags,
     ExpressionFlags expressionFlags,
     HeaderFlags headerFlags,
     IClientData clientData,
     ArgumentList arguments,
     bool exit
     )
 {
     this.kind              = IdentifierKind.InteractiveLoopData;
     this.id                = AttributeOps.GetObjectId(this);
     this.debug             = debug;
     this.args              = args;
     this.code              = code;
     this.breakpointType    = breakpointType;
     this.breakpointName    = breakpointName;
     this.token             = token;
     this.traceInfo         = traceInfo;
     this.engineFlags       = engineFlags;
     this.substitutionFlags = substitutionFlags;
     this.eventFlags        = eventFlags;
     this.expressionFlags   = expressionFlags;
     this.headerFlags       = headerFlags;
     this.clientData        = clientData;
     this.arguments         = arguments;
     this.exit              = exit;
 }
Ejemplo n.º 14
0
 public NamedParameterNode(CodeString Code, ExpressionNode Child, CodeString Name, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.Children = new ExpressionNode[] { Child };
     this.Name     = Name;
 }
Ejemplo n.º 15
0
 public ExpressionNode(CodeString Code, ExpressionFlags Flags = ExpressionFlags.None)
 {
     this.Code  = Code;
     this.Flags = Flags;
 }
Ejemplo n.º 16
0
 public InitializationNode(CodeString Code, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
 }
Ejemplo n.º 17
0
 public LabelExpressionNode(CodeString Code, string Label, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.Label = Label;
 }
Ejemplo n.º 18
0
 public OpExpressionNode(CodeString Code, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.Operator = Operator.Unknown;
     this.Children = null;
 }
Ejemplo n.º 19
0
 public LinkingNode(LinkedExprNode Node, CodeString Code, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.LinkedNode = Node;
 }
Ejemplo n.º 20
0
 public IdExpressionNode(Identifier Identifier, CodeString Code, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.Identifier = Identifier;
 }
Ejemplo n.º 21
0
 public OpExpressionNode(Operator Operator, ExpressionNode[] Children, CodeString Code, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.Operator = Operator;
     this.Children = Children;
 }
Ejemplo n.º 22
0
 public StrExpressionNode(CodeString Code, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
 }
Ejemplo n.º 23
0
 public DataPointerNode(CodeString Code, Assembly Assembly, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.DescPointerType = DataPointerType.Assembly;
     this.Assembly        = Assembly;
 }
Ejemplo n.º 24
0
 public DataPointerNode(CodeString Code, Identifier Id, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.DescPointerType = DataPointerType.Identifier;
     this.Id = Id;
 }
Ejemplo n.º 25
0
 public DataPointerNode(CodeString Code, IncludedBinary IncBin, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.DescPointerType = DataPointerType.IncBin;
     this.IncBin          = IncBin;
 }
Ejemplo n.º 26
0
 public DataPointerNode(CodeString Code, DataPointerType Type, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.DescPointerType = Type;
 }
Ejemplo n.º 27
0
        ///////////////////////////////////////////////////////////////////////

#if XML
        /* INTERNAL STATIC OK */
        internal static IScript CreateFromXmlNode( /* NOTE: Engine use only. */
            string type,
            XmlNode node,
            EngineMode engineMode,
            ScriptFlags scriptFlags,
            EngineFlags engineFlags,
            SubstitutionFlags substitutionFlags,
            EventFlags eventFlags,
            ExpressionFlags expressionFlags,
            IClientData clientData,
            ref Result error
            )
        {
            try
            {
                XmlElement element = node as XmlElement;

                if (element != null)
                {
                    foreach (string attribute in _XmlAttribute.RequiredList)
                    {
                        if ((attribute != null) && !element.HasAttribute(attribute))
                        {
                            error = String.Format(
                                "missing required attribute \"{0}\"",
                                attribute);

                            return(null);
                        }
                    }

                    /* REQUIRED */
                    Guid id = element.HasAttribute(_XmlAttribute.Id) ?
                              new Guid(element.GetAttribute(_XmlAttribute.Id)) : Guid.Empty;

                    /* REQUIRED */
                    XmlBlockType blockType = element.HasAttribute(_XmlAttribute.Type) ?
                                             (XmlBlockType)Enum.Parse(typeof(XmlBlockType),
                                                                      element.GetAttribute(_XmlAttribute.Type), true) :
                                             XmlBlockType.None;

                    /* REQUIRED */
                    string text = element.InnerText;

                    /* OPTIONAL */
                    string name = element.HasAttribute(_XmlAttribute.Name) ?
                                  element.GetAttribute(_XmlAttribute.Name) : null;

                    /* OPTIONAL */
                    string group = element.HasAttribute(_XmlAttribute.Group) ?
                                   element.GetAttribute(_XmlAttribute.Group) : null;

                    /* OPTIONAL */
                    string description = element.HasAttribute(_XmlAttribute.Description) ?
                                         element.GetAttribute(_XmlAttribute.Description) : null;

                    /* OPTIONAL */
                    DateTime timeStamp = element.HasAttribute(_XmlAttribute.TimeStamp) ?
                                         DateTime.Parse(element.GetAttribute(_XmlAttribute.TimeStamp)).ToUniversalTime() :
                                         DateTime.MinValue;

                    /* OPTIONAL */
                    string publicKeyToken = element.HasAttribute(_XmlAttribute.PublicKeyToken) ?
                                            element.GetAttribute(_XmlAttribute.PublicKeyToken) : null;

                    /* OPTIONAL */
                    byte[] signature = element.HasAttribute(_XmlAttribute.Signature) ?
                                       Convert.FromBase64String(
                        element.GetAttribute(_XmlAttribute.Signature)) : null;

                    //
                    // NOTE: Create the script using the values extracted from the XML element.
                    //
                    return(PrivateCreate(
                               id, name, group, description, type, text, null, Parser.UnknownLine,
                               Parser.UnknownLine, false, blockType, timeStamp, publicKeyToken,
                               signature, engineMode, scriptFlags, engineFlags, substitutionFlags,
                               eventFlags, expressionFlags, clientData));
                }
                else
                {
                    error = "xml node is not an element";
                }
            }
            catch (Exception e)
            {
                error = e;
            }

            return(null);
        }
Ejemplo n.º 28
0
 public MacroExpressionNode(Macro Macro, CodeString Code, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.Macro = Macro;
 }
Ejemplo n.º 29
0
        ///////////////////////////////////////////////////////////////////////

        #region Private Constructors
        private Script(
            Guid id,
            string name,
            string group,
            string description,
            string type,
            string text,
            string fileName,
            int startLine,
            int endLine,
            bool viaSource,
#if XML
            XmlBlockType blockType,
            DateTime timeStamp,
            string publicKeyToken,
            byte[] signature,
#endif
#if CAS_POLICY
            Evidence evidence,
            byte[] hashValue,
            HashAlgorithm hashAlgorithm,
#endif
            EngineMode engineMode,
            ScriptFlags scriptFlags,
            EngineFlags engineFlags,
            SubstitutionFlags substitutionFlags,
            EventFlags eventFlags,
            ExpressionFlags expressionFlags,
            IClientData clientData
            )
        {
            this.kind        = IdentifierKind.Script;
            this.id          = id;
            this.name        = name;
            this.group       = group;
            this.description = description;
            this.type        = type;
            this.parts       = null; /* TODO: If we ever support scripts with multiple
                                      *       parts, change this to be a formal argument
                                      *       to this constructor and remove text? */
            this.text        = text;
            this.fileName    = fileName;
            this.startLine   = startLine;
            this.endLine     = endLine;
            this.viaSource   = viaSource;

#if XML
            this.blockType      = blockType;
            this.timeStamp      = timeStamp;
            this.publicKeyToken = publicKeyToken;
            this.signature      = signature;
#endif

#if CAS_POLICY
            this.evidence      = evidence;
            this.hashValue     = hashValue;
            this.hashAlgorithm = hashAlgorithm;
#endif

            this.engineMode        = engineMode;
            this.scriptFlags       = scriptFlags;
            this.engineFlags       = engineFlags;
            this.substitutionFlags = substitutionFlags;
            this.expressionFlags   = expressionFlags;
            this.eventFlags        = eventFlags;
            this.clientData        = clientData;
        }
Ejemplo n.º 30
0
 public MacroArgNode(int Index, CodeString Code, ExpressionFlags Flags = ExpressionFlags.None)
     : base(Code, Flags)
 {
     this.Index = Index;
 }