Пример #1
0
        private CStatementBlock cases; // this will be a vector of case objects

        public CSelect(CToken token, CExpression pivot)
            : base(token)
        {
            cases = new CStatementBlock();
            this.pivot = pivot;
            pivot.Parent = this;
        }
Пример #2
0
 public CUnaryOperator(CToken tok, CExpression rhs)
     : base(tok)
 {
     action = tok;
     this.rhs = rhs;
     rhs.Parent = this;
 }
Пример #3
0
 public CUnionType(CToken token)
     : base(token, "__Unamed_Union" + unnamedCount++)
 {
     CProgram.Global.AddClass(base.Name, this);
     NameToken = CToken.Identifer(token, "", "");
     IsObject = false;
 }
Пример #4
0
 public CNew(CToken tok, CToken classname, CParameters @params)
     : base(tok, classname)
 {
     this.classname      = classname;
     this.@params        = @params;
     [email protected] = this;
 }
Пример #5
0
 public CUnaryOperator(CToken tok, CExpression rhs)
     : base(tok)
 {
     action     = tok;
     this.rhs   = rhs;
     rhs.Parent = this;
 }
Пример #6
0
 public CAccess(CToken tok, CToken item)
     : base(tok)
 {
     referenceToken = item;
     isMemberSource = false;
     isRootAccess = true;
 }
Пример #7
0
        /// <summary>Creates a new instance of CFunction
        /// this one is for funcs and subs that are parts of classes.  this means
        /// that they can be public or private.  also, we track if they are subs or funcs as this has
        /// implications with how exit/return is used
        /// </summary>
        public CFunction(CToken token, string rawname, string name, TokenTypes visibility, FunctionType subFuncFlag,
                         CArgumentList args, CTypeRef tref)
            : base(token)
        {
            funcName        = name;
            rawFuncName     = rawname;
            this.visibility = visibility;
            functionType    = subFuncFlag;
            LoadType(tref);

            if (args != null)
            {
                arguments = args;
            }

            switch (functionType)
            {
            case vbPropertyGet:
                alias = "get_" + rawname;
                break;

            case vbPropertySet:
                alias = "set_" + rawname;
                break;

            case vbSub:
            case vbFunction:
            default:
                alias = rawname;
                break;
            }
        }
Пример #8
0
        private CStatementBlock cases; // this will be a vector of case objects

        public CSelect(CToken token, CExpression pivot)
            : base(token)
        {
            cases        = new CStatementBlock();
            this.pivot   = pivot;
            pivot.Parent = this;
        }
Пример #9
0
        private bool elseCaseFlag;          // flag indicating if this case is the default case


        // if statements is null, that means there are no statements.  meaning this case uses the statements
        // of the case below it.  so dont put a break point.  eg:
        //  switch (color) {
        //      case (red):
        //      case (blue):
        //          print("its red or blue);
        //          break;
        //
        public CCase(CToken token, CExpression val)
            : base(token)
        {
            m_value        = val;
            m_value.Parent = this;
            statements     = null;
        }
Пример #10
0
 public CNew(CToken tok, CToken classname, CParameters @params)
     : base(tok, classname)
 {
     this.classname = classname;
     this.@params = @params;
     [email protected] = this;
 }
Пример #11
0
 public CAccess(CToken tok, CToken item)
     : base(tok)
 {
     referenceToken = item;
     isMemberSource = false;
     isRootAccess   = true;
 }
Пример #12
0
        private CStatementBlock statements; // the statements to be executed in this case of the switch

        #endregion Fields

        #region Constructors

        // if statements is null, that means there are no statements.  meaning this case uses the statements
        // of the case below it.  so dont put a break point.  eg:
        //  switch (color) {
        //      case (red):
        //      case (blue):
        //          print("its red or blue);
        //          break;
        //
        public CCase(CToken token, CExpression val)
            : base(token)
        {
            m_value = val;
            m_value.Parent = this;
            statements = null;
        }
Пример #13
0
 public CUnionType(CToken token, String rawname, String name)
     : base(token, "__Unamed_Union" + unnamedCount++)
 {
     CProgram.Global.AddClass(base.Name, this);
     NameToken = CToken.Identifer(token, name, rawname);
     CProgram.Global.AddClass(base.Name, this);
 }
Пример #14
0
 public CUnionType(CToken token, String rawname, String name)
     : base(token, "__Unamed_Union" + unnamedCount++)
 {
     CProgram.Global.AddClass(base.Name, this);
     NameToken = CToken.Identifer(token, name, rawname);
     CProgram.Global.AddClass(base.Name, this);
 }
Пример #15
0
 public CConst(CToken token, CToken name, CExpression exp)
     : base(token)
 {
     constName         = name;
     constValue        = exp;
     constValue.Parent = this;
 }
Пример #16
0
 public CUnionType(CToken token)
     : base(token, "__Unamed_Union" + unnamedCount++)
 {
     CProgram.Global.AddClass(base.Name, this);
     NameToken = CToken.Identifer(token, "", "");
     IsObject  = false;
 }
Пример #17
0
 public CConst(CToken token, CToken name, CExpression exp)
     : base(token)
 {
     constName = name;
     constValue = exp;
     constValue.Parent = this;
 }
Пример #18
0
 public CArgument(CToken direction, CToken name, CTypeRef tref)
     : base(name)
 {
     this.direction = direction;
     this.name = name;
     base.LoadType(tref);
 }
Пример #19
0
 public CArgument(CToken direction, CToken name, CTypeRef tref)
     : base(name)
 {
     this.direction = direction;
     this.name      = name;
     base.LoadType(tref);
 }
Пример #20
0
 public CMember(CToken tok, string name, string memberType, int declaredSize, bool isUnionMember)
     : base(tok)
 {
     this.name          = name;
     this.memberType    = memberType;
     declared           = new CNode[declaredSize];
     this.isUnionMember = isUnionMember;
 }
Пример #21
0
 public CIf(CToken token, CExpression condition, bool oneLine, bool elseIf)
     : base(token)
 {
     this.condition = condition;
     condition.Parent = this;
     oneLineFlag = oneLine;
     elseIfFlag = elseIf;
 }
Пример #22
0
 public static CToken Keyword(CToken @src, String keyword)
 {
     if (src == null)
     {
         src = Empty;
     }
     return(new CToken(src.filename, src.line, src.offset, src.fullLine, TokenTypes.keyword, keyword.ToLower(), keyword, true));
 }
Пример #23
0
 public CAttribute(CToken name, CParameters parameters, CTypeRef ctr)
     : base(name)
 {
     this.name = name.Value;
     nameToken = name;
     this.parameters = parameters ?? new CParameters();
     LoadType(new CTypeRef(this, ctr));
 }
Пример #24
0
 public CAttribute(CToken name, CParameters parameters, CTypeRef ctr)
     : base(name)
 {
     this.name       = name.Value;
     nameToken       = name;
     this.parameters = parameters ?? new CParameters();
     LoadType(new CTypeRef(this, ctr));
 }
Пример #25
0
 internal static CToken String(CToken @src, string alias)
 {
     if (src == null)
     {
         src = Empty;
     }
     return(new CToken(src.filename, src.line, src.offset, src.fullLine, TokenTypes.str, alias, alias, true));
 }
Пример #26
0
 public CMemberAccess(CToken tok, CAccess objectSource, CToken item)
     : base(tok, item)
 {
     _object = objectSource;
     _object.Parent = this;
     _object.IsMemberSource = true;
     IsRootAccess = false;
 }
Пример #27
0
 public static CToken Identifer(CToken @src, String ident, String rawIdent)
 {
     if (src == null)
     {
         src = Empty;
     }
     return(new CToken(src.filename, src.line, src.offset, src.fullLine, TokenTypes.identifier, ident, rawIdent, true));
 }
Пример #28
0
 public CMemberAccess(CToken tok, CAccess objectSource, CToken item)
     : base(tok, item)
 {
     _object                = objectSource;
     _object.Parent         = this;
     _object.IsMemberSource = true;
     IsRootAccess           = false;
 }
Пример #29
0
 public CIf(CToken token, CExpression condition, bool oneLine, bool elseIf)
     : base(token)
 {
     this.condition   = condition;
     condition.Parent = this;
     oneLineFlag      = oneLine;
     elseIfFlag       = elseIf;
 }
Пример #30
0
 public CExit(CToken token, String exitWhat)
     : base(token)
 {
     this.exitWhat = exitWhat;
     if (exitWhat == "function")
         funcFlag = true;
     else if (exitWhat == "sub")
         subFlag = true;
 }
Пример #31
0
 public CBinaryOperator(CToken tok, CExpression lhs, CExpression rhs)
     : base(tok)
 {
     operation = tok;
     this.lhs = lhs;
     this.rhs = rhs;
     lhs.Parent = this;
     rhs.Parent = this;
 }
Пример #32
0
 public CBinaryOperator(CToken tok, CExpression lhs, CExpression rhs)
     : base(tok)
 {
     operation  = tok;
     this.lhs   = lhs;
     this.rhs   = rhs;
     lhs.Parent = this;
     rhs.Parent = this;
 }
Пример #33
0
 // this is the constructor when you actually need to parse all the statements of a case
 // until you hit the next case
 public CCase(CToken token, CExpression val, CStatementBlock block)
     : base(token)
 {
     m_value = val;
     elseCaseFlag = val == null;
     if (!elseCaseFlag)
         m_value.Parent = this;
     statements = block;
 }
Пример #34
0
        public CConstantExpression(CToken tok)
            : base(tok)
        {
            m_value = tok;
            CClass type = null;

            switch (tok.TokenType)
            {
            case TokenTypes.number:
                int i;
                if (Int32.TryParse(tok.Value, out i) || tok.Value.StartsWith("0x"))
                {
                    type = BuiltIns.Int32;
                }
                else
                {
                    type = BuiltIns.Double;
                }
                break;

            case TokenTypes.str:
                type = BuiltIns.String;
                break;

            case TokenTypes.character:
                type = BuiltIns.Character;
                break;

            case TokenTypes.pound:
                type = BuiltIns.Date;
                break;

            case TokenTypes.keyword:
                if (tok.Value == "true")
                {
                    type = BuiltIns.Boolean;
                }
                else if (tok.Value == "false")
                {
                    type = BuiltIns.Boolean;
                }
                else if (tok.Value == "nothing")
                {
                    type = BuiltIns.Nothing;
                }
                else if (tok.Value == "dbnull")
                {
                    type = BuiltIns.DbNull;
                }
                break;
            }
            if (type != null)
            {
                base.LoadType(type);
            }
        }
Пример #35
0
 public CDefaultAccess(CToken tok, CAccess item, CParameters parameters)
     : base(tok, tok)
 {
     m_targetAccess = item;
     m_targetAccess.Parent = this;
     this.parameters = parameters;
     this.parameters.Parent = this;
     item.IsCallExplicit = true;
     IsRootAccess = false;
 }
Пример #36
0
 public CDefaultAccess(CToken tok, CAccess item, CParameters parameters)
     : base(tok, tok)
 {
     m_targetAccess         = item;
     m_targetAccess.Parent  = this;
     this.parameters        = parameters;
     this.parameters.Parent = this;
     item.IsCallExplicit    = true;
     IsRootAccess           = false;
 }
Пример #37
0
        public CClass(CToken token, String rawname, String name, CTypeRef baseClass)
            : base(token)
        {
            originalClassName  = name;
            className          = CToken.Identifer(token, name, rawname);
            canConvertToString = false;

            this.baseClass = new CTypeRef(this, baseClass);
            base.LoadType(this);
        }
Пример #38
0
        public CTernary(CToken tok, CExpression cond, CExpression lhs, CExpression rhs)
            : base(tok)
        {
            this.cond = cond;
            this.lhs  = lhs;
            this.rhs  = rhs;

            cond.Parent = this;
            lhs.Parent  = this;
            rhs.Parent  = this;
        }
Пример #39
0
        public CTernary(CToken tok, CExpression cond, CExpression lhs, CExpression rhs)
            : base(tok)
        {
            this.cond = cond;
            this.lhs = lhs;
            this.rhs = rhs;

            cond.Parent = this;
            lhs.Parent = this;
            rhs.Parent = this;
        }
Пример #40
0
 // this is the constructor when you actually need to parse all the statements of a case
 // until you hit the next case
 public CCase(CToken token, CExpression val, CStatementBlock block)
     : base(token)
 {
     m_value      = val;
     elseCaseFlag = val == null;
     if (!elseCaseFlag)
     {
         m_value.Parent = this;
     }
     statements = block;
 }
Пример #41
0
 public CVariable(CToken name, bool shared, CTypeRef tref, CParameters arrayDimsinit, CExpression init, CDim parent)
     : base(name, shared)
 {
     this.dim = parent;
     this.name = name;
     base.LoadType(tref);
     this.init = init;
     if (init != null)
         init.Parent = this;
     member = false;
     this.arrayDimsinit = arrayDimsinit;
 }
Пример #42
0
 public CLambdaFunction(CToken token, CFunction containingFunction, CFile containingFile, String name, CTypeRef tref,
                        CArgumentList args)
     : base(token, name, name, TokenTypes.visInternal, FunctionType.Function, args, tref)
 {
     this.containingFunction = containingFunction;
     this.containingFile = containingFile;
     if (this.containingFunction != null)
         this.containingFunction.Lambdas.Add(this);
     else
         this.containingFile.Lambdas.Add(this);
     CallCount++;
     Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
 }
Пример #43
0
 public CExit(CToken token, String exitWhat)
     : base(token)
 {
     this.exitWhat = exitWhat;
     if (exitWhat == "function")
     {
         funcFlag = true;
     }
     else if (exitWhat == "sub")
     {
         subFlag = true;
     }
 }
Пример #44
0
        private CProgram()
            : base(null)
        {
            global = this;

            classes["String"]    = BuiltIns.String;
            classes["Int32"]     = BuiltIns.Int32;
            classes["Int64"]     = BuiltIns.Int32;
            classes["Character"] = BuiltIns.Character;
            classes["Boolean"]   = BuiltIns.Boolean;
            classes["Date"]      = BuiltIns.Date;
            classes["Double"]    = BuiltIns.Double;

            classes["__Object"]  = BuiltIns.Object;
            classes["__Variant"] = BuiltIns.Variant;

            // lowercase alias
            classes["byte"]      = BuiltIns.Byte;
            classes["string"]    = BuiltIns.String;
            classes["int32"]     = BuiltIns.Int32;
            classes["int64"]     = BuiltIns.Int32;
            classes["character"] = BuiltIns.Character;
            classes["boolean"]   = BuiltIns.Boolean;
            classes["date"]      = BuiltIns.Date;
            classes["double"]    = BuiltIns.Double;
            classes["object"]    = BuiltIns.Object;
            classes["variant"]   = BuiltIns.Variant;

            classes["DbNull"]  = BuiltIns.DbNull;
            classes["dbnull"]  = BuiltIns.DbNull;
            classes["Nothing"] = BuiltIns.Nothing;

            classes["__Void"] = BuiltIns.Void;

            foreach (KeyValuePair <string, CClass> e in classes)
            {
                e.Value.SetSemanticallyComplete();
                universalClasses[e.Key] = e.Value;
            }

            // Add valueOf method to Date object
            CFunction valueOf = new CFunction(new CToken("", 1, 0, "", TokenTypes.identifier, "valueof", "valueOf", true),
                                              "valueOf", "valueof", TokenTypes.visPublic, FunctionType.Function, new CArgumentList(),
                                              new CTypeRef(null, BuiltIns.Int32));

            valueOf.Attributes.Add(CToken.Identifer(valueOf.Token, "suppressusagewarning"), new CTypeRef(null, CToken.Identifer(valueOf.Token, "SuppressUsageWarningAttribute")));
            valueOf.Attributes.Add(CToken.Identifer(valueOf.Token, "executeonclient"), new CTypeRef(null, CToken.Identifer(valueOf.Token, "ExecuteOnClientAttribute")));
            valueOf.Class = BuiltIns.Date;
            BuiltIns.Date.SetMember("valueof", new CMethod(valueOf));
        }
Пример #45
0
 public CVariable(CToken name, bool shared, CTypeRef tref, CParameters arrayDimsinit, CExpression init, CDim parent)
     : base(name, shared)
 {
     this.dim  = parent;
     this.name = name;
     base.LoadType(tref);
     this.init = init;
     if (init != null)
     {
         init.Parent = this;
     }
     member             = false;
     this.arrayDimsinit = arrayDimsinit;
 }
Пример #46
0
 public CLambdaFunction(CToken token, CFunction containingFunction, CFile containingFile, String name, CTypeRef tref,
                        CArgumentList args)
     : base(token, name, name, TokenTypes.visInternal, FunctionType.Function, args, tref)
 {
     this.containingFunction = containingFunction;
     this.containingFile     = containingFile;
     if (this.containingFunction != null)
     {
         this.containingFunction.Lambdas.Add(this);
     }
     else
     {
         this.containingFile.Lambdas.Add(this);
     }
     CallCount++;
     Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
 }
Пример #47
0
 public virtual void Add(CTypeRef tref)
 {
     if (tref.Resolved && tref.ActualType is CUnionType)
     {
         Add((CUnionType)tref.ActualType);
     }
     else
     {
         string prefix = " Or ";
         if (Name == "")
         {
             prefix = "";
         }
         NameToken =
             CToken.Identifer(NameToken, Name + prefix + tref.TypeName.Value,
                              RawName + prefix + tref.TypeName.RawValue);
         types.Add(new CTypeRef(this, tref));
     }
 }
Пример #48
0
        public CClass FindClass(CToken name, bool searchImports)
        {
            CClass result = null;

            CFile file = null;

            if (name.Filename != null)
            {
                fileMap.TryGetValue(name.Filename, out file);
            }

            // first look to see if the type has been renamed
            CToken newName;

            if (file != null && file.ClassNameAliases.TryGetValue(name.RawValue, out newName))
            {
                name = newName;
            }

            // Try to find the class the normal way
            if (result == null)
            {
                result = InternalFindClass(name.RawValue, name.Value, searchImports);
            }

            // Look in the namespace mapping
            if (result == null && file != null)
            {
                foreach (var prefix in file.NameSpaceResolutionPrefixes)
                {
                    result = InternalFindClass(
                        prefix.RawValue + "." + name.RawValue,
                        prefix.Value + "." + name.Value,
                        searchImports);
                    if (result != null)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Пример #49
0
        public CFunctionType(CToken token, CFunction function, bool declarationOnly)
            : base(token, function.TypeSignature)
        {
            target = function;
            this.declarationOnly = declarationOnly;

            CMethod method = new CMethod(function);
            DefaultMember = method;

            function.TypeChanged += new EventHandler(function_TypeChanged);
            foreach (CArgument arg in function.Arguments)
                arg.TypeChanged += new EventHandler(function_TypeChanged);

            this.IsSealed = true;

            // we don't actually want people accessing the default method directly
            // we also don't want it to get visited through the type.
            // so we don't do this: Members.Add(function.Name, method);
            Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
        }
        public CConstantExpression(CToken tok)
            : base(tok)
        {
            m_value = tok;
            CClass type = null;
            switch (tok.TokenType)
            {
                case TokenTypes.number:
                    int i;
                    if (Int32.TryParse(tok.Value, out i) || tok.Value.StartsWith("0x"))
                        type = BuiltIns.Int32;
                    else
                        type = BuiltIns.Double;
                    break;

                case TokenTypes.str:
                    type = BuiltIns.String;
                    break;

                case TokenTypes.character:
                    type = BuiltIns.Character;
                    break;

                case TokenTypes.pound:
                    type = BuiltIns.Date;
                    break;

                case TokenTypes.keyword:
                    if (tok.Value == "true")
                        type = BuiltIns.Boolean;
                    else if (tok.Value == "false")
                        type = BuiltIns.Boolean;
                    else if (tok.Value == "nothing")
                        type = BuiltIns.Nothing;
                    else if (tok.Value == "dbnull")
                        type = BuiltIns.DbNull;
                    break;
            }
            if (type != null)
                base.LoadType(type);
        }
Пример #51
0
        public CFunctionType(CToken token, CFunction function, bool declarationOnly)
            : base(token, function.TypeSignature)
        {
            target = function;
            this.declarationOnly = declarationOnly;

            CMethod method = new CMethod(function);

            DefaultMember = method;

            function.TypeChanged += new EventHandler(function_TypeChanged);
            foreach (CArgument arg in function.Arguments)
            {
                arg.TypeChanged += new EventHandler(function_TypeChanged);
            }

            this.IsSealed = true;

            // we don't actually want people accessing the default method directly
            // we also don't want it to get visited through the type.
            // so we don't do this: Members.Add(function.Name, method);
            Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
        }
Пример #52
0
 public CProperty(CToken token, string name)
     : base(token, name, "property", 3, false)
 {
 }
Пример #53
0
 /// <summary>
 /// Create a new Try-Catch-Finally block.
 /// </summary>
 /// <param name="token">The token defining the Try</param>
 public CTry(CToken token)
     : base(token)
 {
 }
Пример #54
0
 public CDirective(CToken token)
     : base(token)
 {
 }
Пример #55
0
 public COptionalByRef(CToken tok)
     : base(tok)
 {
     this.IsPassedByRef = true;
 }
Пример #56
0
 public CDo(CToken token)
     : base(token)
 {
 }
Пример #57
0
 public CComparison(CToken tok, CExpression lhs, CExpression rhs)
     : base(tok, lhs, rhs)
 {
     base.LoadType(BuiltIns.Boolean);
 }
Пример #58
0
 protected CNode()
 {
     type = new CTypeRef(this);
     token = null;
     lock (allNodes) allNodes.Add(this);
 }
Пример #59
0
 protected CNode(CToken token)
 {
     type = new CTypeRef(this);
     this.token = token;
     lock (allNodes) allNodes.Add(this);
 }
Пример #60
0
 public CIgnore(CToken token)
     : base(token)
 {
 }