Ejemplo n.º 1
0
        public TryStatement(
            Token tryToken,
            Executable[] tryCode,
            IList <Token> catchTokens,
            IList <CSharpType> catchBlockTypes,
            IList <Token> catchBlockVariables,
            IList <Executable[]> catchBlockCode,
            Token finallyToken,
            Executable[] finallyCode,
            TopLevelEntity parent)
            : base(tryToken, parent)
        {
            this.TryCode = tryCode;
            List <CatchBlock> catches = new List <CatchBlock>();

            for (int i = 0; i < catchBlockCode.Count; ++i)
            {
                catches.Add(new CatchBlock()
                {
                    CatchToken        = catchTokens[i],
                    ExceptionType     = catchBlockTypes[i],
                    ExceptionVariable = catchBlockVariables[i],
                    Code = catchBlockCode[i],
                });
            }
            this.CatchBlocks  = catches.ToArray();
            this.FinallyToken = finallyToken;
            this.FinallyCode  = finallyCode;
        }
Ejemplo n.º 2
0
        internal static Expression AttemptToResolveDotFieldChainIntoDirectReference(IList <Token> chain, ParserContext context, Expression scope)
        {
            CSharpType   cst           = CSharpType.Fabricate(chain);
            ResolvedType existingThing = scope.DoTypeLookupFailSilently(cst, context);

            if (existingThing != null)
            {
                if (existingThing.IsEnum)
                {
                    return(new EnumDefinitionReference(scope.FirstToken, scope.Parent, existingThing));
                }
                else if (existingThing.CustomType != null)
                {
                    TopLevelEntity tle = existingThing.CustomType;
                    if (tle is ClassLikeDefinition)
                    {
                        return(new StaticClassReference(scope.FirstToken, scope.Parent, (ClassLikeDefinition)tle));
                    }
                    else
                    {
                        throw new System.NotImplementedException();
                    }
                }
                else if (existingThing.FrameworkClass != null)
                {
                    return(new StaticFrameworkClassReference(scope.FirstToken, scope.Parent, existingThing));
                }
                else
                {
                    throw new System.NotImplementedException();
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
 public InterfaceDefinition(
     Token firstToken,
     Dictionary <string, Token> modifiers,
     Token classToken,
     Token classNameToken,
     List <CSharpType> subClassesAndSuch,
     TopLevelEntity parent)
     : base(firstToken, modifiers, classToken, classNameToken, subClassesAndSuch, parent)
 {
 }
Ejemplo n.º 4
0
 public EnumDefinition(
     Token firstToken,
     Dictionary <string, Token> modifiers,
     Token name,
     TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.ApplyModifiers(modifiers);
     this.Name = name;
 }
Ejemplo n.º 5
0
 public ConstDefinition(
     Token firstToken,
     Dictionary <string, Token> modifiers,
     CSharpType constType,
     Token name,
     TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.ApplyModifiers(modifiers);
     this.Name = name;
     this.Type = constType;
 }
Ejemplo n.º 6
0
 public PropertyDefinition(
     Token firstToken,
     Dictionary <string, Token> topLevelModifiers,
     CSharpType type,
     Token name,
     TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.ApplyModifiers(topLevelModifiers);
     this.Type = type;
     this.Name = name;
 }
 public ArrayInitialization(
     Token firstToken,
     CSharpType itemType,
     Expression arrayLength,
     IList <Expression> arrayElements,
     TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.ItemType = itemType;
     this.ArrayLengthExpression = arrayLength;
     this.ArrayItems            = arrayElements == null ? null : arrayElements.ToArray();
 }
Ejemplo n.º 8
0
 public VerifiedFieldReference(
     Token firstToken,
     TopLevelEntity parent,
     Token methodName,
     Expression root,
     ResolvedType staticMethodSource)
     : base(firstToken, parent)
 {
     this.Name               = methodName;
     this.RootValue          = root;
     this.StaticMethodSource = staticMethodSource;
     this.Type               = MethodRefType.UNKNOWN;
 }
Ejemplo n.º 9
0
 public FunctionInvocation(
     Token firstToken,
     Expression root,
     Token openParen,
     IList <Expression> args,
     IList <Token> outTokens,
     TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.Root      = root;
     this.OpenParen = openParen;
     this.Args      = args.ToArray();
     this.OutTokens = outTokens.ToArray();
 }
Ejemplo n.º 10
0
 public ClassLikeDefinition(
     Token firstToken,
     Dictionary <string, Token> modifiers,
     Token classToken,
     Token classNameToken,
     List <CSharpType> parentClassesAndSuch,
     TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.ClassToken = classToken;
     this.Name       = classNameToken;
     this.ApplyModifiers(modifiers);
     this.RawParentClassInfoTokens = parentClassesAndSuch.ToArray();
 }
 public ConstructorDefinition(
     Token firstToken,
     Dictionary <string, Token> modifiers,
     IList <CSharpType> argTypes,
     IList <Token> argNames,
     IList <Token> argModifiers,
     TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.ApplyModifiers(modifiers);
     this.ArgTypes     = argTypes.ToArray();
     this.ArgNames     = argNames.ToArray();
     this.ArgModifiers = argModifiers.ToArray();
     this.BaseConstructorInvocation = null;
     this.BaseConstructorArgs       = null;
 }
Ejemplo n.º 12
0
 public VariableDeclaration(
     Token firstToken,
     CSharpType variableType,
     Token variableName,
     Token assignmentToken,
     Expression value,
     TopLevelEntity parent)
     : base(firstToken, parent)
 {
     if (this.FirstToken.File.Contains("AssemblyDependencyResolver.cs") && this.FirstToken.Line == 53)
     {
     }
     this.VariableName    = variableName;
     this.Type            = variableType;
     this.AssignmentToken = assignmentToken;
     this.InitialValue    = value;
 }
Ejemplo n.º 13
0
        public SwitchStatement(
            Token firstToken,
            Expression condition,
            IList <Token> caseTokens,
            IList <Expression> caseConstants,
            IList <Executable[]> codeForCases,
            TopLevelEntity parent)
            : base(firstToken, parent)
        {
            this.Condition = condition;

            List <SwitchStatementChunk> chunks             = new List <SwitchStatementChunk>();
            List <Token>      caseTokensForCurrentChunk    = new List <Token>();
            List <Expression> caseConstantsForCurrentChunk = new List <Expression>();

            for (int i = 0; i < codeForCases.Count; ++i)
            {
                caseTokensForCurrentChunk.Add(caseTokens[i]);
                caseConstantsForCurrentChunk.Add(caseConstants[i]);
                if (codeForCases[i] == null || codeForCases[i].Length == 0)
                {
                    // carry it over to the next chunk
                }
                else
                {
                    chunks.Add(new SwitchStatementChunk()
                    {
                        Cases      = caseConstantsForCurrentChunk.ToArray(),
                        CaseTokens = caseTokensForCurrentChunk.ToArray(),
                        Code       = codeForCases[i],
                    });
                    caseConstantsForCurrentChunk.Clear();
                    caseTokensForCurrentChunk.Clear();
                }
            }

            if (caseConstantsForCurrentChunk.Count > 0)
            {
                throw new ParserException(caseTokens[0], "This case does not have any code and falls through to the bottom of the switch statement.");
            }

            this.Chunks = chunks.ToArray();
        }
Ejemplo n.º 14
0
        private void ResolveCustomFieldReference()
        {
            string fieldName = this.Name.Value;

            if (this.RootValue.ResolvedType.IsEnum)
            {
                if (!this.RootValue.ResolvedType.HasEnumField(fieldName))
                {
                    throw new ParserException(this.Name, this.RootValue.ResolvedType.ToString() + " doesn't have a field called " + fieldName + ".");
                }
                this.ResolvedType = ResolvedType.CreateEnumField(this.RootValue.ResolvedType);
            }
            else
            {
                ClassLikeDefinition rootType = (ClassLikeDefinition)this.RootValue.ResolvedType.CustomType;
                TopLevelEntity      member   = rootType.GetMember(fieldName).FirstOrDefault();
                if (member == null)
                {
                    throw new ParserException(this.Name, "Not implemented or not found.");                 // could be a framework field.
                }
                if (member is PropertyDefinition)
                {
                    this.Property     = (PropertyDefinition)member;
                    this.ResolvedType = this.Property.ResolvedType;
                }
                else if (member is FieldDefinition)
                {
                    this.Field        = (FieldDefinition)member;
                    this.ResolvedType = this.Field.ResolvedType;
                }
                else
                {
                    throw new ParserException(this.FirstToken, "Not implemented");
                }
            }
        }
Ejemplo n.º 15
0
 public ForLoop(Token forToken, IList <Executable> initCode, Expression condition, IList <Executable> stepCode, IList <Executable> loopBody, TopLevelEntity parent)
     : base(forToken, parent)
 {
     this.InitCode  = initCode.ToArray();
     this.Condition = condition;
     this.StepCode  = stepCode.ToArray();
     this.Code      = loopBody.ToArray();
 }
Ejemplo n.º 16
0
 public Lambda(Token firstToken, IList <Token> args, Token arrowToken, IList <Executable> code, TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.Args       = args.ToArray();
     this.ArrowToken = arrowToken;
     this.Code       = code.ToArray();
 }
Ejemplo n.º 17
0
 public ForEachLoop(Token foreachToken, CSharpType type, Token variableToken, Expression listExpression, IList <Executable> loopBody, TopLevelEntity parent)
     : base(foreachToken, parent)
 {
     this.VariableType   = type;
     this.VariableToken  = variableToken;
     this.ListExpression = listExpression;
     this.Code           = loopBody.ToArray();
 }
Ejemplo n.º 18
0
 public void AddMember(TopLevelEntity tle)
 {
     // TODO: check types
     this.members = null;
     this.membersBuilder.Add(tle);
 }
Ejemplo n.º 19
0
 public OpChain(IList <Expression> expressions, IList <Token> ops, TopLevelEntity parent)
     : base(expressions[0].FirstToken, parent)
 {
     this.Expressions = expressions.ToArray();
     this.Ops         = ops.ToArray();
 }
Ejemplo n.º 20
0
 public FieldDefinition(Token firstToken, Dictionary <string, Token> modifiers, CSharpType type, Token name, Expression nullableInitialValue, TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.ApplyModifiers(modifiers);
     this.Type         = type;
     this.Name         = name;
     this.InitialValue = nullableInitialValue;
 }
Ejemplo n.º 21
0
 public DoWhileLoop(Token doToken, Executable[] code, Expression condition, TopLevelEntity parent)
     : base(doToken, parent)
 {
     this.Code      = code;
     this.Condition = condition;
 }
Ejemplo n.º 22
0
 public ThisKeyword(Token firstToken, TopLevelEntity parent)
     : base(firstToken, parent)
 {
 }
Ejemplo n.º 23
0
 public void AddMember(TopLevelEntity entity)
 {
     this.Members.Add(entity);
 }
Ejemplo n.º 24
0
 public Namespace(Token firstToken, IList <Token> nameParts, TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.NameParts = nameParts.ToArray();
     this.Members   = new List <TopLevelEntity>();
 }
Ejemplo n.º 25
0
 public ReturnStatement(Token firstToken, Expression nullableExpression, TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.Value = nullableExpression;
 }
Ejemplo n.º 26
0
        }                                                            // TODO: get rid of the field and just use this.

        public Executable(Token firstToken, TopLevelEntity parent)
            : base(firstToken)
        {
            this.parent = parent;
        }
Ejemplo n.º 27
0
 public UsingStatement(Token firstToken, CSharpType variableType, Token variableName, Expression expression, IList <Executable> code, TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.Type         = variableType;
     this.VariableName = variableName;
     this.Expression   = expression;
     this.Code         = code.ToArray();
 }
Ejemplo n.º 28
0
 public ThrowStatement(Token throwToken, Expression expr, TopLevelEntity parent)
     : base(throwToken, parent)
 {
     this.Expression = expr;
 }
 public MultiVariableDeclaration(Token firstToken, CSharpType type, IList <Token> names, TopLevelEntity parent)
     : base(firstToken, parent)
 {
     this.Type  = type;
     this.Names = names.ToArray();
 }
Ejemplo n.º 30
0
 public WhileLoop(Token whileToken, Expression condition, Executable[] code, TopLevelEntity parent)
     : base(whileToken, parent)
 {
     this.Condition = condition;
     this.Code      = code;
 }