Example #1
0
 public static bool IsGetTypeMethod(string methodName)
 {
     Validity.Assert(!string.IsNullOrEmpty(methodName));
     return(methodName.Equals(DSDefinitions.Keyword.GetType));
 }
Example #2
0
 public static bool IsPropertyTemp(string varname)
 {
     Validity.Assert(!string.IsNullOrEmpty(varname));
     return(varname.StartsWith(DSASM.Constants.kTempPropertyVar));
 }
Example #3
0
 public static bool IsGetterSetter(string propertyName)
 {
     Validity.Assert(null != propertyName);
     return(IsGetter(propertyName) || IsSetter(propertyName));
 }
Example #4
0
 public static bool IsInternalFunction(string methodName)
 {
     Validity.Assert(!string.IsNullOrEmpty(methodName));
     return(methodName.StartsWith(DSASM.Constants.kInternalNamePrefix) || methodName.StartsWith(DSDefinitions.Keyword.Dispose));
 }
Example #5
0
 public static bool IsInternalMethod(string methodName)
 {
     Validity.Assert(null != methodName);
     return(methodName.StartsWith(Constants.kInternalNamePrefix));
 }
Example #6
0
 public static bool StartsWithDoubleUnderscores(string name)
 {
     Validity.Assert(null != name);
     return(name.StartsWith(DSASM.Constants.kDoubleUnderscores));
 }
Example #7
0
 public static bool IsSetter(string propertyName)
 {
     Validity.Assert(null != propertyName);
     return(propertyName.StartsWith(DSASM.Constants.kSetterPrefix));
 }
Example #8
0
 public static bool IsAutoGeneratedVar(string name)
 {
     Validity.Assert(null != name);
     return(name.StartsWith("%"));
 }
Example #9
0
        private static void ParseUserCodeCore(Core core, string expression, out List <AssociativeNode> astNodes, out List <AssociativeNode> commentNodes)
        {
            astNodes = new List <AssociativeNode>();

            core.ResetForPrecompilation();
            core.IsParsingCodeBlockNode = true;
            core.ParsingMode            = ParseMode.AllowNonAssignment;

            ParseResult parseResult = ParserUtils.ParseWithCore(expression, core);

            commentNodes = ParserUtils.GetAstNodes(parseResult.CommentBlockNode);
            var nodes = ParserUtils.GetAstNodes(parseResult.CodeBlockNode);

            Validity.Assert(nodes != null);

            int index           = 0;
            int typedIdentIndex = 0;

            foreach (var node in nodes)
            {
                var n = node as AssociativeNode;
                Validity.Assert(n != null);

                // Append the temporaries only if it is not a function def or class decl
                bool isFunctionOrClassDef = n is FunctionDefinitionNode || n is ClassDeclNode;

                // Handle non Binary expression nodes separately
                if (n is ModifierStackNode)
                {
                    core.BuildStatus.LogSemanticError(Resources.ModifierBlockNotSupported);
                }
                else if (n is ImportNode)
                {
                    core.BuildStatus.LogSemanticError(Resources.ImportStatementNotSupported);
                }
                else if (isFunctionOrClassDef)
                {
                    // Add node as it is
                    astNodes.Add(node);
                }
                else
                {
                    // Handle temporary naming for temporary Binary exp. nodes and non-assignment nodes
                    var ben = node as BinaryExpressionNode;
                    if (ben != null && ben.Optr == Operator.assign)
                    {
                        var mNode = ben.RightNode as ModifierStackNode;
                        if (mNode != null)
                        {
                            core.BuildStatus.LogSemanticError(Resources.ModifierBlockNotSupported);
                        }
                        var lNode = ben.LeftNode as IdentifierNode;
                        if (lNode != null && lNode.Value == Constants.kTempProcLeftVar)
                        {
                            string name    = Constants.kTempVarForNonAssignment + index;
                            var    newNode = new BinaryExpressionNode(new IdentifierNode(name), ben.RightNode);
                            astNodes.Add(newNode);
                            index++;
                        }
                        else
                        {
                            // Add node as it is
                            astNodes.Add(node);
                            index++;
                        }
                    }
                    else
                    {
                        if (node is TypedIdentifierNode)
                        {
                            // e.g. a : int = %tTypedIdent_<Index>;
                            var ident = new IdentifierNode(Constants.kTempVarForTypedIdentifier + typedIdentIndex);
                            NodeUtils.CopyNodeLocation(ident, node);
                            var typedNode = new BinaryExpressionNode(node as TypedIdentifierNode, ident, Operator.assign);
                            NodeUtils.CopyNodeLocation(typedNode, node);
                            astNodes.Add(typedNode);
                            typedIdentIndex++;
                        }
                        else
                        {
                            string name    = Constants.kTempVarForNonAssignment + index;
                            var    newNode = new BinaryExpressionNode(new IdentifierNode(name), n);
                            astNodes.Add(newNode);
                            index++;
                        }
                    }
                }
            }
        }