예제 #1
0
		public DotStepStruct(Token token, StructDefinition structDef, DotStep original, Executable owner)
			: base(token, owner)
		{
			this.DotToken = original.DotToken;
			this.RawRoot = original.Root;
			this.RootVar = "v_" + ((Variable)original.Root).Name.Split('$')[1];
			this.FieldName = original.StepToken.Value;
			this.StructDefinition = structDef;
		}
예제 #2
0
 public DotStepStruct(Token token, StructDefinition structDef, DotStep original, Executable owner)
     : base(token, owner)
 {
     this.DotToken         = original.DotToken;
     this.RawRoot          = original.Root;
     this.RootVar          = "v_" + ((Variable)original.Root).Name.Split('$')[1];
     this.FieldName        = original.StepToken.Value;
     this.StructDefinition = structDef;
 }
예제 #3
0
        internal override IList <Executable> Resolve(Parser parser)
        {
            this.Target = this.Target.Resolve(parser);

            if (this.Target is Variable)
            {
                this.Target = this.Target.Resolve(parser);
            }
            else if (this.Target is BracketIndex)
            {
                BracketIndex bi = this.Target as BracketIndex;
                bi.Root  = bi.Root.Resolve(parser);
                bi.Index = bi.Index.Resolve(parser);
            }
            else if (this.Target is DotStep)
            {
                DotStep ds = this.Target as DotStep;
                ds.Root = ds.Root.Resolve(parser);
            }

            this.Value = this.Value.Resolve(parser);

            return(Listify(this));
        }
예제 #4
0
		protected override void TranslateDotStep(List<string> output, DotStep dotStep)
		{
			output.Add("(");
			TranslateExpression(output, dotStep.Root);
			output.Add(")");
			output.Add(".f_");
			output.Add(dotStep.StepToken.Value);
		}
예제 #5
0
		private void CompileDotStep(Parser parser, ByteBuffer buffer, DotStep dotStep, bool outputUsed)
		{
			if (!outputUsed) throw new ParserException(dotStep.FirstToken, "This expression does nothing.");
			this.CompileExpression(parser, buffer, dotStep.Root, true);
			int primitiveMethodId = Constants.GetPrimitiveFieldId(dotStep.StepToken.Value);
			buffer.Add(dotStep.DotToken, OpCode.DEREF_DOT, parser.GetId(dotStep.StepToken.Value), primitiveMethodId);
		}
예제 #6
0
		private static Expression ParseEntity(TokenStream tokens, Executable owner)
		{
			Expression root;
			if (tokens.PopIfPresent("("))
			{
				root = Parse(tokens, owner);
				tokens.PopExpected(")");
			}
			else
			{
				root = ParseEntityWithoutSuffixChain(tokens, owner);
			}
			bool anySuffixes = true;
			while (anySuffixes)
			{
				if (tokens.IsNext("."))
				{
					Token dotToken = tokens.Pop();
					Token stepToken = tokens.Pop();
					Parser.VerifyIdentifier(stepToken);
					root = new DotStep(root, dotToken, stepToken, owner);
				}
				else if (tokens.IsNext("["))
				{
					Token openBracket = tokens.Pop();
					List<Expression> sliceComponents = new List<Expression>();
					if (tokens.IsNext(":"))
					{
						sliceComponents.Add(null);
					}
					else
					{
						sliceComponents.Add(Parse(tokens, owner));
					}

					for (int i = 0; i < 2; ++i)
					{
						if (tokens.PopIfPresent(":"))
						{
							if (tokens.IsNext(":") || tokens.IsNext("]"))
							{
								sliceComponents.Add(null);
							}
							else
							{
								sliceComponents.Add(Parse(tokens, owner));
							}
						}
					}

					tokens.PopExpected("]");

					if (sliceComponents.Count == 1)
					{
						Expression index = sliceComponents[0];
						root = new BracketIndex(root, openBracket, index, owner);
					}
					else
					{
						root = new ListSlice(root, sliceComponents, openBracket, owner);
					}
				}
				else if (tokens.IsNext("("))
				{
					Token openParen = tokens.Pop();
					List<Expression> args = new List<Expression>();
					while (!tokens.PopIfPresent(")"))
					{
						if (args.Count > 0)
						{
							tokens.PopExpected(",");
						}

						args.Add(Parse(tokens, owner));
					}
					root = new FunctionCall(root, openParen, args, owner);
				}
				else
				{
					anySuffixes = false;
				}
			}
			return root;
		}
예제 #7
0
		protected abstract void TranslateDotStep(List<string> output, DotStep dotStep);