mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-23 00:24:11 -08:00
Start developing WebAssembly model. Implement mostly all expressions
This commit is contained in:
parent
789119e6ea
commit
8c08136c9a
101
core/src/main/java/org/teavm/wasm/model/WasmFunction.java
Normal file
101
core/src/main/java/org/teavm/wasm/model/WasmFunction.java
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.teavm.wasm.model.expression.WasmExpression;
|
||||
|
||||
public class WasmFunction {
|
||||
WasmModule module;
|
||||
private String name;
|
||||
private boolean exported;
|
||||
private String importName;
|
||||
private String importModule;
|
||||
private List<WasmType> parameters = new ArrayList<>();
|
||||
private WasmType result;
|
||||
private List<WasmLocal> localVariables = new ArrayList<>();
|
||||
private List<WasmLocal> readonlyLocalVariables = Collections.unmodifiableList(localVariables);
|
||||
private List<WasmExpression> body = new ArrayList<>();
|
||||
|
||||
public WasmFunction(String name) {
|
||||
Objects.requireNonNull(name);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public WasmModule getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isExported() {
|
||||
return exported;
|
||||
}
|
||||
|
||||
public void setExported(boolean exported) {
|
||||
this.exported = exported;
|
||||
}
|
||||
|
||||
public String getImportName() {
|
||||
return importName;
|
||||
}
|
||||
|
||||
public void setImportName(String importName) {
|
||||
this.importName = importName;
|
||||
}
|
||||
|
||||
public String getImportModule() {
|
||||
return importModule;
|
||||
}
|
||||
|
||||
public void setImportModule(String importModule) {
|
||||
this.importModule = importModule;
|
||||
}
|
||||
|
||||
public WasmType getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(WasmType result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public List<WasmType> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public List<WasmLocal> getLocalVariables() {
|
||||
return readonlyLocalVariables;
|
||||
}
|
||||
|
||||
public List<WasmExpression> getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void add(WasmLocal local) {
|
||||
if (local.function != null) {
|
||||
throw new IllegalArgumentException("This local is already registered in another function");
|
||||
}
|
||||
local.function = this;
|
||||
local.index = localVariables.size();
|
||||
localVariables.add(local);
|
||||
}
|
||||
}
|
60
core/src/main/java/org/teavm/wasm/model/WasmLocal.java
Normal file
60
core/src/main/java/org/teavm/wasm/model/WasmLocal.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmLocal {
|
||||
WasmFunction function;
|
||||
int index;
|
||||
private String name;
|
||||
private WasmType type;
|
||||
|
||||
public WasmLocal(WasmType type, String name) {
|
||||
Objects.requireNonNull(type);
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public WasmLocal(WasmType type) {
|
||||
this(type, null);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public WasmType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WasmType type) {
|
||||
Objects.requireNonNull(type);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public WasmFunction getFunction() {
|
||||
return function;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
}
|
34
core/src/main/java/org/teavm/wasm/model/WasmModule.java
Normal file
34
core/src/main/java/org/teavm/wasm/model/WasmModule.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class WasmModule {
|
||||
private Map<String, WasmFunction> functions = new LinkedHashMap<>();
|
||||
|
||||
public void add(WasmFunction function) {
|
||||
if (functions.containsKey(function.getName())) {
|
||||
throw new IllegalArgumentException("Function " + function.getName() + " already defined in this module");
|
||||
}
|
||||
if (function.module != null) {
|
||||
throw new IllegalArgumentException("Given function is already registered in another module");
|
||||
}
|
||||
functions.put(function.getName(), function);
|
||||
function.module = this;
|
||||
}
|
||||
}
|
23
core/src/main/java/org/teavm/wasm/model/WasmType.java
Normal file
23
core/src/main/java/org/teavm/wasm/model/WasmType.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model;
|
||||
|
||||
public enum WasmType {
|
||||
INT32,
|
||||
INT64,
|
||||
FLOAT32,
|
||||
FLOAT64
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.teavm.wasm.model.WasmLocal;
|
||||
|
||||
public class WasmAssignment extends WasmExpression {
|
||||
private WasmLocal local;
|
||||
private WasmExpression value;
|
||||
|
||||
public WasmAssignment(WasmLocal local, WasmExpression value) {
|
||||
Objects.requireNonNull(local);
|
||||
Objects.requireNonNull(value);
|
||||
this.local = local;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public WasmLocal getLocal() {
|
||||
return local;
|
||||
}
|
||||
|
||||
public void setLocal(WasmLocal local) {
|
||||
Objects.requireNonNull(local);
|
||||
this.local = local;
|
||||
}
|
||||
|
||||
public WasmExpression getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(WasmExpression value) {
|
||||
Objects.requireNonNull(value);
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WasmBlock extends WasmExpression {
|
||||
private boolean loop;
|
||||
private List<WasmExpression> body = new ArrayList<>();
|
||||
|
||||
public WasmBlock(boolean loop) {
|
||||
this.loop = loop;
|
||||
}
|
||||
|
||||
public boolean isLoop() {
|
||||
return loop;
|
||||
}
|
||||
|
||||
public void setLoop(boolean loop) {
|
||||
this.loop = loop;
|
||||
}
|
||||
|
||||
public List<WasmExpression> getBody() {
|
||||
return body;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmBranch extends WasmExpression {
|
||||
private WasmExpression condition;
|
||||
private WasmBlock target;
|
||||
|
||||
public WasmBranch(WasmExpression condition, WasmBlock target) {
|
||||
this.condition = condition;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public WasmExpression getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public void setCondition(WasmExpression condition) {
|
||||
Objects.requireNonNull(condition);
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public WasmBlock getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(WasmBlock target) {
|
||||
Objects.requireNonNull(target);
|
||||
this.target = target;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmCall extends WasmExpression {
|
||||
private String functionName;
|
||||
private boolean imported;
|
||||
private List<WasmExpression> arguments = new ArrayList<>();
|
||||
|
||||
public WasmCall(String functionName, boolean imported) {
|
||||
Objects.requireNonNull(functionName);
|
||||
this.functionName = functionName;
|
||||
this.imported = imported;
|
||||
}
|
||||
|
||||
public WasmCall(String functionName) {
|
||||
this(functionName, false);
|
||||
}
|
||||
|
||||
public String getFunctionName() {
|
||||
return functionName;
|
||||
}
|
||||
|
||||
public void setFunctionName(String functionName) {
|
||||
Objects.requireNonNull(functionName);
|
||||
this.functionName = functionName;
|
||||
}
|
||||
|
||||
public List<WasmExpression> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public boolean isImported() {
|
||||
return imported;
|
||||
}
|
||||
|
||||
public void setImported(boolean imported) {
|
||||
this.imported = imported;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmConditional extends WasmExpression {
|
||||
private WasmExpression condition;
|
||||
private WasmBlock thenBlock = new WasmBlock(false);
|
||||
private WasmBlock elseBlock = new WasmBlock(false);
|
||||
|
||||
public WasmConditional(WasmExpression condition) {
|
||||
Objects.requireNonNull(condition);
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public WasmExpression getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public void setCondition(WasmExpression condition) {
|
||||
Objects.requireNonNull(condition);
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public WasmBlock getThenBlock() {
|
||||
return thenBlock;
|
||||
}
|
||||
|
||||
public WasmBlock getElseBlock() {
|
||||
return elseBlock;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.teavm.wasm.model.WasmType;
|
||||
|
||||
public class WasmConversion extends WasmExpression {
|
||||
private WasmType sourceType;
|
||||
private WasmType targetType;
|
||||
private boolean signed;
|
||||
private WasmExpression operand;
|
||||
|
||||
public WasmConversion(WasmType sourceType, WasmType targetType, boolean signed, WasmExpression operand) {
|
||||
Objects.requireNonNull(sourceType);
|
||||
Objects.requireNonNull(targetType);
|
||||
Objects.requireNonNull(operand);
|
||||
this.sourceType = sourceType;
|
||||
this.targetType = targetType;
|
||||
this.signed = signed;
|
||||
this.operand = operand;
|
||||
}
|
||||
|
||||
public WasmType getSourceType() {
|
||||
return sourceType;
|
||||
}
|
||||
|
||||
public void setSourceType(WasmType sourceType) {
|
||||
Objects.requireNonNull(sourceType);
|
||||
this.sourceType = sourceType;
|
||||
}
|
||||
|
||||
public WasmType getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
|
||||
public void setTargetType(WasmType targetType) {
|
||||
Objects.requireNonNull(targetType);
|
||||
this.targetType = targetType;
|
||||
}
|
||||
|
||||
public boolean isSigned() {
|
||||
return signed;
|
||||
}
|
||||
|
||||
public void setSigned(boolean signed) {
|
||||
this.signed = signed;
|
||||
}
|
||||
|
||||
public WasmExpression getOperand() {
|
||||
return operand;
|
||||
}
|
||||
|
||||
public void setOperand(WasmExpression operand) {
|
||||
Objects.requireNonNull(operand);
|
||||
this.operand = operand;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmDrop extends WasmExpression {
|
||||
private WasmExpression operand;
|
||||
|
||||
public WasmDrop(WasmExpression operand) {
|
||||
Objects.requireNonNull(operand);
|
||||
this.operand = operand;
|
||||
}
|
||||
|
||||
public WasmExpression getOperand() {
|
||||
return operand;
|
||||
}
|
||||
|
||||
public void setOperand(WasmExpression operand) {
|
||||
Objects.requireNonNull(operand);
|
||||
this.operand = operand;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public abstract class WasmExpression {
|
||||
WasmExpression() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public class WasmFloat32Constant extends WasmExpression {
|
||||
private float value;
|
||||
|
||||
public WasmFloat32Constant(float value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(float value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public class WasmFloat64Constant extends WasmExpression {
|
||||
private double value;
|
||||
|
||||
public WasmFloat64Constant(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmFloatBinary extends WasmExpression {
|
||||
private WasmFloatType type;
|
||||
private WasmFloatBinaryOperation operation;
|
||||
private WasmExpression first;
|
||||
private WasmExpression second;
|
||||
|
||||
public WasmFloatBinary(WasmFloatType type, WasmFloatBinaryOperation operation, WasmExpression first,
|
||||
WasmExpression second) {
|
||||
Objects.requireNonNull(type);
|
||||
Objects.requireNonNull(operation);
|
||||
Objects.requireNonNull(first);
|
||||
Objects.requireNonNull(second);
|
||||
this.type = type;
|
||||
this.operation = operation;
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
public WasmFloatType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WasmFloatType type) {
|
||||
Objects.requireNonNull(type);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public WasmFloatBinaryOperation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(WasmFloatBinaryOperation operation) {
|
||||
Objects.requireNonNull(operation);
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public WasmExpression getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public void setFirst(WasmExpression first) {
|
||||
Objects.requireNonNull(first);
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
public WasmExpression getSecond() {
|
||||
return second;
|
||||
}
|
||||
|
||||
public void setSecond(WasmExpression second) {
|
||||
Objects.requireNonNull(second);
|
||||
this.second = second;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public enum WasmFloatBinaryOperation {
|
||||
ADD,
|
||||
SUB,
|
||||
MUL,
|
||||
DIV,
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public enum WasmFloatType {
|
||||
FLOAT32,
|
||||
FLOAT64
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmFloatUnary extends WasmExpression {
|
||||
private WasmFloatType type;
|
||||
private WasmFloatUnaryOperation operation;
|
||||
private WasmExpression operand;
|
||||
|
||||
public WasmFloatUnary(WasmFloatType type, WasmFloatUnaryOperation operation, WasmExpression operand) {
|
||||
Objects.requireNonNull(type);
|
||||
Objects.requireNonNull(operation);
|
||||
Objects.requireNonNull(operand);
|
||||
this.type = type;
|
||||
this.operation = operation;
|
||||
this.operand = operand;
|
||||
}
|
||||
|
||||
public WasmFloatType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WasmFloatType type) {
|
||||
Objects.requireNonNull(type);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public WasmFloatUnaryOperation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(WasmFloatUnaryOperation operation) {
|
||||
Objects.requireNonNull(operation);
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public WasmExpression getOperand() {
|
||||
return operand;
|
||||
}
|
||||
|
||||
public void setOperand(WasmExpression operand) {
|
||||
Objects.requireNonNull(operand);
|
||||
this.operand = operand;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public enum WasmFloatUnaryOperation {
|
||||
ABS,
|
||||
NEG,
|
||||
COPYSIGN,
|
||||
CEIL,
|
||||
FLOOR,
|
||||
TRUNC,
|
||||
NEAREST,
|
||||
MIN,
|
||||
MAX,
|
||||
SQRT,
|
||||
EQ,
|
||||
NE,
|
||||
LT,
|
||||
LE,
|
||||
GT,
|
||||
GE
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmIndirectCall extends WasmExpression {
|
||||
private WasmExpression selector;
|
||||
private List<WasmExpression> arguments;
|
||||
|
||||
public WasmIndirectCall(WasmExpression selector) {
|
||||
Objects.requireNonNull(selector);
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
public WasmExpression getSelector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
public void setSelector(WasmExpression selector) {
|
||||
Objects.requireNonNull(selector);
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
public List<WasmExpression> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public class WasmInt32Constant extends WasmExpression {
|
||||
private int value;
|
||||
|
||||
public WasmInt32Constant(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public enum WasmInt32Subtype {
|
||||
INT8,
|
||||
UINT8,
|
||||
INT16,
|
||||
UINT16,
|
||||
INT32
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public class WasmInt64Constant extends WasmExpression {
|
||||
private long value;
|
||||
|
||||
public WasmInt64Constant(long value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(long value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public enum WasmInt64Subtype {
|
||||
INT8,
|
||||
UINT8,
|
||||
INT16,
|
||||
UINT16,
|
||||
INT32,
|
||||
UINT32,
|
||||
INT64
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmIntBinary extends WasmExpression {
|
||||
private WasmIntType type;
|
||||
private WasmIntBinaryOperation operation;
|
||||
private WasmExpression first;
|
||||
private WasmExpression second;
|
||||
|
||||
public WasmIntBinary(WasmIntType type, WasmIntBinaryOperation operation, WasmExpression first,
|
||||
WasmExpression second) {
|
||||
Objects.requireNonNull(type);
|
||||
Objects.requireNonNull(operation);
|
||||
Objects.requireNonNull(first);
|
||||
Objects.requireNonNull(second);
|
||||
this.type = type;
|
||||
this.operation = operation;
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
public WasmIntType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WasmIntType type) {
|
||||
Objects.requireNonNull(type);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public WasmIntBinaryOperation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(WasmIntBinaryOperation operation) {
|
||||
Objects.requireNonNull(operation);
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public WasmExpression getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public void setFirst(WasmExpression first) {
|
||||
Objects.requireNonNull(first);
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
public WasmExpression getSecond() {
|
||||
return second;
|
||||
}
|
||||
|
||||
public void setSecond(WasmExpression second) {
|
||||
Objects.requireNonNull(second);
|
||||
this.second = second;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public enum WasmIntBinaryOperation {
|
||||
ADD,
|
||||
SUB,
|
||||
MUL,
|
||||
DIV_SIGNED,
|
||||
DIV_UNSIGNED,
|
||||
REM_SIGNED,
|
||||
REM_UNSIGNED,
|
||||
OR,
|
||||
AND,
|
||||
XOR,
|
||||
SHL,
|
||||
SHR_SIGNED,
|
||||
SHR_UNSIGNED,
|
||||
ROTL,
|
||||
ROTR,
|
||||
EQ,
|
||||
NE,
|
||||
LT_SIGNED,
|
||||
LT_UNSIGNED,
|
||||
LE_SIGNED,
|
||||
LE_UNSIGNED,
|
||||
GT_SIGNED,
|
||||
GT_UNSIGNED,
|
||||
GE_SIGNED,
|
||||
GE_UNSIGNED
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public enum WasmIntType {
|
||||
INT32,
|
||||
INT64
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmIntUnary extends WasmExpression {
|
||||
private WasmIntType type;
|
||||
private WasmIntUnaryOperation operation;
|
||||
private WasmExpression operand;
|
||||
|
||||
public WasmIntUnary(WasmIntType type, WasmIntUnaryOperation operation, WasmExpression operand) {
|
||||
Objects.requireNonNull(type);
|
||||
Objects.requireNonNull(operation);
|
||||
Objects.requireNonNull(operand);
|
||||
this.type = type;
|
||||
this.operation = operation;
|
||||
this.operand = operand;
|
||||
}
|
||||
|
||||
public WasmIntType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WasmIntType type) {
|
||||
Objects.requireNonNull(type);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public WasmIntUnaryOperation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(WasmIntUnaryOperation operation) {
|
||||
Objects.requireNonNull(operation);
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public WasmExpression getOperand() {
|
||||
return operand;
|
||||
}
|
||||
|
||||
public void setOperand(WasmExpression operand) {
|
||||
Objects.requireNonNull(operand);
|
||||
this.operand = operand;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public enum WasmIntUnaryOperation {
|
||||
CLZ,
|
||||
CTZ,
|
||||
POPCNT
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmLoadFloat32 extends WasmExpression {
|
||||
private int alignment;
|
||||
private WasmExpression index;
|
||||
|
||||
public WasmLoadFloat32(int alignment, WasmExpression index) {
|
||||
Objects.requireNonNull(index);
|
||||
this.alignment = alignment;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public int getAlignment() {
|
||||
return alignment;
|
||||
}
|
||||
|
||||
public void setAlignment(int alignment) {
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
public WasmExpression getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(WasmExpression index) {
|
||||
Objects.requireNonNull(index);
|
||||
this.index = index;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmLoadFloat64 extends WasmExpression {
|
||||
private int alignment;
|
||||
private WasmExpression index;
|
||||
|
||||
public WasmLoadFloat64(int alignment, WasmExpression index) {
|
||||
Objects.requireNonNull(index);
|
||||
this.alignment = alignment;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public int getAlignment() {
|
||||
return alignment;
|
||||
}
|
||||
|
||||
public void setAlignment(int alignment) {
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
public WasmExpression getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(WasmExpression index) {
|
||||
Objects.requireNonNull(index);
|
||||
this.index = index;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmLoadInt32 extends WasmExpression {
|
||||
private int alignment;
|
||||
private WasmExpression index;
|
||||
private WasmInt32Subtype convertFrom;
|
||||
|
||||
public WasmLoadInt32(int alignment, WasmExpression index, WasmInt32Subtype convertFrom) {
|
||||
Objects.requireNonNull(index);
|
||||
Objects.requireNonNull(convertFrom);
|
||||
this.alignment = alignment;
|
||||
this.index = index;
|
||||
this.convertFrom = convertFrom;
|
||||
}
|
||||
|
||||
public int getAlignment() {
|
||||
return alignment;
|
||||
}
|
||||
|
||||
public void setAlignment(int alignment) {
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
public WasmExpression getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(WasmExpression index) {
|
||||
Objects.requireNonNull(index);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public WasmInt32Subtype getConvertFrom() {
|
||||
return convertFrom;
|
||||
}
|
||||
|
||||
public void setConvertFrom(WasmInt32Subtype convertFrom) {
|
||||
Objects.requireNonNull(convertFrom);
|
||||
this.convertFrom = convertFrom;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmLoadInt64 extends WasmExpression {
|
||||
private int alignment;
|
||||
private WasmExpression index;
|
||||
private WasmInt64Subtype convertFrom;
|
||||
|
||||
public WasmLoadInt64(int alignment, WasmExpression index, WasmInt64Subtype convertFrom) {
|
||||
Objects.requireNonNull(index);
|
||||
Objects.requireNonNull(convertFrom);
|
||||
this.alignment = alignment;
|
||||
this.index = index;
|
||||
this.convertFrom = convertFrom;
|
||||
}
|
||||
|
||||
public int getAlignment() {
|
||||
return alignment;
|
||||
}
|
||||
|
||||
public void setAlignment(int alignment) {
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
public WasmExpression getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(WasmExpression index) {
|
||||
Objects.requireNonNull(index);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public WasmInt64Subtype getConvertFrom() {
|
||||
return convertFrom;
|
||||
}
|
||||
|
||||
public void setConvertFrom(WasmInt64Subtype convertFrom) {
|
||||
Objects.requireNonNull(convertFrom);
|
||||
this.convertFrom = convertFrom;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.teavm.wasm.model.WasmLocal;
|
||||
|
||||
public class WasmLocalReference extends WasmExpression {
|
||||
private WasmLocal local;
|
||||
|
||||
public WasmLocalReference(WasmLocal local) {
|
||||
Objects.requireNonNull(local);
|
||||
this.local = local;
|
||||
}
|
||||
|
||||
public WasmLocal getLocal() {
|
||||
return local;
|
||||
}
|
||||
|
||||
public void setLocal(WasmLocal local) {
|
||||
Objects.requireNonNull(local);
|
||||
this.local = local;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public class WasmReturn extends WasmExpression {
|
||||
private WasmExpression value;
|
||||
|
||||
public WasmReturn(WasmExpression value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public WasmReturn() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public WasmExpression getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(WasmExpression value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmStoreFloat32 extends WasmExpression {
|
||||
private int alignment;
|
||||
private WasmExpression index;
|
||||
private WasmExpression value;
|
||||
|
||||
public WasmStoreFloat32(int alignment, WasmExpression index, WasmExpression value) {
|
||||
Objects.requireNonNull(index);
|
||||
Objects.requireNonNull(value);
|
||||
this.alignment = alignment;
|
||||
this.index = index;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getAlignment() {
|
||||
return alignment;
|
||||
}
|
||||
|
||||
public void setAlignment(int alignment) {
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
public WasmExpression getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(WasmExpression index) {
|
||||
Objects.requireNonNull(index);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public WasmExpression getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(WasmExpression value) {
|
||||
Objects.requireNonNull(value);
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmStoreFloat64 extends WasmExpression {
|
||||
private int alignment;
|
||||
private WasmExpression index;
|
||||
private WasmExpression value;
|
||||
|
||||
public WasmStoreFloat64(int alignment, WasmExpression index, WasmExpression value) {
|
||||
Objects.requireNonNull(index);
|
||||
Objects.requireNonNull(value);
|
||||
this.alignment = alignment;
|
||||
this.index = index;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getAlignment() {
|
||||
return alignment;
|
||||
}
|
||||
|
||||
public void setAlignment(int alignment) {
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
public WasmExpression getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(WasmExpression index) {
|
||||
Objects.requireNonNull(index);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public WasmExpression getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(WasmExpression value) {
|
||||
Objects.requireNonNull(value);
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmStoreInt32 extends WasmExpression {
|
||||
private int alignment;
|
||||
private WasmExpression index;
|
||||
private WasmExpression value;
|
||||
private WasmInt32Subtype convertTo;
|
||||
|
||||
public WasmStoreInt32(int alignment, WasmExpression index, WasmExpression value,
|
||||
WasmInt32Subtype convertTo) {
|
||||
Objects.requireNonNull(index);
|
||||
Objects.requireNonNull(convertTo);
|
||||
Objects.requireNonNull(value);
|
||||
this.alignment = alignment;
|
||||
this.index = index;
|
||||
this.value = value;
|
||||
this.convertTo = convertTo;
|
||||
}
|
||||
|
||||
public int getAlignment() {
|
||||
return alignment;
|
||||
}
|
||||
|
||||
public void setAlignment(int alignment) {
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
public WasmExpression getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(WasmExpression index) {
|
||||
Objects.requireNonNull(index);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public WasmExpression getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(WasmExpression value) {
|
||||
Objects.requireNonNull(value);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public WasmInt32Subtype getConvertTo() {
|
||||
return convertTo;
|
||||
}
|
||||
|
||||
public void setConvertTo(WasmInt32Subtype convertTo) {
|
||||
Objects.requireNonNull(convertTo);
|
||||
this.convertTo = convertTo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmStoreInt64 extends WasmExpression {
|
||||
private int alignment;
|
||||
private WasmExpression index;
|
||||
private WasmExpression value;
|
||||
private WasmInt64Subtype convertTo;
|
||||
|
||||
public WasmStoreInt64(int alignment, WasmExpression index, WasmExpression value,
|
||||
WasmInt64Subtype convertTo) {
|
||||
Objects.requireNonNull(index);
|
||||
Objects.requireNonNull(convertTo);
|
||||
Objects.requireNonNull(value);
|
||||
this.alignment = alignment;
|
||||
this.index = index;
|
||||
this.value = value;
|
||||
this.convertTo = convertTo;
|
||||
}
|
||||
|
||||
public int getAlignment() {
|
||||
return alignment;
|
||||
}
|
||||
|
||||
public void setAlignment(int alignment) {
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
public WasmExpression getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(WasmExpression index) {
|
||||
Objects.requireNonNull(index);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public WasmExpression getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(WasmExpression value) {
|
||||
Objects.requireNonNull(value);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public WasmInt64Subtype getConvertTo() {
|
||||
return convertTo;
|
||||
}
|
||||
|
||||
public void setConvertTo(WasmInt64Subtype convertTo) {
|
||||
Objects.requireNonNull(convertTo);
|
||||
this.convertTo = convertTo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class WasmSwitch extends WasmExpression {
|
||||
private WasmExpression selector;
|
||||
private List<WasmBlock> targets = new ArrayList<>();
|
||||
private WasmBlock defaultTarget;
|
||||
|
||||
public WasmSwitch(WasmExpression selector, WasmBlock defaultTarget) {
|
||||
this.selector = selector;
|
||||
this.defaultTarget = defaultTarget;
|
||||
}
|
||||
|
||||
public WasmExpression getSelector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
public void setSelector(WasmExpression selector) {
|
||||
Objects.requireNonNull(selector);
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
public WasmBlock getDefaultTarget() {
|
||||
return defaultTarget;
|
||||
}
|
||||
|
||||
public void setDefaultTarget(WasmBlock defaultTarget) {
|
||||
Objects.requireNonNull(defaultTarget);
|
||||
this.defaultTarget = defaultTarget;
|
||||
}
|
||||
|
||||
public List<WasmBlock> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2016 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.wasm.model.expression;
|
||||
|
||||
public class WasmUnreachable extends WasmExpression {
|
||||
public static final WasmUnreachable INSTANCE = new WasmUnreachable();
|
||||
|
||||
private WasmUnreachable() {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user