
js.prompto.declaration.ConcreteMethodDeclaration.js Maven / Gradle / Ivy
var BaseMethodDeclaration = require("./BaseMethodDeclaration").BaseMethodDeclaration;
var VoidType = require("../type/VoidType").VoidType;
var DictType = require("../type/DictType").DictType;
var TextType = require("../type/TextType").TextType;
var CodeArgument = require("../argument/CodeArgument").CodeArgument;
var CategoryArgument = require("../argument/CategoryArgument").CategoryArgument;
function ConcreteMethodDeclaration(id, args, returnType, statements) {
BaseMethodDeclaration.call(this, id, args, returnType);
this.statements = statements;
this.returnType = returnType || null;
return this;
}
ConcreteMethodDeclaration.prototype = Object.create(BaseMethodDeclaration.prototype);
ConcreteMethodDeclaration.prototype.constructor = ConcreteMethodDeclaration;
ConcreteMethodDeclaration.prototype.memberCheck = function(declaration, context) {
// TODO Auto-generated method stub
};
ConcreteMethodDeclaration.prototype.check = function(context) {
if(this.canBeChecked(context)) {
return this.fullCheck(context, false);
} else {
return VoidType.instance;
}
};
ConcreteMethodDeclaration.prototype.canBeChecked = function(context) {
if(context.isGlobalContext()) {
return !this.mustBeBeCheckedInCallContext(context);
} else {
return true;
}
};
ConcreteMethodDeclaration.prototype.mustBeBeCheckedInCallContext = function(context) {
// if at least one argument is 'Code'
if(this.args===null) {
return false;
}
for(var i=0;i");
this.returnType.toDialect(writer);
}
writer.append(":\n");
writer.indent();
this.statements.toDialect(writer);
writer.dedent();
};
ConcreteMethodDeclaration.prototype.toEDialect = function(writer) {
writer.append("define ");
writer.append(this.name);
writer.append(" as method ");
this.args.toDialect(writer);
if(this.returnType!=null && this.returnType!=VoidType.instance) {
writer.append("returning ");
this.returnType.toDialect(writer);
writer.append(" ");
}
writer.append("doing:\n");
writer.indent();
this.statements.toDialect(writer);
writer.dedent();
};
ConcreteMethodDeclaration.prototype.toODialect = function(writer) {
if(this.returnType!=null && this.returnType!=VoidType.instance) {
this.returnType.toDialect(writer);
writer.append(" ");
}
writer.append("method ");
writer.append(this.name);
writer.append(" (");
this.args.toDialect(writer);
writer.append(") {\n");
writer.indent();
this.statements.toDialect(writer);
writer.dedent();
writer.append("}\n");
};
exports.ConcreteMethodDeclaration = ConcreteMethodDeclaration;
© 2015 - 2025 Weber Informatics LLC | Privacy Policy