Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,18 @@ public interface Variable {

/** The platform. */
int PLATFORM = 16;

int DATA = 17;

/** The number. */
// Update this variable when adding a kind of symbol
int __NUMBER__ = 17;
int __NUMBER__ = 18;

/** The template menu. */
String[] TEMPLATE_MENU = { "Species", "Model", "Statement", "Behavior", "Parameter", "Output", "Layer", "Skill",
"Batch", "Batch", "", "Statement", "Statement", "Experiment", "", "Operator", "" };

/** The Constant STATEMENTS_WITH_ATTRIBUTES. */
Set<Integer> STATEMENTS_CONTAINING_ATTRIBUTES = new HashSet<>(Arrays.asList(SPECIES, EXPERIMENT, OUTPUT, MODEL));
Set<Integer> STATEMENTS_CONTAINING_ATTRIBUTES = new HashSet<>(Arrays.asList(SPECIES, EXPERIMENT, OUTPUT, MODEL, DATA));

}
2 changes: 2 additions & 0 deletions gama.core/src/gama/core/common/interfaces/IKeyword.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ public interface IKeyword {

/** The data. */
String DATA = "data";

String DATA_TYPE = "data_type";

/** The default. */
String DEFAULT = "default";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ public void setWorkingPath(final String p) {
* @return the parameters
*/
@getter (IKeyword.PARAMETERS)
@doc ("retuns the map of parameters defined in this experiment")
@doc ("returns the map of parameters defined in this experiment")
public GamaMap<String, Object> getParameters(final IScope scope) {
return getParameterValues();
}
Expand Down
52 changes: 52 additions & 0 deletions gama.core/src/gama/core/util/GamaData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*******************************************************************************************************
*
* GamaData.java, in gama.core, is part of the source code of the GAMA modeling and simulation platform (v.2025-03).
*
* (c) 2007-2025 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, ESPACE-DEV, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
********************************************************************************************************/
package gama.core.util;

import gama.core.common.interfaces.IValue;
import gama.core.runtime.IScope;
import gama.core.runtime.exceptions.GamaRuntimeException;
import gama.core.util.file.json.Json;
import gama.core.util.file.json.JsonValue;

/**
* The Class GamaData.
*/
public class GamaData implements IValue {

@Override
public JsonValue serializeToJson(final Json json) {
// TODO Auto-generated method stub
return null;
}

@Override
public String stringValue(final IScope scope) throws GamaRuntimeException {
// TODO Auto-generated method stub
return null;
}

@Override
public IValue copy(final IScope scope) throws GamaRuntimeException {
// TODO Auto-generated method stub
return null;
}

/**
* Gets the field value.
*
* @param name
* the name
* @return the field value
*/
public Object getFieldValue(final String name) {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import gama.core.runtime.IScope;
import gama.gaml.architecture.IArchitecture;
import gama.gaml.expressions.IExpression;
import gama.gaml.skills.Skill;
import gama.gaml.species.ISpecies;

Expand Down Expand Up @@ -43,10 +42,10 @@ public String getTrace(final IScope scope) {
return "";
}

@Override
public IExpression getFacet(final String... key) {
return null;
}
// @Override
// public IExpression getFacet(final String... key) {
// return null;
// }

@Override
public boolean hasFacet(final String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ protected void removeFacet(final String name) {
@Override
public boolean isExperiment() { return false; }


@Override
public boolean isData() { return false; }

@Override
public boolean isSkill() { return false; }


/*
* (non-Javadoc)
*
Expand Down Expand Up @@ -286,6 +294,14 @@ public void visitSpecies(final SyntacticVisitor visitor) {}
*/
@Override
public void visitExperiments(final SyntacticVisitor visitor) {}


@Override
public void visitData(final SyntacticVisitor visitor) {}

@Override
public void visitSkills(final SyntacticVisitor visitor) {}


/*
* (non-Javadoc)
Expand Down
35 changes: 34 additions & 1 deletion gama.core/src/gama/gaml/compilation/ast/ISyntacticElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,19 @@ public interface SyntacticVisitor {
* The Constant EXPERIMENT_FILTER.
*/
Predicate<ISyntacticElement> EXPERIMENT_FILTER = ISyntacticElement::isExperiment;

/**
* The Constant DATA_FILTER.
*/
Predicate<ISyntacticElement> DATA_FILTER = ISyntacticElement::isData;

Predicate<ISyntacticElement> SKILL_FILTER = ISyntacticElement::isSkill;

/**
* The Constant OTHER_FILTER.
*/
Predicate<ISyntacticElement> OTHER_FILTER = each -> !each.isExperiment() && !each.isSpecies();
Predicate<ISyntacticElement> OTHER_FILTER = each -> !each.isExperiment() && !each.isSpecies()
&& !each.isData() && !each.isSkill();

/**
* Sets the keyword of the element.
Expand Down Expand Up @@ -170,6 +178,15 @@ public interface SyntacticVisitor {
* @return true if the element is an experiment, false otherwise
*/
boolean isExperiment();

/**
* Returns whether this element represents data.
*
* @return true if the element is data, false otherwise
*/
boolean isData();

boolean isSkill();

/**
* Whether this elements has any facets.
Expand Down Expand Up @@ -217,6 +234,22 @@ public interface SyntacticVisitor {
* the visitor, not null
*/
void visitExperiments(final SyntacticVisitor visitor);

/**
* Allows a visitor to visit only the elements that are data (either this element or its children).
*
* @param visitor
* the visitor, not null
*/
void visitData(final SyntacticVisitor visitor);

/**
* Allows a visitor to visit only the elements that are skills (either this element or its children).
*
* @param visitor
* the visitor, not null
*/
void visitSkills(final SyntacticVisitor visitor);

/**
* Allows a visitor to visit only the elements that are grids (either this element or its children).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package gama.gaml.compilation.ast;

import org.eclipse.emf.ecore.EObject;

import gama.gaml.statements.Facets;

public class SyntacticDataTypeElement extends SyntacticStructuralElement {

public SyntacticDataTypeElement(final String keyword, final Facets facets, final EObject statement) {
super(keyword, facets, statement);
}

@Override
public boolean isData() {
return true;
}


}
4 changes: 4 additions & 0 deletions gama.core/src/gama/gaml/compilation/ast/SyntacticFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
********************************************************************************************************/
package gama.gaml.compilation.ast;

import static gama.core.common.interfaces.IKeyword.DATA_TYPE;
import static gama.core.common.interfaces.IKeyword.EXPERIMENT;
import static gama.core.common.interfaces.IKeyword.GRID;
import static gama.core.common.interfaces.IKeyword.MODEL;
import static gama.core.common.interfaces.IKeyword.SPECIES;
import static gama.core.common.interfaces.IKeyword.SKILL;

import org.eclipse.emf.ecore.EObject;

Expand Down Expand Up @@ -136,6 +138,8 @@ public static ISyntacticElement create(final String keyword, final Facets facets
if (SPECIES.equals(keyword) || GRID.equals(keyword))
return new SyntacticSpeciesElement(keyword, facets, statement);
else if (EXPERIMENT.equals(keyword)) return new SyntacticExperimentElement(keyword, facets, statement);
else if (DATA_TYPE.equals(keyword)) return new SyntacticDataTypeElement(keyword, facets, statement);
else if (SKILL.equals(keyword)) return new SyntacticSkillElement(keyword, facets, statement);
if (!withChildren) return new SyntacticSingleElement(keyword, facets, statement);
return new SyntacticComposedElement(keyword, facets, statement);
}
Expand Down
11 changes: 11 additions & 0 deletions gama.core/src/gama/gaml/compilation/ast/SyntacticModelElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ public void visitExperiments(final SyntacticVisitor visitor) {
visitAllChildren(visitor, EXPERIMENT_FILTER);
}

@Override
public void visitData(final SyntacticVisitor visitor) {
visitAllChildren(visitor, DATA_FILTER);
}

@Override
public void visitSkills(final SyntacticVisitor visitor) {
visitAllChildren(visitor, SKILL_FILTER);
}


/**
* The compacter.
*/
Expand Down
19 changes: 19 additions & 0 deletions gama.core/src/gama/gaml/compilation/ast/SyntacticSkillElement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package gama.gaml.compilation.ast;

import org.eclipse.emf.ecore.EObject;

import gama.gaml.statements.Facets;

public class SyntacticSkillElement extends SyntacticStructuralElement {

public SyntacticSkillElement(final String keyword, final Facets facets, final EObject statement) {
super(keyword, facets, statement);
}

@Override
public boolean isSkill() {
return true;
}


}
75 changes: 75 additions & 0 deletions gama.core/src/gama/gaml/descriptions/DataTypeDescription.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*******************************************************************************************************
*
* DataTypeDescription.java, in gama.core, is part of the source code of the GAMA modeling and simulation platform
* (v.2025-03).
*
* (c) 2007-2025 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, ESPACE-DEV, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
********************************************************************************************************/
package gama.gaml.descriptions;

import org.eclipse.emf.ecore.EObject;

import gama.core.util.GamaData;
import gama.gaml.statements.Facets;

/**
* The Class DataTypeDescription.
*/
public class DataTypeDescription extends TypeDescription {

/**
* Instantiates a new data type description.
*
* @param keyword
* the keyword
* @param clazz
* the clazz
* @param macroDesc
* the macro desc
* @param parent
* the parent
* @param cp
* the cp
* @param source
* the source
* @param facets
* the facets
* @param plugin
* the plugin
*/
public DataTypeDescription(final String keyword, final Class clazz, final IDescription macroDesc,
final TypeDescription parent, final Iterable<? extends IDescription> cp, final EObject source,
final Facets facets, final String plugin) {
super(keyword, clazz, macroDesc, parent, cp, source, facets, plugin);
}

@Override
public boolean isBuiltIn() { return false; }

@Override
public String getTitle() { return "data_type " + getName(); }

@Override
public DataTypeDescription getParent() { return (DataTypeDescription) super.getParent(); }

@Override
public Class getJavaBase() { return GamaData.class; }

@Override
public IDescription addChild(final IDescription child) {
super.addChild(child);
switch (child) {
case ActionDescription ad:
addAction(ad);
break;
case VariableDescription vd:
addOwnAttribute(vd);
break;
default:
}
return child;
}
}
Loading