All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.uscexp.dotnotation.parser.attributedetail.AstAttributeArrayDetailTreeNode Maven / Gradle / Ivy

/*
 * Copyright (C) 2014 - 2018 by haui - all rights reserved
 */
package com.github.uscexp.dotnotation.parser.attributedetail;

import com.github.uscexp.parboiled.extension.interpreter.ProcessStore;
import com.github.uscexp.parboiled.extension.nodes.AstCommandTreeNode;
import com.github.uscexp.parboiled.extension.util.IStack;

/**
 * @author haui
 *
 */
public class AstAttributeArrayDetailTreeNode extends AstCommandTreeNode {

	public AstAttributeArrayDetailTreeNode(String node, String value) {
		super(node, value);
	}

	@Override
	protected void interpretAfterChilds(Long id) throws ReflectiveOperationException {
		ProcessStore processStore = ProcessStore.getInstance(id);
		IStack stack = processStore.getStack();
		AttributeDetailInterpreterResult attributeDetailInterpreterResult = (AttributeDetailInterpreterResult) processStore.getVariable(
				AttributeDetailParser.ATTRIBUTE_DETAIL_INTERPRETER_RESULT);
		if(!attributeDetailInterpreterResult.isMapType()) {
			attributeDetailInterpreterResult.setArrayType(true);
			if(!stack.isEmpty()) {
				String index = (String) stack.pop();
				attributeDetailInterpreterResult.setIndex(Integer.valueOf(index));
			}
		}
	}

	@Override
	protected void interpretBeforeChilds(Long id) throws Exception {
	}

}